function show(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility = 'visible';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = 'visible';
  }
  else if (document.all) {
    document.all[object].style.visibility = 'visible';
  }
}

function hide(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility = 'hidden';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = 'hidden';
  }
  else if (document.all) {
    document.all[object].style.visibility = 'hidden';
  }
}


 function handleClick(whichClick) {
    if (whichClick == "hide it") {
        hide('messagelyr');
        checkit();
    }
  }
function message()
{
var a
show('messagelyr');
handleClick(a);

}


//here
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 ='1';
		var spkrstring ='0';
        var descleadtime='2-5 days';
		var bighd=0;
		var user_input = '';
 
// Get value of the 'cpu' radio buttons.

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

    textstring += 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)
		{
			user_input = document.forms[0].lcd[i].value;
		}
	}
  
	textstring += 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)
		{
			user_input = document.forms[0].mem[i].value;
		}
	}
  
	textstring += 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;
		}
	}

	if ((hdd_user_input == "A")||(hdd_user_input == "B")||(hdd_user_input == "C"))
	{
		bighd=1;
	}
	else
	{
		bighd=0;
	}   

	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)
		{
			user_input = document.forms[0].os[i].value;
		}
	}

    textstring += 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)
		{
			user_input = document.forms[0].touch[i].value;
		}
	}
	textstring += user_input;

// Use Standard I/O port, No Spkr
//	user_input="0";

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

// Get value of the 'opt' radio buttons. (Add on 1)

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

// Get value of the 'lpt' radio buttons for parallel port option

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


// NO Add on 2
//    user_input="0";

//	textstring += user_input;

// Logo
//    user_input="1";
//	textstring += user_input;

// Base included
//    user_input="1";

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

//wallmount option
	 for (i=0;i<document.forms[0].mount.length;i++)
	{
		if (document.forms[0].mount[i].selected)
		{
			mount_user_input = document.forms[0].mount[i].value;
		}
	}	

// need to use small hdd if cd rw 
	if ((bighd==1) && (media_user_input!="1"))
	{
		alert('When CD RW is required, please change Storage to use 2.5" HD, and Submit again.');
 	 	document.partno_form.leadtime.value = "";
	 	document.partno_form.output.value = "";
		return;
	}  

//	textstring += base_user_input;
// need to use small hdd if wallmount
	if ((bighd==1) && (mount_user_input=="Z"))
	{
		alert('For Wall or Pole mount, please change Storage to use 2.5" HD, and Submit again.');
 	 	document.partno_form.leadtime.value = "";
	 	document.partno_form.output.value = "";
		return;
	}  

// no CD if wallmount
	if ((media_user_input==4) && (mount_user_input=="Z"))
	{
		alert("Special configuration. Please call PIONEERPOS @ 888-468-9757.");
 	 	document.partno_form.leadtime.value = "";
	 	document.partno_form.output.value = "";
		return;
	}

	if (media_user_input=="4")
	{
		mount_user_input = media_user_input;
		document.partno_form.mount[1].selected = true;
		alert("If CDRW is included, standard Base will be the taller model.")
	}

	document.forms[0].output.value =textstring+"01"+mount_user_input;
	document.forms[0].leadtime.value = " "+descleadtime;
	}

function valid(form){

        var logostring ='1';
		var spkrstring='0'
        var descleadtime='2-5 days';
    	var user_input = '';

		var newwhich=0;
		newwhich=document.partno_form.output.value;
		var count=partno_form.output.value.length;
		
	if (count>12){
  		 alert("Incorrect PartNo");
    	
 	 	document.partno_form.leadtime.value = "";
	 	document.partno_form.output.value = "";
		document.partno_form.output.focus();
     	return false; 
		}
// ARRAY COUNTS TO THE RIGHT
// [0]  [1]  [2]
// [3]  [4]
		
///CPU
   Upwhich= newwhich.toUpperCase();
   cpu_user_input = Upwhich.substring(0,1);

	if ( cpu_user_input=="E"){
       document.partno_form.cpu[0].selected = true;
    }

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

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

//privacy filter	
   if (user_input=="2"){
       document.partno_form.lcd[1].selected = true;
    }
//MEM
  Upwhich= newwhich.toUpperCase();   
  user_input = Upwhich.substring(2,3);

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

//HDD
   Upwhich= newwhich.toUpperCase();   
   user_input = Upwhich.substring(3,4);
	
   if (user_input=="A"){
       document.partno_form.hdd[0].selected = true;
    }
	
   if (user_input=="C"){
       document.partno_form.hdd[1].selected = true;
    }

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


//OS
  Upwhich= newwhich.toUpperCase();          
  user_input = Upwhich.substring(4,5);

   if (user_input=="X"){
       document.partno_form.os[0].selected = true;
    }
	
   if (user_input=="W"){
       document.partno_form.os[1].selected = true;
    }
		
    if (user_input=="P"){
       document.partno_form.os[2].selected = true;
    }
	
   if (user_input=="E"){
       document.partno_form.os[3].selected = true;
    }
	
   if (user_input=="Y"){
       document.partno_form.os[4].selected = true;
    }
   if (user_input=="C"){
       document.partno_form.os[5].selected = true;
    }
		
   if (user_input=="L"){
       document.partno_form.os[6].selected = true;
    }
	
   if (user_input=="0"){
       document.partno_form.os[7].selected = true;
    }


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

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

// I/O
  Upwhich= newwhich.toUpperCase(); 
  user_input = Upwhich.substring(6,7);

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

   if (user_input=="1"){
     document.partno_form.spkr[1].selected = true;
     }

	
//OPT (Add on 1)
  Upwhich= newwhich.toUpperCase();         
  user_input = Upwhich.substring(7,8);

   if (user_input=="0"){
      document.partno_form.opt[0].selected = true;
    }
	
   if (user_input=="5"){
      document.partno_form.opt[1].selected = true;
    }
	
	
// PARALLEL LPT ADD ON
  Upwhich= newwhich.toUpperCase(); 
  user_input = Upwhich.substring(8,9);

   if (user_input=="0"){
      document.partno_form.lpt[0].selected = true;
    }
	
   if (user_input=="E"){
      document.partno_form.lpt[1].selected = true;
    }
	
// ADD ON 2
  Upwhich= newwhich.toUpperCase(); 
  user_input = Upwhich.substring(9,10);

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

// LOGO
  Upwhich= newwhich.toUpperCase(); 
  user_input = Upwhich.substring(10,11);

   if (user_input=="1"){
 //  document.partno_form.lcd[0].checked = true;
     }

// BASE
  Upwhich= newwhich.toUpperCase(); 
  user_input = Upwhich.substring(11,12);

 // standard height
   if (user_input=="1"){
      document.partno_form.media[0].selected = true;
	  
	  //set mounting option = base
      document.partno_form.mount[0].selected = true;
    }

// if CDRW
//   if (user_input=="4"){
//      document.partno_form.media[1].selected = true;
//	  document.partno_form.mount[1].selected = true;
 //   }
	
	//wall mount
   if (user_input=="Z"){
      document.partno_form.mount[1].selected = true;

	  //if wall mount, no CD
      document.partno_form.media[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);
   touchui = Upwhich.substring(5,6);
   ioui = Upwhich.substring(6,7);
   optui = Upwhich.substring(7,8);
   lptui = Upwhich.substring(8,9);
   addonui = Upwhich.substring(9,10);
   logoui = Upwhich.substring(10,11);
   baseui = Upwhich.substring(11,12);
if (Upwhich==""){
checkit();
return true;
}
else if ( (cpuui =="E") &&
			((lcdui =="K")||(lcdui =="2"))&&
			((memui =="5")||(memui =="1")||(memui =="2"))&&
			((hddui =="A")||(hddui =="C")||(hddui =="Q")||(hddui =="5"))&&
			((osui =="E")||(osui =="X")||(osui =="W")||(osui =="P")||(osui =="Y")||(osui =="C")||(osui =="L")||(osui =="0"))&&
			(touchui =="R")&&
			((ioui =="0")||(ioui=="1"))&&
			((optui =="0")||(optui =="5"))&&
			((lptui =="0")||(lptui =="E"))&&
			(addonui == "0")&&
			(logoui =="1")&&
			((baseui =="1")||(baseui=="Z")) )
{
}
 else {
 	alert("Incorrect PartNo");
   	 document.partno_form.leadtime.value = "";
	 	 document.partno_form.output.value = "";
     return false;
    }  
return true;
}//end of function



// -->



