// this function is needed to work around 
  // a bug in IE related to element attributes
function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
}   

function stripeTable(id) {

    var even = false;
  
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#ededed";
  
    var table = document.getElementById(id);
    if (! table) { return; }
	
    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {
    
     // find all the &lt;tr&gt; elements... 
      var trs = tbodies[h].getElementsByTagName("tr");
      
      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {

        // avoid rows that have a class attribute
        // or backgroundColor style
        if (! hasClass(trs[i]) &&
            ! trs[i].style.backgroundColor) {
 		  
          // get all the cells in this row...
          var tds = trs[i].getElementsByTagName("td");
        
          // and iterate through them...
          for (var j = 0; j < tds.length; j++) {
        
            var mytd = tds[j];

            // avoid cells that have a class attribute
            // or backgroundColor style
            if (! hasClass(mytd) &&
                ! mytd.style.backgroundColor) {
        
              mytd.style.backgroundColor =
                even ? evenColor : oddColor;
            
            }
          }
        }
        // flip from odd to even, or vice-versa
        even =  ! even;
      }
    }
  }




function MM_setTextOfLayer(objId, x, newText) { //v.proper
    if((obj = document.getElementById(objId)) != null){
        document.getElementById(objId).innerHTML = unescape(newText);
    }
}
var nrTelefoane = 0;
var preturi = new Array() ;
var preturi2 = new Array();
var optiuniTelefoane = new Array();
/*
function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}
*/
function parseTabel() {
var j = 0;
var k = 0;

var stripedTable = document.getElementById("stripedTable");
var tds = stripedTable.getElementsByTagName("td");
		for (i=0; i<tds.length; i++) {
			if (((i-1) % 3) == 0) {
				preturi[j] = tds[i].innerHTML;
				j = j + 1;
				}
			if (((i-2) % 3) == 0) {
				preturi2[k] = tds[i].innerHTML;
				k = k + 1;
				}
			if ((i % 3) == 0) {
			    telefonLink = tds[i].innerHTML;
				optiuniTelefoane[nrTelefoane] = telefonLink;
				nrTelefoane = nrTelefoane + 1;
			}
		}
}				

var sel=0; 

function priceUpdate(){
var tva=0;
var pts=document.phoneForm.OTY.value;
var tmp=0, fin=0, base=0;

if (sel==0) return 0;
//alert(sel);
//alert(document.phoneForm.contract[0].checked);
if (document.phoneForm.contract[0].checked) {base=preturi[sel-1]} else {base=preturi2[sel-1]};
//if (document.phoneForm.contract.value=="contract_12") {base=preturi[sel-1]} else {base=preturi2[sel-1]};

MM_setTextOfLayer('LTelName','','<span class="ortext">'+document.phoneForm.dropPhone.options[sel].text+'<\/span>');
MM_setTextOfLayer('LTelPrice','',base);
//alert(base);
//MM_setTextOfLayer('LPriceTVA','',Math.floor((base*tva)*100)/100);
MM_setTextOfLayer('LPriceAdj','','0');
MM_setTextOfLayer('LPriceFinal','',Math.floor((base*(1+tva))*100)/100);

if ((preturi[sel-1]!=preturi2[sel-1])&&document.phoneForm.contract[1].checked)
	{	MM_setTextOfLayer('contractNote','','In conditiile prelungirii relatiei contractuale cu Orange Romania cu 24 de luni.');	}
	else
	{	MM_setTextOfLayer('contractNote','','&nbsp;');	}

if (isNaN(pts) || pts.length==0 || pts.indexOf('x')!=-1) {
	MM_setTextOfLayer('LPriceAdj','','-');

	return;
	}
	else {
	pts=parseFloat(pts);
	fin=Math.max(0,base*(1+tva)-pts/10);
	fin=Math.ceil(fin*100)/100;
	tmp=fin.toString();
	if (tmp.indexOf('.')==-1) tmp+='.00'
	else 
	if (tmp.indexOf('.')==tmp.length-2) tmp+='0';
	fin=tmp;
//		MM_setTextOfLayer('LBase'+i,'',preturi[i]);
	tmp=0-pts/10;
	tmp=tmp.toString();
	MM_setTextOfLayer('LPriceAdj','',tmp);
	MM_setTextOfLayer('LPriceFinal','',fin);
	}
	
}


function selectUpdate() {
//location.href="http://www.orange.ro";
sel=document.phoneForm.dropPhone.selectedIndex;
//alert(sel);
priceUpdate();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->