All pastes #902406 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-02-13 13:42 UTC
rendered paste body
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>Neparmaksa.lv</title>
	<style type="text/css" media="all">@import "style.css";</style>
	<style type="text/css" media="all">@import "thickbox.css";</style>
	<script type="text/javascript" src="js/jquery-latest.pack.js"></script>

	<script type="text/javascript" src="js/jquery.tablesorter.pack.js"></script>
	<script type="text/javascript" src="js/jquery.cookie.pack.js"></script>
	<script type="text/javascript" src="js/jquery.validation.js"></script>
	<script type="text/javascript" src="js/jquery.thickbox.js"></script>
	<script type="text/javascript">

      function findPos(obj) {
        var curleft = obj.offsetLeft || 0;
        var curtop  = obj.offsetTop || 0;
        while (obj = obj.offsetParent) {
          curleft += obj.offsetLeft
          curtop += obj.offsetTop
        }
        return {x:curleft,y:curtop};
      }

      function formatRate(mnt) {
        mnt -= 0;
        mnt = (Math.round(mnt*100))/100;
        return (mnt == Math.floor(mnt)) ? mnt + '.0'  : ( (mnt*10 == Math.floor(mnt*10)) ? mnt + '' : mnt);
      }
        	
      $(document).ready(function(){
        
        $('div#tab_first').bind('click',function() {
          window.location = "http://orkz.id.lv/n/?cat=mobile";
          return false;
        });
        
        $('div#tab_proceed').bind('click',function() {
          window.location = "http://orkz.id.lv/n/?cat=mobile&proceed=1";
          return false;
        });
        
      });
  </script>	
</head>
<body>

<!-- page start -->
<div id="wrapper">
  <div id="header">
						
			<a href="http://orkz.id.lv/n/"><img src="img/logo.lat.gif" /></a>
    
				<div id="menu">
      
   
    
    
      
  
    
  
    

  
    <a href="?">Sākumlapa</a> > <a href="?cat=home&sub=services">Pakalpojumi</a> > <a href="?cat=mobile">Mobilo tālruņu operatoru sarunu tarifi</a>

    
  
     
</div>	</div>
	
	<!-- tabs -->
  
    <div id="tabs">
  	<div class="bar_enabled_left"></div><div id="tab_first" class="bar_enabled_main">1. Kritēriju ievade</div><div class="bar_enabled_right"></div>
  	<div class="bar_tab_left"></div><div class="bar_tab_main">2. Rezultāts</div><div class="bar_tab_right"></div>
  </div>
  


  
  <!-- content -->

      <div id="main" class="homex">
      <style>
 td.cmp_rate_bar {
 	padding: 5px 5px 1px 15px !important
 }
 
 td.cmp_rate_info {
 	padding: 5px 5px 1px 5px !important;
 }
</style>
<pre>Array
(
    [6] => Array
        (
            [0] => 2
            [1] => 4
            [2] => 4
            [3] => 4
        )

    [7] => Array
        (
            [0] => 5
            [1] => 5
            [2] => 5
            [3] => 5
            [4] => 5
        )

    [9] => Array
        (
            [0] => 4
            [1] => 4
            [2] => 4
            [3] => 5
            [4] => 5
        )

)
</pre><script type="text/javascript">

	function contains(a, e) {
		for(j=0;j<a.length;j++)if(a[j]==e)return true;
		return false;
	}

	function unique(a) {
		tmp = new Array(0);
		for(i=0;i<a.length;i++){
			if(!contains(tmp, a[i])){
				tmp.length+=1;
				tmp[tmp.length-1]=a[i];
			}
		}
		return tmp;
	}    
	
	var animation = '<img src="img/ajax-loader.gif" />';
	var benefical_td   = [];   
	var best_td	 	= [];
	var min_td	 	= []; 
	var col = [];  
	var opers = [];
 
   opers['LMT'] = ['LMT', '<img src="img/logo/mobile_lmt.gif" alt="LMT" /> <br /><br /><a target="_blank" href="http://lmt.lv/lv/index.php">mājas lapa</a>'];
  opers['Tele2'] = ['Tele2', '<img src="img/logo/mobile_tele2.gif" alt="Tele2" /> <br /><br /><a target="_blank" href="http://tele2.lv/">mājas lapa</a>'];
  opers['Bite'] = ['Bite', '<img src="img/logo/mobile_bite.gif" alt="Bite" /> <br /><br /><a target="_blank" href="http://www.bite.lv/">mājas lapa</a>'];

  var op_vote_all = [];
  
  op_vote_all['LMT'] = [];
  op_vote_all['LMT'][0]  = [4.5, 9, 2]; 
  op_vote_all['LMT'][1]  = [5.0, 10, 2];
  op_vote_all['LMT'][2]  = [4.5, 9, 2];
  op_vote_all['LMT'][3]  = [5.0, 10, 2];
  op_vote_all['LMT'][4]  = [3.5, 7, 2];
  op_vote_all['Tele2'] = [];
  op_vote_all['Tele2'][0]  = [3.0, 6, 2]; 
  op_vote_all['Tele2'][1]  = [5.0, 10, 2];
  op_vote_all['Tele2'][2]  = [5.0, 10, 2];
  op_vote_all['Tele2'][3]  = [5.0, 10, 2];
  op_vote_all['Tele2'][4]  = [4.0, 8, 2];
  op_vote_all['Bite'] = [];
  op_vote_all['Bite'][0]  = [4.0, 4, 1]; 
  op_vote_all['Bite'][1]  = [3.0, 3, 1];
  op_vote_all['Bite'][2]  = [4.5, 9, 2];
  op_vote_all['Bite'][3]  = [3.5, 7, 2];
  op_vote_all['Bite'][4]  = [3.5, 7, 2];

  var op_vote_user = [];
  
  op_vote_user['LMT']  = [0, 0, 0, 0, 0];
  op_vote_user['Tele2']  = [0, 0, 0, 0, 0];
  op_vote_user['Bite']  = [0, 0, 0, 0, 0];

  var companies = [];  
  
  companies['1']      = ['6.32', 'LMT',      '<img src="img/logo_LMT.gif" />'];
  companies['2']      = ['8', 'LMT',      '<img src="img/logo_LMT.gif" />'];
  companies['3']      = ['18', 'LMT',      '<img src="img/logo_LMT.gif" />'];
  companies['4']      = ['28', 'LMT',      '<img src="img/logo_LMT.gif" />'];
  companies['5']      = ['8.94', 'Tele2',      '<img src="img/logo_Tele2.gif" />'];
  companies['6']      = ['8.75', 'Tele2',      '<img src="img/logo_Tele2.gif" />'];
  companies['7']      = ['7', 'Tele2',      '<img src="img/logo_Tele2.gif" />'];
  companies['8']      = ['7.14', 'Tele2',      '<img src="img/logo_Tele2.gif" />'];
  companies['9']      = ['7', 'Bite',      '<img src="img/logo_Bite.gif" />'];
  companies['10']      = ['15', 'Bite',      '<img src="img/logo_Bite.gif" />'];
  companies['11']      = ['25', 'Bite',      '<img src="img/logo_Bite.gif" />'];
  
  var last_cmp = false;

  var tarifs = [];

  
  tarifs['1'] = 'Vietejais / Vietejais+';
  
  tarifs['2'] = 'Formula 8';
  
  tarifs['3'] = 'Formula 18';
  
  tarifs['4'] = 'Formula 28';
  
  tarifs['5'] = 'Starta tarifs';
  
  tarifs['6'] = 'Aktivais tarifs';
  
  tarifs['7'] = 'Brivais tarifs';
  
  tarifs['8'] = 'Vienotais tarifs';
  
  tarifs['9'] = 'Popularais 240';
  
  tarifs['10'] = 'Popularais 600';
  
  tarifs['11'] = 'Popularais 1200';

  function displayCompany(cmp) {
    //Hide all opened
    $("tr").remove('#cmp_info');
    
    //Quick hack - restore design for last
    if (last_cmp !== false) { 
		if (col[last_cmp]) {
	      $("tr#cmp_" + last_cmp).find("td").css('background-color', '#fff4cd');
	      $("tr#cmp_" + last_cmp).find("td").css('border-top', '');		
		}
		else {
	      $("tr#cmp_" + last_cmp).find("td").css('background-color', '');
	      $("tr#cmp_" + last_cmp).find("td").css('border-top', '');		
		}
    }
      
    //Check if user closed
    if (last_cmp == cmp) {
      last_cmp = false; return false;
    }
    
    //Quick hack - change design for active 
    $("tr#cmp_" + cmp).find("td").css('background-color', '#D1F1DC');
    $("tr#cmp_" + cmp).find("td").css('border-top', '1px solid #9F9F9F');        

    last_cmp = cmp;
     
    //Generate company info
    var tmp = '';

    tmp += '<tr id="cmp_info" class="cmp_info"><td colspan="5" style="padding: 0; border-bottom: 1px solid #9F9F9F">';
    
    tmp += '<table class="tblInner" id="' + cmp + '_info" cellspacing="0" cellpadding="0">';
    tmp += '<tr valign="top">';
    
    tmp += '<td width="250">' + opers[ companies[cmp][1] ][1] + '</td>'; 
    
    tmp += '<td>';
    
    tmp += '<table class="tblInner" cellspacing="0" cellpadding="0">';

    tmp += '<tr>';
    
    tmp += '<td class="cmp_rate_info">&nbsp;</td>';
    tmp += '<td class="cmp_rate_info"><b>Lietotāju vērtējums</b></td>';
    tmp += '<td class="cmp_rate_info"><b>Tavs vērtējums</b></td>'; 
    tmp += '</tr>';

    tmp += '<tr>';
    tmp += '<td class="cmp_rate_info">Klientu apkalpošana:</td>';
    tmp += '<td class="cmp_rate_bar"><div class="rating_bar ' + companies[cmp][1] + '_all_0"  id="' + cmp + '_all_0"><div></div></div> <span class="' + companies[cmp][1] + '_label_0" id="' + cmp + '_label_0"></span></td>';
    tmp += '<td class="cmp_rate_bar"><div class="rating_user ' + companies[cmp][1] + '_user_0" id="' + cmp + '_user_0"><div></div></div></td>';
    tmp += '</tr>';
    
    tmp += '<tr>';
    tmp += '<td class="cmp_rate_info">Iegādes/samaksas ērtums:</td>';
    tmp += '<td class="cmp_rate_bar"><div class="rating_bar ' + companies[cmp][1] + '_all_1"  id="' + cmp + '_all_1"><div></div></div> <span class="' + companies[cmp][1] + '_label_1" id="' + cmp + '_label_1"></span></td>';
    tmp += '<td class="cmp_rate_bar"><div class="rating_user ' + companies[cmp][1] + '_user_1" id="' + cmp + '_user_1"><div></div></div></td>';
    tmp += '</tr>';

    tmp += '<tr>';
    tmp += '<td class="cmp_rate_info">Sarunu/tīlka kvalitāte:</td>';
    tmp += '<td class="cmp_rate_bar"><div class="rating_bar ' + companies[cmp][1] + '_all_2"  id="' + cmp + '_all_2"><div></div></div> <span class="' + companies[cmp][1] + '_label_2" id="' + cmp + '_label_2"></td>';
    tmp += '<td class="cmp_rate_bar"><div class="rating_user ' + companies[cmp][1] + '_user_2" id="' + cmp + '_user_2"><div></div></div></td>';
    tmp += '</tr>';
    
    tmp += '<tr>';
    tmp += '<td class="cmp_rate_info">Pārklājums:</td>';
    tmp += '<td class="cmp_rate_bar"><div class="rating_bar ' + companies[cmp][1] + '_all_3"  id="' + cmp + '_all_3"><div></div></div> <span class="' + companies[cmp][1] + '_label_3" id="' + cmp + '_label_3"></td>';
    tmp += '<td class="cmp_rate_bar"><div class="rating_user ' + companies[cmp][1] + '_user_3" id="' + cmp + '_user_3"><div></div></div></td>';
    tmp += '</tr>';
    
    tmp += '<tr>';
    tmp += '<td class="cmp_rate_info">Papildpakalpojumi <br />(atlaides, mazcenas telefoni u.c.):</td>';
    tmp += '<td class="cmp_rate_bar"><div class="rating_bar ' + companies[cmp][1] + '_all_4"  id="' + cmp + '_all_4"><div></div></div> <span class="' + companies[cmp][1] + '_label_4" id="' + cmp + '_label_4"></td>';
    tmp += '<td class="cmp_rate_bar"><div class="rating_user ' + companies[cmp][1] + '_user_4" id="' + cmp + '_user_4"><div></div></div></td>';
    tmp += '</tr>';
    
    tmp += '<tr>';
    tmp += '<td colspan="3" class="cmp_rate_info"><h4>Vidējais:</h4> <div class="rating_bar" style="margin-top: 2px;" id="' + cmp + '_all_total"><div></div></div> <span class="' + companies[cmp][1] + '_label_total" id="' + cmp + '_label_total" style="float: left; font-weight: bold; font-size: 115%;"></span></td>';
    tmp += '</tr>';
    
    tmp += '</table>';
    
    tmp += '</td>';
    tmp += '</table>';
    
    tmp += '</td></tr>';
    
    //Insert info into table
    $("tr#cmp_" + cmp).after(tmp);
    
    //Add clickable ratings
    $('div.rating_user').hover(function(e) {
      
      //Add full stars when user moves mouse
      $(this).bind('mousemove', function(e) {

        //var prc = Math.ceil(Math.round((((e.pageX - findPos(this).x) * 100) / $(this).width())) * 5 / 100) * 20;
        
        stz_x = 0;
        stz_y = 0;
        
        if (!e) var e = window.event;
        if (e.pageX || e.pageY)  {
          stz_x = e.pageX;
          stz_y = e.pageY;
        } else if (e.clientX || e.clientY)  {
          stz_x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
          stz_y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
        }
        
        var prc = Math.ceil(Math.round((((stz_x - findPos(this).x) * 100) / $(this).width())) * 5 / 100) * 20;
        
        prc = prc > 100 ? 100 : prc;

        $(this).find('div').css("width", prc + "%");           
      });
    }, function() {
    
      //Collect garbage
      $(this).unbind("mousemove");
      $(this).unbind("click");

      //Restore user vote
      var tmp = $(this).attr("id"); tmp = tmp.split("_");

      var xxx = companies[ tmp[0] ][1];

      $(this).find('div').css("width", (op_vote_user[ xxx ][ (tmp[2]) ]) * 20 + "%");          
    });  

    //Proceed vote on click
    $('div.rating_user > div').bind('click', function(e) {
      //var vote  = Math.ceil(Math.round((((e.pageX - findPos(this).x) * 100) / $(this).width())) * 5 / 100);

      var vote = $(this).css("width");
      var vote = parseFloat( vote );
      
      vote = Math.ceil(vote / 20); 
      
      if (vote < 1 || vote > 5) {
        return;
      }
      
      var tmp   = $(this).parent().attr("id"); tmp = tmp.split("_");

      var cmp = tmp[0];
      var nr  = tmp[2];
      
      updateUserRatings(cmp, nr, vote);

      //Send vote
      $.post("http://orkz.id.lv/n/scripts/np_vote.php", { mod: 'mobile', vote: vote, item: cmp, nr: nr });
    });
    
    updateCmpRatings(cmp);
    
    return false;
  }
  
  function updateUserRatings(cmp, nr, vote) {
    
    var xxx = companies[cmp][1];
        
    //Update all votes
    op_vote_all[ xxx ][ nr ][ 1 ] = op_vote_user[ xxx ][ nr ] > 0 ? op_vote_all[ xxx ][ nr ][ 1 ]  - op_vote_user[ xxx ][ nr ] + vote : op_vote_all[ xxx ][ nr ][ 1 ] + vote;
    op_vote_all[ xxx ][ nr ][ 2 ] = op_vote_user[ xxx ][ nr ] > 0 ? op_vote_all[ xxx ][ nr ][ 2 ] : op_vote_all[ xxx ][ nr ][ 2 ] + 1;
    
    var tmp1 = op_vote_all[ xxx ][ nr ][ 2 ] > 0 ? Math.round(( op_vote_all[ xxx ][ nr ][ 1 ] / op_vote_all[ xxx ][ nr ][ 2 ]) * 10) / 10 : op_vote_all[ xxx ][ nr ][ 1 ];

    op_vote_all[ xxx ][ nr ][ 0 ] = tmp1;        
     
    $("span." + xxx + "_label_" + nr).html(formatRate(tmp1));
    $("div." + xxx + "_all_"   + nr).find('div').css("width", (tmp1 * 20) + "%");
    
    var tmp2 = Math.round( ((op_vote_all[ xxx ][0][0] + op_vote_all[ xxx ][1][0] + op_vote_all[ xxx ][2][0] + op_vote_all[ xxx ][3][0] + op_vote_all[ xxx ][4][0])  / 5) * 20);

    $("div." + xxx + "_all_total").find('div').css("width",  tmp2  + "%");
    
    $("div." + xxx + "_rating_main").find('div').css("width",  tmp2  + "%");
      
    var tmp3 = (Math.round( ((op_vote_all[ xxx ][0][0] + op_vote_all[ xxx ][1][0] + op_vote_all[ xxx ][2][0] + op_vote_all[ xxx ][3][0] + op_vote_all[ xxx ][4][0]) / 5) * 10) / 10);
       
    $("span." + xxx + "_label_total").html(formatRate(tmp3));
    $("span." + xxx + "_label_main").html(formatRate(tmp3)+' ('+op_vote_all[ xxx ][0][2]+')');
    
    //Update user vote
    op_vote_user[ xxx ][ nr ] = vote;

    var total = op_vote_user[ xxx ][0] > 0 && op_vote_user[ xxx ][1] > 0 ? Math.round( ((op_vote_user[ xxx ][0] + op_vote_user[ xxx ][1] + op_vote_user[ xxx ][2] + op_vote_user[ xxx ][3] + op_vote_user[ xxx ][4]) / 5) * 20) : op_vote_user[ xxx ][ nr ] * 20;

    //Update table sorting
    $("#tblResults").trigger("update");
  }
  
  function updateCmpRatings(cmp) {
  
    var xxx = companies[cmp][1];
    
    //All
    $("div." + xxx + "_all_total").find('div').css("width",  (Math.round( ((op_vote_all[ xxx ][0][0] + op_vote_all[ xxx ][1][0] + op_vote_all[ xxx ][2][0] + op_vote_all[ xxx ][3][0] + op_vote_all[ xxx ][4][0])  / 5) * 20)) + "%");
    $("span." + xxx + "_label_total").html( formatRate( (Math.round( ((op_vote_all[ xxx ][0][0] + op_vote_all[ xxx ][1][0] + op_vote_all[ xxx ][2][0] + op_vote_all[ xxx ][3][0] + op_vote_all[ xxx ][4][0]) / 5) * 10) / 10)) );
    
    $("div." + xxx + "_all_0").find('div').css("width",  (op_vote_all[ xxx ][0][0] * 20)  + "%");
    $("div." + xxx + "_all_1").find('div').css("width",  (op_vote_all[ xxx ][1][0] * 20) + "%");
    $("div." + xxx + "_all_2").find('div').css("width",  (op_vote_all[ xxx ][2][0] * 20) + "%");
    $("div." + xxx + "_all_3").find('div').css("width",  (op_vote_all[ xxx ][3][0] * 20) + "%");
    $("div." + xxx + "_all_4").find('div').css("width",  (op_vote_all[ xxx ][4][0] * 20) + "%");
    
    $("span." + xxx + "_label_0").html(formatRate(op_vote_all[ xxx ][0][0]));
    $("span." + xxx + "_label_1").html(formatRate(op_vote_all[ xxx ][1][0])); 
    $("span." + xxx + "_label_2").html(formatRate(op_vote_all[ xxx ][2][0]));
    $("span." + xxx + "_label_3").html(formatRate(op_vote_all[ xxx ][3][0]));
    $("span." + xxx + "_label_4").html(formatRate(op_vote_all[ xxx ][4][0]));   
    
    //User
    $("div." + xxx + "_user_0").find('div').css("width",  (op_vote_user[ xxx ][0] * 20)  + "%");
    $("div." + xxx + "_user_1").find('div').css("width",  (op_vote_user[ xxx ][1] * 20)  + "%");
    $("div." + xxx + "_user_2").find('div').css("width",  (op_vote_user[ xxx ][2] * 20)  + "%");
    $("div." + xxx + "_user_3").find('div').css("width",  (op_vote_user[ xxx ][3] * 20)  + "%");
    $("div." + xxx + "_user_4").find('div').css("width",  (op_vote_user[ xxx ][4] * 20)  + "%");
    
  }
  
  function updateMainRatings() {
    for (var cmp in companies) {
      var xxx = companies[cmp][1];

      //var tmp = Math.round( (cmp_vote_all[ cmp ][0][0]  + cmp_vote_all[ cmp ][1][0]) * 5) / 10;
      //console.info(cmp);
      
      var tmp = Math.round( (op_vote_all[ xxx ][0][0]  + op_vote_all[ xxx ][1][0] + op_vote_all[ xxx ][2][0] + op_vote_all[ xxx ][3][0] + op_vote_all[ xxx ][4][0]) * 5 * (2/5)) / 10;
      
      //$("#" + cmp + "_rating_main").find('div').css("width",  (tmp * 20) + "%");
      //$("#" + cmp + "_label_main").html(formatRate(tmp));
      $("div." + xxx + "_rating_main").find('div').css("width",  (tmp * 20) + "%");
      $("span." + xxx + "_label_main").html(formatRate(tmp)+' ('+op_vote_all[ xxx ][0][2]+')');
    }
    
    $("table#tblResults").trigger("update");
  }
  
  function displayGraph() {
    
    var str   = 'mod=mobile';
    
    var benefical_cmp  = false;
    var benefical_rate = false;
    var benefical_arr   = [];       
          
    var cheapest_cmp    = false;
    var cheapest_price  = false;
    var cheapest_arr    = [];    

    var best_cmp  = false;
    var best_rate = 0;
    var best_arr  = [];
    
    for (var cmp in companies) {
      var xxx = companies[cmp][1];
    
      //Benefical
      var tmp_rate = companies[cmp][0] * (( op_vote_all[ xxx ][0][0] + op_vote_all[ xxx ][1][0] + op_vote_all[ xxx ][2][0]+ op_vote_all[ xxx ][3][0]+ op_vote_all[ xxx ][4][0]) /5 );
      
      if (benefical_rate == false) {
        benefical_cmp   = cmp;
        benefical_rate  = tmp_rate;  
		benefical_td[cmp] = true;		
      } else {          
        if (tmp_rate <  benefical_rate) { 
          benefical_cmp   = cmp;
          benefical_rate  = tmp_rate;
		  benefical_td = [];		  
		  benefical_td[cmp] = true;	
        }            
      }
      
      //Generate iframe url for graph      
      if (companies[cmp][0] == parseFloat(companies[cmp][0])) {
        //str += '&' + cmp + '=' + tmp_rate;
        str += '&price[' + cmp + ']=' + companies[cmp][0] + '&rate[' + cmp + ']=' + ( Math.round(( (( op_vote_all[ xxx ][0][0] + op_vote_all[ xxx ][1][0] + op_vote_all[ xxx ][2][0]+ op_vote_all[ xxx ][3][0]+ op_vote_all[ xxx ][4][0]) /5 )) * 10) / 10); 
      }
      
      //Cheapest
      if (companies[cmp][0] == parseFloat(companies[cmp][0])) {
        
        if (cheapest_cmp == false) {
          cheapest_cmp    = cmp;
          cheapest_price  = companies[cmp][0];
		  min_td[cmp] = true;	

        } else {        
          companies[cmp][0] = parseFloat(companies[cmp][0]);
          
          if (cheapest_price > companies[cmp][0]) {          
            cheapest_cmp    = cmp;
            cheapest_price  = companies[cmp][0];
			min_td		= [];
			min_td[cmp] = true;
          }
        }
      }
      
      //Best  
      var tmp_rate = Math.round( (op_vote_all[ xxx ][0][0] + op_vote_all[ xxx ][1][0] + op_vote_all[ xxx ][2][0] + op_vote_all[ xxx ][3][0] + op_vote_all[ xxx ][4][0]) * 10) / 10;
      
      if (tmp_rate > best_rate) { 
        best_rate = tmp_rate;
        best_cmp  = cmp;
        best_arr  = [];
		best_td	  = [];
      }

      if (tmp_rate == best_rate) {
        if (best_arr.toString().indexOf(companies[cmp][1])!==-1) {
        }

        //console.info(  best_arr.toString().indexOf(companies[cmp][1]) );
                
        best_arr.push(companies[cmp][1]);
        
        best_arr = unique(best_arr);
		best_td[cmp] = true;;
      }
    }
    
    if (cheapest_cmp == false) {
      $("div#error").show();
      return;
    }
    
    $("span#benefical_cmp").html(companies[benefical_cmp][1] + '/' + tarifs[benefical_cmp] );
    
    //console.info(cheapest_cmp);
    
    $("span#cheapest_cmp").html(companies[cheapest_cmp][1] + '/' + tarifs[cheapest_cmp] );
      
	for (var p in min_td) {
		col[p] = true;	
		$("tr#cmp_" + p).find("td").css('background-color', '#fff4cd');
		$("td#info_" + p).html($("td#info_" + p).html()+'<b>Zemākā<br /></b>');
	}
	for (var p in best_td) {
		$("tr#cmp_" + p).find("td").css('background-color', '#fff4cd');
		$("td#info_" + p).html($("td#info_" + p).html()+'<b>Labākais<br /></b>');
		col[p] = true;
	}	
	for (var p in benefical_td) {
		$("tr#cmp_" + p).find("td").css('background-color', '#fff4cd');
		$("td#info_" + p).html($("td#info_" + p).html()+'<b>Izdevīgākais</b><br />');
		col[p] = true;
	}	  
	  
	  
	  
    //Best
    var tmp = best_arr.join("<br /> ");
    $("span#best_cmp").html(tmp);
    
    //Proceed graph
    str += '&benefical_cmp=' + benefical_cmp;
    
    $('#graph_frame').attr('src', 'http://orkz.id.lv/n/graph/?' + str);
      
    $("div#graph").show();
    
    $("table#tblResults").trigger("update");
    
  }
  
  $(document).ready(function() {

    //Initialize table sorting
    $.tablesorter.addParser({ 
        id: 'rating', 
        is: function(s) { 
            return false; 
        }, 
        format: function(s) { 
            var regex = /<span.+>(.*)\(.*\)<\/span>/i;
            var match = regex.exec(s);
			var res = (match == null) ? 0 : match[1];
            return res;
        }, 
        type: 'numeric' 
    });
    
    //Remove any opened company info when sorting
    $('th.header').bind('click',function() {
      $("tr").remove('.cmp_info');
      
      if (last_cmp !== false) { 
		if (col[last_cmp]) {
	      $("tr#cmp_" + last_cmp).find("td").css('background-color', '#fff4cd');
	      $("tr#cmp_" + last_cmp).find("td").css('border-top', '');		
		}
		else {
	      $("tr#cmp_" + last_cmp).find("td").css('background-color', '');
	      $("tr#cmp_" + last_cmp).find("td").css('border-top', '');		
		}
      }
    }); 
    
    $("table#tblResults").tablesorter({widgets: ['zebra'], headers: {2: {sorter:'rating'}}});
    $("#tblResults").trigger("sorton", [[[3,0]]]);
    
    //Update company ratings
    updateMainRatings();
    
    displayGraph(); 

  });
</script>
<h3>Esam atraduši sekojošus piedāvājumus</h3>
<div id="content">

  <table class="tbl" id="tblResults" cellpadding="5" cellspacing="0">
  <thead>
  <tr>

    <th class="header" width="100">Operators</th>
    <th class="header" width="175">Tarifs</th>
    <th class="header" width="230">Vērtējums</th>
    <th class="header" width="230">Cena</th>
    <th class="header" width="215"></th>
  </tr>
  </thead>

  <tbody>
  <tr id="cmp_1">
    <td><a href="javascript:void(0);" onClick="displayCompany('1');">LMT</a></td>
    <td>Vietejais / Vietejais+</td>
    <td class="td_rate" id="rate_1"><div><div class="rating_bar LMT_rating_main" id="1_rating_main"><div></div></div> <span class="LMT_label_main" id="1_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">6.32</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_1">&nbsp;</td>

  </tr>
  <tr id="cmp_2">
    <td><a href="javascript:void(0);" onClick="displayCompany('2');">LMT</a></td>
    <td>Formula 8</td>
    <td class="td_rate" id="rate_2"><div><div class="rating_bar LMT_rating_main" id="2_rating_main"><div></div></div> <span class="LMT_label_main" id="2_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">8.00</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_2">&nbsp;</td>

  </tr>
  <tr id="cmp_3">
    <td><a href="javascript:void(0);" onClick="displayCompany('3');">LMT</a></td>
    <td>Formula 18</td>
    <td class="td_rate" id="rate_3"><div><div class="rating_bar LMT_rating_main" id="3_rating_main"><div></div></div> <span class="LMT_label_main" id="3_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">18.00</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_3">&nbsp;</td>

  </tr>
  <tr id="cmp_4">
    <td><a href="javascript:void(0);" onClick="displayCompany('4');">LMT</a></td>
    <td>Formula 28</td>
    <td class="td_rate" id="rate_4"><div><div class="rating_bar LMT_rating_main" id="4_rating_main"><div></div></div> <span class="LMT_label_main" id="4_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">28.00</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_4">&nbsp;</td>

  </tr>
  <tr id="cmp_5">
    <td><a href="javascript:void(0);" onClick="displayCompany('5');">Tele2</a></td>
    <td>Starta tarifs</td>
    <td class="td_rate" id="rate_5"><div><div class="rating_bar Tele2_rating_main" id="5_rating_main"><div></div></div> <span class="Tele2_label_main" id="5_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">8.94</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_5">&nbsp;</td>

  </tr>
  <tr id="cmp_6">
    <td><a href="javascript:void(0);" onClick="displayCompany('6');">Tele2</a></td>
    <td>Aktivais tarifs</td>
    <td class="td_rate" id="rate_6"><div><div class="rating_bar Tele2_rating_main" id="6_rating_main"><div></div></div> <span class="Tele2_label_main" id="6_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">8.75</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_6">&nbsp;</td>

  </tr>
  <tr id="cmp_7">
    <td><a href="javascript:void(0);" onClick="displayCompany('7');">Tele2</a></td>
    <td>Brivais tarifs</td>
    <td class="td_rate" id="rate_7"><div><div class="rating_bar Tele2_rating_main" id="7_rating_main"><div></div></div> <span class="Tele2_label_main" id="7_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">7.00</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_7">&nbsp;</td>

  </tr>
  <tr id="cmp_8">
    <td><a href="javascript:void(0);" onClick="displayCompany('8');">Tele2</a></td>
    <td>Vienotais tarifs</td>
    <td class="td_rate" id="rate_8"><div><div class="rating_bar Tele2_rating_main" id="8_rating_main"><div></div></div> <span class="Tele2_label_main" id="8_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">7.14</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_8">&nbsp;</td>

  </tr>
  <tr id="cmp_9">
    <td><a href="javascript:void(0);" onClick="displayCompany('9');">Bite</a></td>
    <td>Popularais 240</td>
    <td class="td_rate" id="rate_9"><div><div class="rating_bar Bite_rating_main" id="9_rating_main"><div></div></div> <span class="Bite_label_main" id="9_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">7.00</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_9">&nbsp;</td>

  </tr>
  <tr id="cmp_10">
    <td><a href="javascript:void(0);" onClick="displayCompany('10');">Bite</a></td>
    <td>Popularais 600</td>
    <td class="td_rate" id="rate_10"><div><div class="rating_bar Bite_rating_main" id="10_rating_main"><div></div></div> <span class="Bite_label_main" id="10_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">15.00</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_10">&nbsp;</td>

  </tr>
  <tr id="cmp_11">
    <td><a href="javascript:void(0);" onClick="displayCompany('11');">Bite</a></td>
    <td>Popularais 1200</td>
    <td class="td_rate" id="rate_11"><div><div class="rating_bar Bite_rating_main" id="11_rating_main"><div></div></div> <span class="Bite_label_main" id="11_label_main"></span></div></td>
    <td align="right" style="padding-right: 50px;">25.00</td>
	<td align="right" style="padding-right: 10px; font-size: 13px;" id="info_11">&nbsp;</td>

  </tr>
  </tbody>
  </table>
  
  <span class="star" style="padding-left: 30px;">*</span> Informācija tiek nolasīta no pakalpojuma sniedzēja Interneta lapas - 12/11/2007
  
  <div id="error" style="display: none;">
    <div id="alert" class="error_info">
      <div class="bar_alert_left"></div><div class="bar_alert_main">Lūdzu, pārbaudi ievades datus!</div><div class="bar_alert_right"></div>
    </div>

     
    <br /><br />
  </div>

  <div style="float: right; padding: 0 18px 10px 0;"><a href="?cat=mobile">Atpakaļ</a></div><br clear="all" />
</div>
  	</div>
    
	<div id="footer">
    <a href="http://blog.neparmaksa.lv">Blogs</a> | <a href="?cat=home&sub=contacts">Kontakti</a> <br />

    © 2007 Neparmaksa.lv (beta)
	</div>
</div>
<!-- page end -->

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script src="http://www.gmetrix.lv/search.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-2904825-1";
urchinTracker();
</script> 
</body>
</html>