function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function checkit()
{
	    var textstring = '';
        var logostring ='L';
        var descleadtime='2-5 days';
    	var user_input = '';
/*/check 
	for (i=0;i<document.forms[0].cpu.length;i++)
	{

    // Changed checked to selected in line below [TEA] 
		if (document.forms[0].cpu[i].selected)
		{
			cpu_user_input = document.forms[0].cpu[i].value;
     
      // Added concatination string.  Need this for each select [TEA]
      // The variable on the right must must the variable above (cpu_user_input)
      textstring += cpu_user_input;
		}
	}

  
  
         for (i=0;i<document.forms[0].mem.length;i++)
	{
		if (document.forms[0].mem[i].selected)
		{
			mem_user_input = document.forms[0].mem[i].value;
      
      // Added concatination string.  Need this for each select [TEA]
      // The variable on the right must must the variable above (mem_user_input)
      textstring += mem_user_input;

		}
	}
  
  
  */
  
  
  // ********************************************************************************************************************************
  // Start Comment 6/11/06 [TEA]
  // To remove multi-line comment remove the /* above this section
  // ********************************************************************************************************************************

  
  
         for (i=0;i<document.forms[0].hdd.length;i++)
	{
		if (document.forms[0].hdd[i].selected)
		{
			hdd_user_input = document.forms[0].hdd[i].value;
		}
	}

        for (i=0;i<document.forms[0].os.length;i++)
	{
		if (document.forms[0].os[i].selected)
		{
			os_user_input = document.forms[0].os[i].value;
		}
	}
        for (i=0;i<document.forms[0].opt.length;i++)
	{
		if (document.forms[0].opt[i].selected)
		{
			opt_user_input = document.forms[0].opt[i].value;
		}
	}
        for (i=0;i<document.forms[0].touch.length;i++)
	{
		if (document.forms[0].touch[i].selected)
		{
			touch_user_input = document.forms[0].touch[i].value;
		}
	}
        for (i=0;i<document.forms[0].lcd.length;i++)
	{
		if (document.forms[0].lcd[i].selected)
		{
			lcd_input = document.forms[0].lcd[i].value;
		}
	}

	
	
// Get value of the 'cpu' radio buttons.   
	for (i=0;i<document.forms[0].cpu.length;i++)
	{
		if (document.forms[0].cpu[i].selected)
		{
			cpu_user_input = document.forms[0].cpu[i].value;
		}
	}
 
    textstring += cpu_user_input;
       
// Get value of the 'lcd' radio buttons.
 
        for (i=0;i<document.forms[0].lcd.length;i++)
	{
		if (document.forms[0].lcd[i].selected)
		{
			lcd_user_input = document.forms[0].lcd[i].value;
		}
	}
	
	textstring += lcd_user_input;

// Get value of the 'mem' radio buttons.

         for (i=0;i<document.forms[0].mem.length;i++)
	{
		if (document.forms[0].mem[i].selected)
		{
			mem_user_input = document.forms[0].mem[i].value;
		}
	}

	textstring += mem_user_input;

// Get value of the 'hdd' radio buttons.

    for (i=0;i<document.forms[0].hdd.length;i++)
	{
		if (document.forms[0].hdd[i].selected)
		{
			hdd_user_input = document.forms[0].hdd[i].value;
		}
	}
	
	textstring += hdd_user_input;

// Get value of the 'os' radio buttons.

        for (i=0;i<document.forms[0].os.length;i++)
	{
		if (document.forms[0].os[i].selected)
		{
			os_user_input = document.forms[0].os[i].value;
		}
	}

     textstring += os_user_input;

// Get value of the 'opt' radio buttons.
       for (i=0;i<document.forms[0].opt.length;i++)
	   {
		if (document.forms[0].opt[i].selected)
		{
			opt_user_input = document.forms[0].opt[i].value;
		}
	  }
	
        if (opt_user_input=="5")
           {
                logostring='P';
                descleadtime='5-7 days';
           }  
  
        if (opt_user_input=="L")
           {
                logostring='P';
                descleadtime='5-7 days';
           }

        if (opt_user_input=="F")
           {
                logostring='P';
                descleadtime='5-7 days';
           }  
  
        if (opt_user_input=="S")
           {
                logostring='P'; 
                descleadtime='5-7 days';
           }

  
	textstring += opt_user_input;
   

// Get value of the 'touch' radio buttons.
 
        for (i=0;i<document.forms[0].touch.length;i++)
	{
		if (document.forms[0].touch[i].selected)
		{
			touch_user_input = document.forms[0].touch[i].value;
		}
	}
	
  // ********************************************************************************************************************************
  // End Comment [TEA]
  // To remove end multi-line comment remove the * / below this
  // ********************************************************************************************************************************
    
  
  
  
  // You don't need this line below because it's taken care of already in the above code
  // Commented line below [TEA] 
	textstring += touch_user_input;

    document.forms[0].output.value =""+textstring+"3B"+logostring;
    document.forms[0].leadtime.value = " "+descleadtime;
	
}

function valid(form){
	
        var logostring ='L';
        var descleadtime='2-5 days';
    	var user_input = '';

		var newwhich=0;
		newwhich=replace(document.partno_form.output.value,' ','');
        var count=partno_form.output.value.length;

		if (count>10){
 			alert("Incorrect PartNo");
  	 	 	document.partno_form.leadtime.value = "";
		 	document.partno_form.output.value = "";
			document.partno_form.output.focus();
     	return false; 
		}

//CPU
   Upwhich= newwhich.toUpperCase();
   user_input = Upwhich.substring(0,1);

/*    if (user_input=="G"){
      document.partno_form.cpu[0].checked = true;
    }
*/	
 	if ( user_input=="K"){
      document.partno_form.cpu[0].selected = true;
    }
		
   if ( user_input=="M"){
     document.partno_form.cpu[1].selected = true;
    }

//LCD 
  Upwhich= newwhich.toUpperCase(); 
  user_input = Upwhich.substring(1,2);

   if (user_input=="C"){
     document.partno_form.lcd[0].selected = true;
    }

//Gee 5/21/07 : only offers 12" TFT dual bulb	
//   if (user_input=="2"){
//    document.partno_form.lcd[1].selected = true;
//    }
	
//   if (user_input=="3"){
//     document.partno_form.lcd[2].selected = true;
//    }

//MEM
  Upwhich= newwhich.toUpperCase();   
  user_input = Upwhich.substring(2,3);

   if (user_input=="8"){
      document.partno_form.mem[0].selected = true;
    }
	
   if (user_input=="6"){
   document.partno_form.mem[1].selected = true;
    }
		
   if (user_input=="5"){
   document.partno_form.mem[2].selected = true;
    }


//HDD
   Upwhich= newwhich.toUpperCase();   
   user_input = Upwhich.substring(3,4);

   if (user_input=="C"){
      document.partno_form.hdd[0].selected = true;
    }
	
   if (user_input=="E"){
     document.partno_form.hdd[1].selected = true; 
    }

   if (user_input=="0"){
     document.partno_form.hdd[2].selected = true;
    }


//OS
  Upwhich= newwhich.toUpperCase();          
  user_input = Upwhich.substring(4,5);
  
   if (user_input=="0"){
     document.partno_form.os[0].selected = true;
    }
	
   if (user_input=="X"){
     document.partno_form.os[1].selected = true; 
    }
	
    if (user_input=="W"){
     document.partno_form.os[2].selected = true;
    }
	
	if (user_input=="2"){
     document.partno_form.os[3].selected = true; 
    }
	

 
//OPT
  Upwhich= newwhich.toUpperCase();         
  user_input = Upwhich.substring(5,6);

   if (user_input=="0"){
     document.partno_form.opt[0].selected = true;
    }
	
   if (user_input=="L"){
     document.partno_form.opt[1].selected = true; 
    }
	
   if (user_input=="5"){
     document.partno_form.opt[2].selected = true;
    }
	
   if (user_input=="F"){
     document.partno_form.opt[3].selected = true;
    }

  if (user_input=="S"){
     document.partno_form.opt[4].selected = true;
    }
	
//Touch
	Upwhich= newwhich.toUpperCase();         
	user_input = Upwhich.substring(6,7);

   if (user_input=="R"){
     document.partno_form.touch[0].selected = true;
    }


//check if correct part no or not

   cpuui = Upwhich.substring(0,1);
   lcdui = Upwhich.substring(1,2);
   memui = Upwhich.substring(2,3);
   hddui = Upwhich.substring(3,4);
   osui = Upwhich.substring(4,5);
   optui = Upwhich.substring(5,6);
   touchui = Upwhich.substring(6,7);
   pwrui = Upwhich.substring(7,9);
   logoui = Upwhich.substring(9,10);

if (Upwhich==""){
checkit();
return true;
}

else if (((cpuui =="K")||(cpuui =="M"))&&
		((lcdui =="C"))&&
		((memui =="8")||(memui =="5")||(memui =="6"))&&
		((hddui =="C")||(hddui =="0")||(hddui =="E"))&&
		((osui =="W")||(osui =="X")||(osui =="0")||(osui =="2"))&&
		(((optui=="0")&&(logoui=="L"))||((optui =="5")&&(logoui=="P"))||((optui =="L")&&(logoui=="P"))||((optui =="F")&&(logoui=="P"))||((optui =="S")&&(logoui=="P")))&&
		(touchui=="R")&&(pwrui=="3B")&&((logoui=="L")||(logoui=="P")))
		{
		}
else{    alert("Incorrect PartNo");
    	
 	 	document.partno_form.leadtime.value = "";
	 	document.partno_form.output.value = "";
		document.partno_form.output.focus();
     	return false;   
  	   
	   }//end of else

}//end of function