<!--Begin //
var iitem1,iitem2,iitem3,iitem4,iitem5;
var arrayindex_mb=new Array();
var arrayindex_cpu=new Array();
var arrayindex_mem=new Array();

function getradio(doc,section){ //getradio(document.MB,'mb')
getRadios(doc,section);
iprice(doc.ITEM,doc.price,section);
initform();
}
function free_offer(){
//document.order.Special_Request.value='Free Memory Module Cooler installed for MB Bundle order over $150'; 
}
function setCheckedValue(radioObj, newValue) { //document.MB.item5, ALL
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function getmodel(mb,cpu,mem){ 
 window.document.MB.model.value=mb[0];
 window.document.CPU.model.value=cpu[0];
 window.document.MEM.model.value=mem[0];
  
 var cpu_sku=cpu[2];
 setCheckedValue(document.MB.item1,'ALL');
 setCheckedValue(document.MEM.item2,'ALL');
 getradio(document.MB,'mb');
 getradio(document.MEM,'mem');

 //pdata('ALL','ALL','ALL','ALL','ALL','mb');
 select_list_item(mb[0],'mb');
 iprice(document.MB.ITEM,document.MB.price,'mb');
 //pdata('ALL','ALL','ALL','ALL','ALL','cpu');
 select_list_item(cpu_sku,'cpu');
 iprice(document.CPU.ITEM,document.CPU.price,'cpu');
 //pdata('ALL','ALL','ALL','ALL','ALL','mem');
 select_list_item(mem[0],'mem');
 iprice(document.MEM.ITEM,document.MEM.price,'mem');
 initform();
}

function select_list_item(select_item,section){
  var iselect;
  var str;
  //select_item=select_item.toLowerCase();
  
  if (section=='mb'){ 
    iselect = window.document.MB.ITEM;
	select_item=' '+select_item+' ';
  }
  if(section=='cpu'){ 
    iselect = window.document.CPU.ITEM;
  }
  if(section=='mem'){ 
    iselect = window.document.MEM.ITEM;
  }
  for(i=0;i<iselect.length;i++){
     str=iselect.options[i].text;
     //str=str.toLowerCase(); 
	 if(str.search(select_item)>=0){
	    iselect.options[i].selected=true;
		break;
	 }
	 
  }

}
function getRadios(what, section){
// get item1 value
what.model.value='ALL';
j=what.item1.length; //alert(j)
	for (i=0; i<j; i++){
		if(what.item1[i].checked) var item1 = what.item1[i].value
	}
//get item2 type
j=what.item2.length; //alert(j)
	for (i=0; i<j; i++){
		if(what.item2[i].checked) var item2 = what.item2[i].value
	}
// get item3 value
j=what.item3.length; //alert(j)
	for (i=0; i<j; i++){
		if(what.item3[i].checked) var item3 = what.item3[i].value
	}
//get item4 value
j=what.item4.length; //alert(j)
	for (i=0; i<j; i++){
		if(what.item4[i].checked) var item4 = what.item4[i].value
	}
//get item5 value
j=what.item5.length; //alert(j)
	for (i=0; i<j; i++){
		if(what.item5[i].checked) var item5 = what.item5[i].value
	}
  pdata(item1,item2,item3,item4,item5,section);
}


function pdata(item1,item2,item3,item4,item5,section){
  var array1=new Array();
  var array2=new Array();
  var div;
  var iselect;
  var model;
  var location=2;
  if (section=='mb'){ 
    iselect = window.document.MB.ITEM;
	model=window.document.MB.model.value;
	array1=arraymb;
	div='div_mb2';
  }
  else if (section=='cpu'){
   iselect = window.document.CPU.ITEM;
   model=window.document.CPU.model.value;
   array1=arraycpu;
   div='div_cpu2';
  }
  else if (section=='mem'){ 
   iselect = window.document.MEM.ITEM;
   model=window.document.MEM.model.value;
   array1=arraymem;
   div='div_mem2';
  }
  var string = "";
  var sstring = "";
  var count=0;
  var iall="ALL"; 
  iselect.options.length = count;
  if(model=='ALL'){
   for(i=0;i<array1.length;i++){ //different
    string=array1[i].split("|"); //different
	sstring=string[0].split(","); 
	k=string[0].split(",").length;
	if(sstring[k-2]=='*')
	if(sstring[1].split(" ")[0]==item1 || item1==iall)
	  if(sstring[3].split(" ")[0]==item2  ||(sstring[3].split(" ")[0]=='SKT775'&&item2=='LGA775'&&section=='mb') || item2==iall)
	     if(sstring[4].split(" ")[0]==item3 || item3==iall)
		     if(sstring[5].split(" ")[0]==item4 || item4==iall)
	            if(sstring[6].split(" ")[0]==item5 || item5==iall){
	                array2[count]= new Array();              //different
					for(j=0;j<=k;j++) array2[count][j]= sstring[j];
					array2[count][k+1]=string[1];
					array2[count][k+2]=string[2];
					iselect.options[count++] = new Option( sstring[0]+' '+sstring[1]+' '+sstring[2]+' '+sstring[3]+' '+sstring[4]+' '+sstring[5]+' '+sstring[6]);
				} 		
   }
  }
  else {
   if(section=='cpu'){ location=1;}
   else { location=2;} 
     for(i=0;i<array1.length;i++){ //different
     string=array1[i].split("|"); //different
	 sstring=string[0].split(","); 
	 k=string[0].split(",").length;
	 if(sstring[k-2]=='*')
	 if(sstring[location]==model ){
	       array2[count]= new Array();              //different
		   for(j=0;j<=k;j++) array2[count][j]= sstring[j];
		   array2[count][k+1]=string[1];
		   array2[count][k+2]=string[2];
	       iselect.options[count++] = new Option( sstring[0]+' '+sstring[1]+' '+sstring[2]+' '+sstring[3]+' '+sstring[4]+' '+sstring[5]+' '+sstring[6]);
	 } 		
    }
  } 	
  if (count==0){ iselect.options[count] = new Option( '*** NO SELECTIONS ***');
                 document.getElementById(div).innerHTML='No Product Found';
  }
  if (count)document.getElementById(div).innerHTML=count+' Products Found : click on dropdown list to see the options' ;
  if (section=='mb') arrayindex_mb=array2;
  else if(section=='cpu') arrayindex_cpu=array2;
  else if(section=='mem') arrayindex_mem=array2;
  

}  
function popup(s){
 if (! window.focus)return true;
 var k=arrayindex[s.selectedIndex].length;
 var http='../info/'+arrayindex[s.selectedIndex][k-2];
 
 window.open(http, arrayindex[s.selectedIndex][k-2], 'width=800,height=600,resizable=yes,scrollbars=yes');
 return false;
}

function iprice(s,s1,section){
  var arrayindex=new Array();
  var section_div
  var section_des
  //var qty=1;
  sprice="";
  ssprice="";
  des="";
  iitem="";
  
  sprice=s.options[s.selectedIndex].text;
  if(section=='mb') { arrayindex=arrayindex_mb;	section_div='div_mb1'; section_des=document.MB; }
  else if(section=='cpu') { arrayindex=arrayindex_cpu; section_div='div_cpu1'; section_des=document.CPU;}	  	  
  else if(section=='mem') { arrayindex=arrayindex_mem; section_div='div_mem1'; section_des=document.MEM;}
  
  if ((sprice=="") || (sprice==null)) sprice="0.00";
  else if ( (sprice.indexOf("(")== -1)||(sprice.indexOf("+")== -1)||(sprice.indexOf(")")== -1) ) sprice="0.00";
  else{
    sprice=sprice.split(")");
    sprice=sprice[0].split("+");
    sprice=sprice[1];
  }
  s1.value=sprice;
  if(sprice=='0.00') {
    section_des.description.value = 'NO SELECTIONS'; 
	document.getElementById(section_div).innerHTML=' <img src="../img1/no_image.jpg" width="100" height="100" border="0">';
  }	
  else {
      //qty=section_des.QTY.options[section_des.QTY.selectedIndex].text;
      //s1.value=sprice*qty;
      for(i=1;i<arrayindex[s.selectedIndex].length-3;i++) des +=' '+arrayindex[s.selectedIndex][i];
      for(i=0;i<arrayindex[s.selectedIndex].length-3;i++) iitem +=' '+arrayindex[s.selectedIndex][i];
	  section_des.description.value = des;
	  var t=arrayindex[s.selectedIndex].length-1;
      var t1='../img1/'+arrayindex[s.selectedIndex][t];
      var t2='../info/'+arrayindex[s.selectedIndex][t-1]; 
      document.getElementById(section_div).innerHTML='<a href="'+t2+'" target="_blank"><img src="'+t1+'" width="100" border="0"><img src="../img1/More_Detail.gif"   border="0" ></a>';
  }	
  
}                                                  //a href="../info/pentiumm.htm"


function initform(){
  var mb=document.order.STEP01_MB;  var cpu=document.order.STEP02_CPU;
  var mem=document.order.STEP03_MEM;  var mb_q=document.order.STEP01_MB_QTY;
  var cpu_q=document.order.STEP02_CPU_QTY;  var mem_q=document.order.STEP03_MEM_QTY;
  var test=document.order.STEP04_TESTED;
  var sub_total, test_fee;
  var total=document.order.TOTAL;
  var mb_price=document.MB.price.value;
  var cpu_price=document.CPU.price.value;
  var mem_price=document.MEM.price.value;
  mb.value='$'+mb_price+' '+document.MB.description.value;
  mb_q.value=document.MB.QTY.options[document.MB.QTY.selectedIndex].text;
  cpu.value='$'+cpu_price+' '+document.CPU.description.value;
  cpu_q.value=document.CPU.QTY.options[document.CPU.QTY.selectedIndex].text;
  mem.value='$'+mem_price+' '+document.MEM.description.value;
  mem_q.value=document.MEM.QTY.options[document.MEM.QTY.selectedIndex].text;
  sub_total=mb_price*mb_q.value+cpu_price*cpu_q.value+mem_price*mem_q.value;
  if(sub_total<300){
  test_fee=sub_total*0.03;
  }
  else if(sub_total<500){
  test_fee=sub_total*0.03;
  }
  else if(sub_total<1000){
  test_fee=sub_total*0.02;
  }
  else {
  test_fee=sub_total*0.02;
  }
  test_fee=Math.round(test_fee);
  if(test_fee>=0) test_fee=0;
  //test.value='$'+test_fee+'  Assembly and Testing Fee ';
  test.value='Free Assembly and Testing';
  // free testing fee
  if((document.MB.model.value!='ALL')&&(document.CPU.model.value!='ALL')&&(document.MEM.model.value!='ALL')){
    //test_fee=sub_total*0.02;
	//test_fee=Math.round(test_fee);
	//test_fee=(-test_fee);
	test_fee=0;
	test.value='$'+test_fee+'  ( Free Assembly & Testing on Recommended MB Bundles )';
  }
  else{
    //test_fee=0;
    test.value='$'+test_fee+' Free Assembly and Testing Fee ';
  }
  sub_total=sub_total+test_fee;
  total.value='$'+sub_total;
  document.order.T.value='(+'+sub_total+')';
  document.order.Submit_Type.disabled= false;
  if(sub_total==0) document.order.Submit_Type.disabled= true;
}

//  End -->
