var http_request = false;
var selectArr=new Array();
var levelPriceArr=new Array();
var trgObj=null;
var prod_ok=false;
var country_code=null;
var part_desc='';
var search_str='';
var part_num='';
var part_name='';
var level_price='';
var vol_price='';
var item_count=1;
var endUserOK=false;
var inititem=0;
var onetimeOk=true;
var productOk=false;
var valueUnitOK=false;
var user_part_desc='';
var delete_items='';
var value_unit_str='value unit';
var levelPriceOk=false;
var part_group_desc='';
var pro_url='';
var pro_postStr1='';
var pro_postStr2='';
var special_char=new Array();
var vitem_index_arr=new Array();
var vitem_index=0;
var selectChkObj;
var sr_vendor;
var sr_brand;
var lineItemOk=false;
var editLineItem=false;
var entireQuoteOK=false;
var edit_index='';
var sleepTime=2000;
special_char["®"]="(R)";
special_char["™"]="(TM)";
special_char["&"]="(AD)";
function makeRequest(url,str) {
	http_request = false;
	if (window.XMLHttpRequest)
	{ // Mozilla, Safari,...
   	http_request = new XMLHttpRequest();
   	if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
       // See note below about this line
   	}
	} 	
	else if (window.ActiveXObject)
	{ // IE
   	try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			 } 
			 catch (e)
			{
       		try {
           			http_request = new ActiveXObject("Microsoft.XMLHTTP");
       			 } catch (e) {}
   		}
			}

	if (!http_request) {
   	alert('Giving up :( Cannot create an XMLHTTP instance');
   	return false;
	}

	http_request.onreadystatechange = showContents;
	http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); 
	http_request.send(str);
}

function showContents() {
	if (http_request.readyState == 4 && http_request.status == 200){
		eval(http_request.responseText);
		if (endUserOK)
		{
	        if (selectArr.length>1)
                document.getElementById("passport#").style.display="";
	        else
                document.getElementById("passport#").style.display="none";
	        endUserOK=false;
		}
		if (selectArr!=null && trgObj!=null){
		
		 loadCombo();
		}
		
		if (valueUnitOK)
			loadProccerDetails();
		
		if (productOk)
		{   
	        var tableObj=document.getElementById('prod_detail_tab');
			  search_str='';
			  if (part_desc!='')
			  	search_str=part_desc;
			
			  if (search_str=='' && user_part_desc!='')
					search_str=user_part_desc;
			  else if (search_str=='' && part_group_desc!='')
			  		search_str=part_group_desc;
			  
			  if (document.getElementById('entireQuoteOK') && document.getElementById('entireQuoteOK').value!='')
			  {
			  	entireQuoteOK=true;
				
			  }	
			  if ( search_str!='' && search_str!=null)
			  { 		
			  		search_str=search_str.toLowerCase();
				 
				  	if (search_str.match(value_unit_str) || search_str.match(value_unit_str))
				  	{
						if (!entireQuoteOK)
							getValueUnits();
						else
						{
							
							lineItemOk=true;
							insertProduct(tableObj);
							
							//insertValueUnits(tableObj);
							
						}
						productOk=false;
						search_str='';
						return;
				  	}
			  }
			  insertProduct(tableObj);
	        search_str='';
			  productOk=false;
			
		}
		if (levelPriceOk)
		{
			changeLevelPrice();
			levelPriceOk=false;
		}
		

	}
} 


function loadProccerDetails()
{
	tabObj=document.getElementById('proc_detail_tab');
	if (ie4 && tabObj.tBodies[0])
	{
		obj=tabObj.tBodies[0].all;
		for(i=obj.length-1;i>=0;i--)
			delElem(obj[i]);
	}
	else
		tabObj.innerHTML='';
		
	for(var i=0;i<selectArr.length;i++)
	{
		var trrow=document.createElement("tr");	
		trrow.setAttribute("valign","top");
		trrow.className="normal";
		trrow.bgColor="#F2F2F2";
		for(j=1;j<=6;j++)
		{
			var tdcell= document.createElement("td");
			tdcell.setAttribute("width","100px");
			tdcell.setAttribute("align","center");
			if (j==5)
			{
				tdcell.innerHTML='<input type="text"  maxlength="5" class="normal" id="_'+i+'_'+j+'" style="width:96px" onkeyup="javascript:validateInputNumber(this,5,\'integer\');" onkeydown="javascript:validateInputNumber(this,5,\'integer\');" autocomplete="off" value="'+convertCharTOSymbol(selectArr[i][j])+'">';
			}else if (j!=6)
				tdcell.innerHTML='<input type="text"  class="normal" id="_'+i+'_'+j+'" style="width:96px" value="'+convertCharTOSymbol(selectArr[i][j])+'">';
			else
				tdcell.innerHTML='<input type="checkbox"  value="'+i+'" name="someCheckBox['+i+']"  id="someCheckBox['+i+']" onclick="selectallelm(this);">';
			trrow.appendChild(tdcell);
		}
		
		if (ie4 && tabObj.tBodies[0])
			tabObj.tBodies[0].appendChild(trrow);
		else
			tabObj.appendChild(trrow);
	}
	valueUnitOK=false;
	selectArr=null;
}

function delElem(elemToDel)
{
	if(!elemToDel)return;
		elemToDel.parentNode.removeChild(elemToDel);
}

function clearElem(elemToDel)
{
	tdElements = elemToDel.childNodes;
	
	for(var i=0;i<tdElements.length;i++)
	{
		tdElements[i].innerText='';
		elemToDel.removeChild(tdElements[i]);
	}	
}

function getValueUnits()
{
	holdForProcessing();
	showValueUnitsTable(true);
	releaseAfterProcessing();
}

function insertLineItem()
{
	var tableObj=document.getElementById('prod_detail_tab');
	var frm =document.getElementById('procValUnitsFrm');
	var vendObj=document.getElementById('svrVendNeed');
	var brandObj=document.getElementById('svrBrandNeed');
	var chkObj=document.getElementById('someCheckBox[0]');
	var qtyObj=document.getElementById('procCoreQty');
	var tbObj=document.getElementById('prod_detail_tab');
	if (vendObj.value==0 || vendObj.value=='')
	{
		alert("Please select the Vendor Needed.");
		vendObj.focus();
		return false;
	}
	if (brandObj.value==0 || brandObj.value=='')
	{
		alert("Please select the Brand Needed.");
		brandObj.focus();
		return false;
	}
	if (!selectChkObj || selectChkObj==null)
	{
	 	alert("Please select the appropriate Architecture, Processor Brand  and Type Needed.");
	 	chkObj.checked=true;
		selectChkObj=chkObj;
		return false;
	}
	
	if (qtyObj.value=='' || qtyObj.value==0)
	{
		alert("Please insert valid Processor Core Quantity.");
		qtyObj.focus();
		return false;
	}
	
	//document.getElementById('svrVendNeed').options[1].selected=true;
	//unitApp=document.getElementById('valUnitApp');
	if (frm.valUnitApp[0].checked)
	{  
		//if (document.getElementById('entire_index').value>0)
		//deleteItem(document.getElementById('entire_index').value);
		deleteExistingValueItem();
		if (!ie4)
		{
			document.getElementById('sr_td_vendor').innerHTML='';
			var txtcel1=document.createTextNode(sr_vendor);
			document.getElementById('sr_td_vendor').appendChild(txtcel1);
		}
		else
			document.getElementById('sr_td_vendor').innerText=sr_vendor;
					
		document.getElementById('SR_VENDOR').value=sr_vendor;
		
		
		if (!ie4)
		{
			document.getElementById('sr_td_brand').innerHTML='';
			var txtcel1=document.createTextNode(sr_brand);
			document.getElementById('sr_td_brand').appendChild(txtcel1);
		}
		else
			document.getElementById('sr_td_brand').innerText=sr_brand;
				
		document.getElementById('SR_BRAND').value=sr_brand;
		
		
		if (!ie4)
		{
			document.getElementById('pr_td_vendor').innerHTML='';
			var txtcel1=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_1").value);
			document.getElementById('pr_td_vendor').appendChild(txtcel1);
		}
		else
			document.getElementById('pr_td_vendor').innerText=document.getElementById("_"+selectChkObj.value+"_1").value;	
		
		document.getElementById('PR_VENDOR').value=document.getElementById("_"+selectChkObj.value+"_1").value;
		
		
		if (!ie4)
		{
			document.getElementById('pr_td_architecture').innerHTML='';
			var txtcel1=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_2").value);
			document.getElementById('pr_td_architecture').appendChild(txtcel1);
		
		}
		else
			document.getElementById('pr_td_architecture').innerText=document.getElementById("_"+selectChkObj.value+"_2").value;
				
		document.getElementById('PR_ARCHITECTURE').value=document.getElementById("_"+selectChkObj.value+"_2").value;
		
		if (!ie4)
		{
			document.getElementById('pr_td_brand').innerHTML='';
			var txtcel1=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_3").value);
			document.getElementById('pr_td_brand').appendChild(txtcel1);
		}
		else
			document.getElementById('pr_td_brand').innerText=document.getElementById("_"+selectChkObj.value+"_3").value;
				
			document.getElementById('PR_BRAND').value=document.getElementById("_"+selectChkObj.value+"_3").value;
		
		if (!ie4)
		{
			document.getElementById('pr_td_type').innerHTML='';
			var txtcel1=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_4").value);
			document.getElementById('pr_td_type').appendChild(txtcel1);
		}
		else
			document.getElementById('pr_td_type').innerText=document.getElementById("_"+selectChkObj.value+"_4").value;
				
		
		document.getElementById('PR_TYPE').value=document.getElementById("_"+selectChkObj.value+"_4").value;
		
		
		if (!ie4)
		{
			document.getElementById('td_value_units_core').innerHTML='';
			var txtcel1=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_5").value);
			document.getElementById('td_value_units_core').appendChild(txtcel1);
		}
		else
			document.getElementById('td_value_units_core').innerText=document.getElementById("_"+selectChkObj.value+"_5").value;	
		document.getElementById('VALUE_UNITS_CORE').value=document.getElementById("_"+selectChkObj.value+"_5").value;
		
		if (!ie4)
		{
			document.getElementById('pr_td_core_qty').innerHTML='';
			var txtcel1=document.createTextNode(document.getElementById("procCoreQty").value);
			document.getElementById('pr_td_core_qty').appendChild(txtcel1);
		}
		else
			document.getElementById('pr_td_core_qty').innerText=document.getElementById("procCoreQty").value;
					
		document.getElementById('PR_CORE_QTY').value=document.getElementById("procCoreQty").value;
		
		
		if (!ie4)
		{
			document.getElementById('pr_td_total_price').innerHTML='';
			var txtcel1=document.createTextNode(document.getElementById("procCoreQty").value*document.getElementById("_"+selectChkObj.value+"_5").value);
			document.getElementById('pr_td_total_price').appendChild(txtcel1);
		
		}
		else
			document.getElementById('pr_td_total_price').innerText=document.getElementById("procCoreQty").value*document.getElementById("_"+selectChkObj.value+"_5").value;
				
		document.getElementById('PR_TOTAL_PRICE').value=document.getElementById("procCoreQty").value*document.getElementById("_"+selectChkObj.value+"_5").value;
		
		
		document.getElementById('entire_index').value='YES';
		document.getElementById('entire_row').style.display='';
		document.getElementById('value_units_cell').style.height='140px';
		document.getElementById('part_num').focus();
		lineItemOk=true;
		entireQuoteOK=true;
		if (editLineItem)
		{
			frm.valUnitApp[0].disabled=false;
			frm.valUnitApp[1].disabled=false;
			editLineItem=false;
			lineItemOk=false;
		}
		else
		{
			insertProduct(tbObj);
			//insertValueUnits(tbObj);
		}	
		frm.valUnitApp[0].checked=false;
		//showValueUnitsTable(false);
	}
	else if (frm.valUnitApp[1].checked )
	{
		
		lineItemOk=true;
		if (editLineItem)
		{
			frm.valUnitApp[0].disabled=false;
			frm.valUnitApp[1].disabled=false;
			editValueUnits(edit_index);
			editLineItem=false;
		}
		else
		{
			insertProduct(tbObj);
			insertValueUnits(tbObj);
		}	
		frm.valUnitApp[1].checked=false;
	}
	else 
	{
		alert("Please select the Value Unit Application.");
	 	frm.valUnitApp[0].checked=true;
		return false;
	}	
	
	tabObj=document.getElementById('proc_detail_tab');
	if (ie4 && tabObj.tBodies[0])
	{
		obj=tabObj.tBodies[0].all;
		for(i=obj.length-1;i>=0;i--)
			delElem(obj[i]);
	}
	else
		tabObj.innerHTML='';
	showValueUnitsTable(false);
	productOk=false;
	return true;
}

function deleteExistingValueItem()
{
	
	if (document.getElementById('vitem_index') && document.getElementById('vitem_index').value!='')
	{
		vitem_index_arr=document.getElementById('vitem_index').value.split("|");
	 	document.getElementById('vitem_index').value=""; 
	}
	var len=vitem_index_arr.length;
	if (len==0)	return;
	for(var i=0;i<len;i++)
	{
		
		//editValueUnits(vitem_index_arr[i]);
		
		//document.getElementById("TR_UN_"+vitem_index_arr[i]+"_0").style.display='none';
		
		document.getElementById("TR_UN_"+vitem_index_arr[i]+"_1").innerText='';
		document.getElementById("TR_UN_"+vitem_index_arr[i]+"_2").innerText='';
		document.getElementById("TR_UN_"+vitem_index_arr[i]+"_3").innerText='';
		//document.getElementById("TR_UN_"+vitem_index_arr[i]+"_4").innerText='';
		document.getElementById("TR_UN_"+vitem_index_arr[i]+"_0").style.display='none';
		document.getElementById("TR_UN_"+vitem_index_arr[i]+"_1").style.display='none';
		document.getElementById("TR_UN_"+vitem_index_arr[i]+"_2").style.display='none';
		document.getElementById("TR_UN_"+vitem_index_arr[i]+"_3").style.display='none';
		//document.getElementById("TR_UN_"+vitem_index_arr[i]+"_4").style.display='none';
		document.getElementById("TR_UN_"+vitem_index_arr[i]+"_0").innerText='';
	}
}

function editValueUnits(edit_index)
{
	tableObj=document.getElementById('prod_detail_tab');
	var trrow1=document.getElementById("TR_UN_"+edit_index+"_1");
	var trrow2=document.getElementById("TR_UN_"+edit_index+"_2");
	var trrow3=document.getElementById("TR_UN_"+edit_index+"_3");
	//alert(trrow1);
	if (ie4 && tabObj.tBodies[0])
	{
		trrow1.innerText='';
		trrow2.innerText='';
		trrow3.innerText='';
	}
	else
	{
		trrow1.innerHTML='';
		trrow2.innerHTML='';
		trrow3.innerHTML='';
	}
	var tdcell= document.createElement("td");
	tdcell.setAttribute('width', '100px');
	trrow1.appendChild(tdcell);
	
	var tdcell11= document.createElement("td");
	var txtcel111=document.createTextNode("Server Vendor:");
	tdcell11.appendChild(txtcel111);
	trrow1.appendChild(tdcell11);
	
	var tdcell12= document.createElement("td");
	var txtcell12=document.createTextNode(sr_vendor);
	tdcell12.appendChild(txtcell12);
	trrow1.appendChild(tdcell12);
	document.getElementById('SR_VENDOR_'+edit_index).value=sr_vendor;
	
	var tdcell13= document.createElement("td");
	var txtcel113=document.createTextNode("Server Brand: ");
	tdcell13.appendChild(txtcel113);
	trrow1.appendChild(tdcell13);
	
	var tdcell14= document.createElement("td");
	var txtcell14=document.createTextNode(sr_brand);
	tdcell14.appendChild(txtcell14);
	trrow1.appendChild(tdcell14);
	document.getElementById('SR_BRAND_'+edit_index).value=sr_brand;
	
	var tdcell15= document.createElement("td");
	var txtcel115=document.createTextNode("Processor Vendor: ");
	tdcell15.appendChild(txtcel115);
	trrow1.appendChild(tdcell15);
	
	var tdcell16= document.createElement("td");
	var txtcell16=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_1").value);
	tdcell16.appendChild(txtcell16);
	trrow1.appendChild(tdcell16);
	document.getElementById('PR_VENDOR_'+edit_index).value=document.getElementById("_"+selectChkObj.value+"_1").value;
	
	var tdcell= document.createElement("td");
	tdcell.setAttribute('width', '100px');
	trrow2.appendChild(tdcell);
	
	var tdcell17= document.createElement("td");
	var txtcel117=document.createTextNode("Processor Architecture:");
	tdcell17.appendChild(txtcel117);
	trrow2.appendChild(tdcell17);
	
	
	
	var tdcell18= document.createElement("td");
	var txtcell18=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_2").value);
	tdcell18.appendChild(txtcell18);
	trrow2.appendChild(tdcell18);
	document.getElementById('PR_ARCHITECTURE_'+edit_index).value=document.getElementById("_"+selectChkObj.value+"_2").value;
	
	var tdcell19= document.createElement("td");
	var txtcel119=document.createTextNode("Processor Brand: ");
	tdcell19.appendChild(txtcel119);
	trrow2.appendChild(tdcell19);
	
	var tdcell10= document.createElement("td");
	var txtcell10=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_3").value);
	tdcell10.appendChild(txtcell10);
	trrow2.appendChild(tdcell10);
	document.getElementById('PR_BRAND_'+edit_index).value=document.getElementById("_"+selectChkObj.value+"_3").value;
		
	var tdcell11= document.createElement("td");
	var txtcel111=document.createTextNode("Processor Type: ");
	tdcell11.appendChild(txtcel111);
	trrow2.appendChild(tdcell11);
	
	var tdcell12= document.createElement("td");
	var txtcell12=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_4").value);
	tdcell12.appendChild(txtcell12);
	trrow2.appendChild(tdcell12);
	document.getElementById('PR_TYPE_'+edit_index).value=document.getElementById("_"+selectChkObj.value+"_4").value;
			
	var tdcell= document.createElement("td");
	tdcell.setAttribute('width', '100px');
	trrow3.appendChild(tdcell);
	
	var tdcell13= document.createElement("td");
	var txtcel113=document.createTextNode("Value Units: ");
	tdcell13.appendChild(txtcel113);
	trrow3.appendChild(tdcell13);
	
	var tdcell14= document.createElement("td");
	var txtcell14=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_5").value);
	tdcell14.appendChild(txtcell14);
	trrow3.appendChild(tdcell14);
	document.getElementById('VALUE_UNITS_CORE_'+edit_index).value=document.getElementById("_"+selectChkObj.value+"_5").value;
		
	var tdcell17= document.createElement("td");
	var txtcel117=document.createTextNode("Processor Core Qty: ");
	tdcell17.appendChild(txtcel117);
	trrow3.appendChild(tdcell17);
	
	var tdcell18= document.createElement("td");
	var txtcell18=document.createTextNode(document.getElementById("procCoreQty").value);
	tdcell18.appendChild(txtcell18);
	trrow3.appendChild(tdcell18);	
	document.getElementById('PR_CORE_QTY_'+edit_index).value=document.getElementById("procCoreQty").value;
			
	var tdcell19= document.createElement("td");
	var txtcel119=document.createTextNode("Total: ");
	tdcell19.appendChild(txtcel119);
	trrow3.appendChild(tdcell19);
	
	var tdcell20= document.createElement("td");
	var txtcell20=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_5").value*document.getElementById("procCoreQty").value);
	tdcell20.appendChild(txtcell20);
	trrow3.appendChild(tdcell20);
	document.getElementById('PR_TOTAL_PRICE_'+edit_index).value=document.getElementById("_"+selectChkObj.value+"_5").value*document.getElementById("procCoreQty").value;
	edit_index='';
	lineItemOk=false;
	
}

function showValueUnitsTable(action,item_index)
{
	
	if(action)
	{
		
		setValueUnitsWindowPosition();
		showHideSelectControls('hide');
		if (!item_index)
			document.getElementById('svrBrandNeed').disabled=true;
		
		document.getElementById('showValueUnits').style.visibility='visible';
		return true;
	}
	else
	{
		tabObj=document.getElementById('proc_detail_tab');
		if (ie4 && tabObj.tBodies[0])
		{
			obj=tabObj.tBodies[0].all;
			for(i=obj.length-1;i>=0;i--)
				delElem(obj[i]);
		}
		else
			document.getElementById('proc_detail_tab').innerHTML='';
			
		
		var opt1=document.createElement('OPTION');
		var opt2=document.createElement('OPTION');
		opt1.value='';
		opt1.text='';
		document.getElementById('svrBrandNeed').options[0]=opt1;
		opt2.value='0';
		opt2.text='Select Brand...';
		document.getElementById('svrBrandNeed').options[1]=opt2;
		document.getElementById('svrVendNeed').options[1].selected=true;
		document.getElementById('svrBrandNeed').options[1].selected=true;
		var frm =document.getElementById('procValUnitsFrm');
		frm.valUnitApp[0].disabled=false;
		frm.valUnitApp[1].disabled=false;
		frm.valUnitApp[0].checked=false;
		frm.valUnitApp[1].checked=false;
		document.getElementById('procCoreQty').value='';
		showHideSelectControls('show');
		document.getElementById('showValueUnits').style.visibility='hidden';
		part_desc='';
		part_num='';
		part_name=null;
		part_no=null;
		vol_price=null;
		level_price=null;
		selectChkObj=null;
		user_part_desc='';
		part_group_desc='';
		search_str='';
		document.getElementById('prod_name').selectedIndex=-1;
	}
}

function showHideSelectControls(action) 
{
	var width = 580;
	var height = 525;//300
	var preObj=document.getElementById("showValueUnits");
	if (ie4)
	{
		var y = document.body.scrollTop+(document.body.clientHeight-height)/2;
		var x = document.body.scrollLeft+(document.body.clientWidth-width)/2;
	}else if (ns6||ns4){
		var y =window.pageYOffset+(window.innerHeight-height)/2;
		var x =window.pageXOffset+(window.innerWidth-width)/2;
	}
	
	var right = x+width-1; 
	var bottom = y+height-1; 
	var selectControls=document.getElementsByTagName("SELECT"); 
	for (var i=0; i<selectControls.length; i++){ 
		if (action=='hide'){
			var sx=selectControls[i].offsetLeft; 
			var sy=selectControls[i].offsetTop; 
			if(selectControls[i].offsetParent){
				var parent=selectControls[i].offsetParent; 
 				do { 
   					sx += parent.offsetLeft; 
   					sy += parent.offsetTop; 
 				} while ( parent = parent.offsetParent ); 
			}
		
		var sRight=selectControls[i].offsetWidth;
 		var sBottom=selectControls[i].offsetHeight;
		if(  (((x <= sx && sx <= right) || (x <= (sx+sRight) && (sx+sRight) <= right)) && ((y <= sy && sy <= bottom) || (y <= (sy+sBottom) && (sy+sBottom) <= bottom)))  && (selectControls[i].name != 'svrVendNeed' && selectControls[i].name != 'svrBrandNeed'))
			selectControls[i].style.visibility='hidden'; 
		else 
			selectControls[i].style.visibility='visible'; 
		} else if(action=='show')
			if(selectControls[i].name != 'svrVendNeed' && selectControls[i].name != 'svrBrandNeed') 
				selectControls[i].style.visibility='visible'; 
			else
			   selectControls[i].style.visibility='hidden'; 
	}
}
				
function selectallelm (elm){
	var i,m;
	var Inputs = document.getElementsByTagName("input");
	m=Inputs.length;
	//m=frm.length;
	for(i=0; i<m; i++) {
		if(Inputs[i].type=='checkbox'){
			if (Inputs[i].id==elm.id){
							selectChkObj=Inputs[i];
							Inputs[i].checked=true;
					}
			else if (Inputs[i].id!='ADD_YEAR_MAINT') {
				Inputs[i].checked=false;
			}
		}
	}
}



function holdForProcessing()
{
	var Inputs = document.getElementsByTagName("input");
	for(var j=0; j<Inputs.length; j++)
	if (Inputs[j].type.toLowerCase()=="submit" || Inputs[j].type.toLowerCase()=="button" )
		Inputs[j].disabled=true;
}

function releaseAfterProcessing()
{
	var Inputs = document.getElementsByTagName("input");
	for(var j=0; j<Inputs.length; j++)
	if (Inputs[j].type.toLowerCase()=="submit" || Inputs[j].type.toLowerCase()=="button" )
		Inputs[j].disabled=false;
}

function setValueUnitsWindowPosition()
{
	var preObj=document.getElementById("showValueUnits");
	if (ie4)
	{
		preObj.style.top= document.body.scrollTop+(document.body.clientHeight-300)/2;
		preObj.style.left= document.body.scrollLeft+(document.body.clientWidth-580)/2;
		preObj.style.width='580px';
	}
	else if (ns6||ns4) 
	{
		preObj.style.top=window.pageYOffset+(window.innerHeight-300)/2;
		preObj.style.left=window.pageXOffset+(window.innerWidth-580)/2;
		preObj.style.width='580px';
	}
}

function passProcessorRequest(url,postStr,srcObj,targetObjName)
{
	var src_value;
	var frm =document.getElementById('procValUnitsFrm');
	
	trgObj = document.getElementById(targetObjName);
	
	src_value=convertSymbolTOChar(srcObj.value);
	if (!editLineItem)
	{
		frm.valUnitApp[0].checked=false;
		frm.valUnitApp[1].checked=false;
	}
	
	//document.getElementById('procCoreQty').value='';
	if (selectChkObj!=null)
	{
		selectChkObj.checked=false;
		selectChkObj=null;
	}
	if (srcObj.id=='svrVendNeed')
	{	document.getElementById('svrBrandNeed').disabled=false;
		if (srcObj.value==0 || srcObj.value=='')
			document.getElementById('svrBrandNeed').innerHTML='';
	}
	if (srcObj.id=='svrVendNeed' || srcObj.value=='')
	{
		
		tabObj=document.getElementById('proc_detail_tab');
		if (ie4 && tabObj.tBodies[0])
		{
			obj=tabObj.tBodies[0].all;
			for(i=obj.length-1;i>=0;i--)
				delElem(obj[i]);
		}
		else
			tabObj.innerHTML='';
	}
	
	
	
	if (!targetObjName)
	{
		pro_postStr2=postStr;
		pro_url=url;
		sr_brand=srcObj.value;
		sr_vendor=document.getElementById('svrVendNeed').value;
		postStr+="&sr_brand="+src_value;
		postStr+="&sr_vendor="+convertSymbolTOChar(sr_vendor);
		
	}
	else
	{
		
		pro_postStr1=postStr;
		postStr+="&src_value="+src_value;
		
		
	}
	makeRequest(url,postStr);
}

function convertSymbolTOChar(src_value)
{
	for (var i in special_char)
		if (src_value.match(i))
  			src_value=src_value.replace(i,special_char[i]);	
   src_value=src_value.replace("++","(PL)(PL)");
	src_value=src_value.replace("+","(PL)");
	return src_value;
}

function convertCharTOSymbol(src_value)
{
	for (var i in special_char)
		if (src_value.match(special_char[i]))
  			src_value=src_value.replace(special_char[i],i);	
   return src_value;
}

function passProdRequest(url,postStr,srcObj,targetObjName)
{
	
	trgObj = document.getElementById(targetObjName);
	postStr+="&src_value="+convertSymbolTOChar(srcObj.value);
	if (onetimeOk && document.getElementById('item_count') && document.getElementById('item_count').value>0)
	{
			inititem=document.getElementById('item_count').value;
			//item_count=parseInt(inititem)+1;
			onetimeOk=false;
			
	}
	
	if (country_code==null && document.getElementById('country_code') && document.getElementById('country_code').value!='')
	{
		country_code=document.getElementById('country_code').value;
	}
	if (srcObj.id=='eu_name')
	{
		endUserOK=true;
	}
	else if (srcObj.id=='soft_brand')
	{
		
		document.getElementById('part_type').innerHTML='';
		document.getElementById('part_type').disabled=true;
		document.getElementById('prod_name').selectedIndex=-1;
		document.getElementById('prod_name').disabled=true;
		if (document.getElementById('soft_brand').value=='' || 
				document.getElementById('soft_brand').value=='Select Pillar...')
		{
			 document.getElementById('prod_trade').innerHTML='';
			 document.getElementById('prod_name').innerHTML='';
			 document.getElementById('prod_name').disabled=true;
			 document.getElementById('prod_trade').disabled=true;
			 return;
		}	 
		
		
	}
	else if (srcObj.id=='prod_trade')
	{
		
		
		document.getElementById('prod_name').selectedIndex=-1;
		document.getElementById('prod_name').disabled=true;
		if (document.getElementById('prod_trade').value=='' || 
				document.getElementById('soft_brand').value=='Select Pillar...')
		{
			document.getElementById('part_type').innerHTML='';
			document.getElementById('part_type').disabled=true;
			return;
		}	
		
		postStr+="&SW_BRAND="+convertSymbolTOChar(document.getElementById('soft_brand').value); 
	}
	else if (srcObj.id=='part_type')
	//Start Changed by TDSL October 09, 2006
	//PPADV Value Unit Items for Quote Requests
	{
		
		if (document.getElementById('part_type').value=='' || 
				document.getElementById('soft_brand').value=='Select Pillar...')
		{
			document.getElementById('prod_name').innerHTML='';
			document.getElementById('prod_name').disabled=true;
			return;
		}	 
		postStr+="&SW_BRAND="+convertSymbolTOChar(document.getElementById('soft_brand').value);
		postStr+="&PRODUCT_TD_NAME="+convertSymbolTOChar(document.getElementById('prod_trade').value);
	}
	
	if (country_code)
	{
		postStr+="&country_code="+country_code;
	}
	makeRequest(url,postStr);
	
	
}

function getPartNumbers(url,postStr,obj)
{
	
	var count=document.getElementById('item_count').value;
	if (!country_code)
		country_code=document.getElementById('country_code').value;
	if (country_code!='')
		postStr+="&country_code="+country_code;
	postStr+="&user_level="+obj.value;
	if (count>0)
	{ 
	   for(var i=1;i<=count;i++)
		{
			if (document.getElementById('PART_NUM_'+i) && document.getElementById('PART_NUM_'+i).value!='')
				postStr+="&PART_NUM_"+i+"="+document.getElementById('PART_NUM_'+i).value;
			if (document.getElementById('CURRENCY_CODE_'+i) && document.getElementById('CURRENCY_CODE_'+i).value!='')
				postStr+="&CURRENCY_CODE_"+i+"="+document.getElementById('CURRENCY_CODE_'+i).value;
		}
		levelPriceOk=true;
		makeRequest(url,postStr);
	}
	
}

function changeLevelPrice()
{
	var count=document.getElementById('item_count').value;
	for(var i=1;i<=count;i++)
	{
		for (var j=0;j<levelPriceArr.length;j++)
		{
			if (document.getElementById('PART_NUM_'+i) && 
					document.getElementById('CURRENCY_CODE_'+i) &&
					levelPriceArr[j]['PART_NUM'] &&
					levelPriceArr[j]['ISO_CURRENCY_CODE'] &&
					document.getElementById('PART_NUM_'+i).value==levelPriceArr[j]['PART_NUM'] &&
					document.getElementById('CURRENCY_CODE_'+i).value==levelPriceArr[j]['ISO_CURRENCY_CODE'])
					
					
		   {
				document.getElementById('LEVEL_PRICE_'+i).value=levelPriceArr[j]['LEVEL_PRICE'];
				document.getElementById('level_'+i).innerHTML=levelPriceArr[j]['LEVEL_PRICE'];
			}	
		}
	
	}
	
}	

function passEUserCountryRequest(url,str,srcObj,targetObjName)
{		
	country_code=srcObj.value;
	document.getElementById('prod_trade').innerHTML= '';
	document.getElementById('prod_name').innerHTML= '';
	document.getElementById('part_type').innerHTML= '';
	document.getElementById('prod_trade').disabled= true;
	document.getElementById('prod_name').disabled= true;
	document.getElementById('part_type').disabled= true;
	if (document.getElementById('item_count').value>0)
		item_count=document.getElementById('item_count').value;
	
	trgObj = document.getElementById(targetObjName);
	
	postStr=str+"&country_code="+country_code;
	productOk=false;
	makeRequest(url,postStr);
}


function loadCombo()
{
	var len = 0; 
	trgObj.disabled= false;
	trgObj.innerHTML='';
	var opt=document.createElement('OPTION');
	var ie4=document.all?true:false;
	opt.value='';
	opt.text='';
	trgObj.options[len]=opt;
	
	len++;
	for (var i=0;i<selectArr.length;i++){
		var opt=document.createElement('OPTION');
		selectArr[i]=convertCharTOSymbol(selectArr[i]);
		opt.value=selectArr[i];
		opt.text=selectArr[i];
		trgObj.options[len]=opt;
		len++;
		opt=null;
	}
	trgObj=null;
	selectArr=null;
}



function passPartInfoRequest(url,str,obj)
{
 	 postStr=str;
	 var usrlev=document.getElementById('user_level');
	 if (!country_code)
		 	country_code=document.getElementById('country_code').value;
	 if(obj.type=="button" && obj.name=="ADD_PRODUCT"){
	 	 var part=document.getElementById('part_num');
		 document.getElementById('prod_name').innerHTML='';
		 document.getElementById('prod_name').disabled=true;
		 document.getElementById('prod_trade').innerHTML='';
		 document.getElementById('prod_trade').disabled=true;
		 document.getElementById('part_type').innerHTML='';
		 document.getElementById('part_type').disabled=true;
		 document.getElementById('soft_brand').selectedIndex=-1;
		 if (part.value!=''){
		 	part_num=trim(part.value);
			user_part_desc=trim(part.value);
			part.value='';
			postStr+="&part_num="+part_num;
		   
		 }	
		 trgObj=null;
		 productOk=true;
		 
	 }
	 else if (obj.type=="button" && obj.name=="ADD_PRODUCT_BY_PILLAR")
	 {
		 var arr=(document.getElementById('prod_name').value).split("  ");
		 var brand=document.getElementById('soft_brand').value;
		 var trade=document.getElementById('prod_trade').value;
		 var part=document.getElementById('part_type').value;	
		 part_name=arr[0];
		 part_num=arr[1];
		 postStr+="&part_num="+arr[0];
		 if (brand!=0)
		 	part_group_desc+=brand;
		 if (trade!=0 && brand!=0)
		 	part_group_desc+=" - "+trade;
		 else if (trade!=0)
		 	part_group_desc+=trade;
		 if (part!=0 && (trade!=0 || brand!=0 ))
		   part_group_desc+=" - "+part;
		 else if (part!=0)
		 	part_group_desc+=part;
		
			productOk=true;
	 }
	 
	 if (document.getElementById('item_count').value>0)
			item_count=parseInt(document.getElementById('item_count').value)+1;
	 else
		 	item_count=1 ;
	 if (usrlev)
	 	postStr+="&user_level="+usrlev.value
	 if (country_code)
	 	postStr+="&country_code="+country_code;
	 else
	 {
	 	alert('Please select country for end user.');
		return;
	 }
	 
	 makeRequest(url,postStr);
  //  alert(user_part_desc);
}

function editEntireQuote(url,postStr1,postStr2)
{
	document.getElementById('svrBrandNeed').disabled=false;
	document.getElementById('svrVendNeed').value=document.getElementById('SR_VENDOR').value;
	document.body.style.cursor = 'wait';
	passProcessorRequest(url,postStr1,document.getElementById('svrVendNeed'),'svrBrandNeed');
	setTimeout("sleepAndLoad1(\'"+url+"\',\'"+postStr2+"\')", sleepTime*2);
	
}


function editValueItem(url,postStr1,postStr2,item_index)
{
	
	document.getElementById('svrBrandNeed').disabled=false;
	document.getElementById('svrVendNeed').value=document.getElementById('SR_VENDOR_'+item_index).value;
	document.body.style.cursor = 'wait';
	passProcessorRequest(url,postStr1,document.getElementById('svrVendNeed'),'svrBrandNeed');
	setTimeout("sleepAndLoad1(\'"+url+"\',\'"+postStr2+"\',\'"+item_index+"\')", sleepTime*2);
	
}

function sleepAndLoad1(url,postStr,item_index)
{
	
	if (item_index)
		document.getElementById('svrBrandNeed').value=document.getElementById('SR_BRAND_'+item_index).value;
	else
		document.getElementById('svrBrandNeed').value=document.getElementById('SR_BRAND').value;
	passProcessorRequest(url,postStr,document.getElementById('svrBrandNeed'));
	if (item_index)
	{
		document.getElementById('procCoreQty').value=document.getElementById('PR_CORE_QTY_'+item_index).value;
		setTimeout("sleepAndLoad2("+item_index+")", sleepTime);
	}
	else
	{
		document.getElementById('procCoreQty').value=document.getElementById('PR_CORE_QTY').value;
	   setTimeout("sleepAndLoad3()", sleepTime);
	}
}

function sleepAndLoad3(){
	
	var frm =document.getElementById('procValUnitsFrm');
	var Inputs = document.getElementsByTagName("input");
	for (var e = 0; e <Inputs.length; e++)
	{
		obj=Inputs[e];
		if (obj.type=="text" && obj.id.substring(0,1)=='_' && obj.id.indexOf("[")==-1)
		{
			
			if (document.getElementById('PR_VENDOR').value==obj.value)
			{
				obj=Inputs[e+1];
				
				if (document.getElementById('PR_ARCHITECTURE').value==obj.value)
				{
					
					obj=Inputs[e+2];
					if (document.getElementById('PR_BRAND').value==obj.value)
					{
						obj=Inputs[e+3];
						if (document.getElementById('PR_TYPE').value==obj.value)
						{
							
							Inputs[e+4].value=document.getElementById('VALUE_UNITS_CORE').value;
							Inputs[e+5].checked=true;
							selectChkObj=Inputs[e+5];
							editLineItem=true;
							
							
					
						}
					}
				
				}
			}
			
				
		}
		 
	}		
	
	frm.valUnitApp[0].checked=true;
	frm.valUnitApp[0].disabled=true;
	frm.valUnitApp[1].disabled=true;
	document.body.style.cursor = 'default';
	showValueUnitsTable(true,1);
}	
	
function sleepAndLoad2(item_index)
{	
	var frm =document.getElementById('procValUnitsFrm');
	var Inputs = document.getElementsByTagName("input");
	for (var e = 0; e <Inputs.length; e++)
	{
		obj=Inputs[e];
		if (obj.type=="text" && obj.id.substring(0,1)=='_' && obj.id.indexOf("[")==-1)
		{
			
			if (document.getElementById('PR_VENDOR_'+item_index).value==obj.value)
			{
				obj=Inputs[e+1];
				
				if (document.getElementById('PR_ARCHITECTURE_'+item_index).value==obj.value)
				{
					
					obj=Inputs[e+2];
					if (document.getElementById('PR_BRAND_'+item_index).value==obj.value)
					{
						obj=Inputs[e+3];
						if (document.getElementById('PR_TYPE_'+item_index).value==obj.value)
						{
							
							Inputs[e+4].value=document.getElementById('VALUE_UNITS_CORE_'+item_index).value;
							Inputs[e+5].checked=true;
							selectChkObj=Inputs[e+5];
							edit_index=item_index;
							editLineItem=true;
					
						}
					}
				
				}
			}
				
		}
		 
	}		
	
	frm.valUnitApp[1].checked=true;
	frm.valUnitApp[0].disabled=true;
	frm.valUnitApp[1].disabled=true;
	document.body.style.cursor = 'default';
	showValueUnitsTable(true,item_index);
}





function insertValueUnits(tableObj)
{
	var ie4=document.all?true:false;
	var frm=document.getElementById('quoteform');
	/*
	var trrow0=document.createElement("tr");	
	trrow0.className="normal";
	trrow0.id="TR_UN_"+item_count+"_0";
	trrow0.height="10px";
	var tdcell0= document.createElement("td");
	tdcell0.colSpan=6;
	var hr11=document.createElement("hr");
	tdcell0.appendChild(hr11);
	trrow0.appendChild(tdcell0);	
	if (ie4 && tableObj.tBodies[0])
		tableObj.tBodies[0].appendChild(trrow0);
	else
		tableObj.appendChild(trrow0);
	*/
	var trrow0=document.createElement("tr");	
	trrow0.className="normal";
	trrow0.id="TR_UN_"+item_count+"_0";
	trrow0.height="10px";
	var tdcell0= document.createElement("td");
	tdcell0.colSpan=7;
	tdcell0.setAttribute('align', 'right');
	if (!entireQuoteOK)
		tdcell0.innerHTML='<input type="button" class="btn" value="Edit" onclick="javascript:editValueItem(\''+pro_url+'\',\''+pro_postStr1+'\',\''+pro_postStr2+'\',\''+item_count+'\')" >';
	
	//tdcell15.appendChild(btn5);
	trrow0.appendChild(tdcell0);
	if (ie4 && tableObj.tBodies[0])
		tableObj.tBodies[0].appendChild(trrow0);
	else
		tableObj.appendChild(trrow0);
	
	
	var trrow1=document.createElement("tr");
	trrow1.className="normal";
	trrow1.id="TR_UN_"+item_count+"_1";
	
	var tdcell= document.createElement("td");
	tdcell.setAttribute('width', '100px');
	trrow1.appendChild(tdcell);
	
	var tdcell11= document.createElement("td");
	var txtcel111=document.createTextNode("Server Vendor: ");
	tdcell11.appendChild(txtcel111);
	trrow1.appendChild(tdcell11);
	
	var tdcell12= document.createElement("td");
	if (!entireQuoteOK)
		var txtcell12=document.createTextNode(sr_vendor);	
	else
		var txtcell12=document.createTextNode(document.getElementById('SR_VENDOR').value);
	
	var hidecell12=document.createElement('input');
	tdcell12.appendChild(txtcell12);
	trrow1.appendChild(tdcell12);
	hidecell12.setAttribute("type","hidden");
	hidecell12.setAttribute('id', 'SR_VENDOR_'+item_count);
	hidecell12.setAttribute('name', 'SR_VENDOR_'+item_count);
	if (!entireQuoteOK)
		hidecell12.setAttribute('value', sr_vendor);
	else
		hidecell12.setAttribute('value', document.getElementById('SR_VENDOR').value);
	tdcell0.appendChild(hidecell12);
	frm.appendChild(hidecell12);
		
	var tdcell13= document.createElement("td");
	var txtcel113=document.createTextNode("Server Brand: ");
	tdcell13.appendChild(txtcel113);
	trrow1.appendChild(tdcell13);
	var tdcell14= document.createElement("td");
	if (!entireQuoteOK)
		var txtcell14=document.createTextNode(sr_brand);
	else
		var txtcell14=document.createTextNode(document.getElementById('SR_BRAND').value);
	
	
	
	var hidecell14=document.createElement('input');
	tdcell14.appendChild(txtcell14);
	trrow1.appendChild(tdcell14);
	hidecell14.setAttribute("type","hidden");
	hidecell14.setAttribute('id', 'SR_BRAND_'+item_count);
	hidecell14.setAttribute('name', 'SR_BRAND_'+item_count);
	if (!entireQuoteOK)
		hidecell14.setAttribute('value', sr_brand);	
	else
		hidecell14.setAttribute('value', document.getElementById('PR_VENDOR').value);
	tdcell0.appendChild(hidecell14);
	frm.appendChild(hidecell14);
	trrow1.appendChild(tdcell14);
	
	var tdcell15= document.createElement("td");
	var txtcel115=document.createTextNode("Processor Vendor: ");
	tdcell15.appendChild(txtcel115);
	trrow1.appendChild(tdcell15);
	
	var tdcell16= document.createElement("td");
	if (!entireQuoteOK)
		var txtcell16=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_1").value);
	else
		var txtcell16=document.createTextNode(document.getElementById("PR_VENDOR").value);
	var hidecell16=document.createElement('input');
	tdcell16.appendChild(txtcell16);
	trrow1.appendChild(tdcell16);
	hidecell16.setAttribute("type","hidden");
	hidecell16.setAttribute('id', 'PR_VENDOR_'+item_count);
	hidecell16.setAttribute('name', 'PR_VENDOR_'+item_count);
	if (!entireQuoteOK)
		hidecell16.setAttribute('value', document.getElementById("_"+selectChkObj.value+"_1").value);	
	else
		hidecell16.setAttribute('value', document.getElementById("PR_VENDOR").value);
	tdcell0.appendChild(hidecell16);
	frm.appendChild(hidecell16);

	if (ie4 && tableObj.tBodies[0])
	{
		tableObj.tBodies[0].appendChild(trrow1);
		
	}else
		tableObj.appendChild(trrow1);
	
	var trrow2=document.createElement("tr");
	trrow2.className="normal";
	trrow2.id="TR_UN_"+item_count+"_2";
	
	var tdcell= document.createElement("td");
	tdcell.setAttribute('width', '100px');
	trrow2.appendChild(tdcell);
	
	var tdcell17= document.createElement("td");
	var txtcel117=document.createTextNode("Processor Architecture: ");
	tdcell17.appendChild(txtcel117);
	trrow2.appendChild(tdcell17);
	
	var tdcell18= document.createElement("td");
	if (!entireQuoteOK)
		var txtcell18=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_2").value);
	else
		var txtcell18=document.createTextNode(document.getElementById("PR_ARCHITECTURE").value);
	var hidecell18=document.createElement('input');
	tdcell18.appendChild(txtcell18);
	trrow2.appendChild(tdcell18);
	hidecell18.setAttribute("type","hidden");
	hidecell18.setAttribute('id', 'PR_ARCHITECTURE_'+item_count);
	hidecell18.setAttribute('name', 'PR_ARCHITECTURE_'+item_count);
	if (!entireQuoteOK)
		hidecell18.setAttribute('value', document.getElementById("_"+selectChkObj.value+"_2").value);	
	else
		hidecell18.setAttribute('value', document.getElementById("PR_ARCHITECTURE").value);		
	tdcell0.appendChild(hidecell18);
	frm.appendChild(hidecell18);
	
	var tdcell19= document.createElement("td");
	var txtcel119=document.createTextNode("Processor Brand: ");
	tdcell19.appendChild(txtcel119);
	trrow2.appendChild(tdcell19);
	
	var tdcell10= document.createElement("td");
	if (!entireQuoteOK)
		var txtcell10=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_3").value);
	else
		var txtcell10=document.createTextNode(document.getElementById("PR_BRAND").value);
	var hidecell10=document.createElement('input');
	tdcell10.appendChild(txtcell10);
	trrow2.appendChild(tdcell10);
	hidecell10.setAttribute("type","hidden");
	hidecell10.setAttribute('id', 'PR_BRAND_'+item_count);
	hidecell10.setAttribute('name', 'PR_BRAND_'+item_count);
	if (!entireQuoteOK)
		hidecell10.setAttribute('value', document.getElementById("_"+selectChkObj.value+"_3").value);	
	else
		hidecell10.setAttribute('value', document.getElementById("PR_BRAND").value);	
	tdcell0.appendChild(hidecell10);
	frm.appendChild(hidecell10);

	
	var tdcell11= document.createElement("td");
	var txtcel111=document.createTextNode("Processor Type: ");
	tdcell11.appendChild(txtcel111);
	trrow2.appendChild(tdcell11);
	
	var tdcell12= document.createElement("td");
	if (!entireQuoteOK)
		var txtcell12=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_4").value);
	else
		var txtcell12=document.createTextNode(document.getElementById("PR_TYPE").value);
	var hidecell10=document.createElement('input');
	tdcell12.appendChild(txtcell12);
	trrow2.appendChild(tdcell12);
	hidecell10.setAttribute("type","hidden");
	hidecell10.setAttribute('id', 'PR_TYPE_'+item_count);
	hidecell10.setAttribute('name', 'PR_TYPE_'+item_count);
	if (!entireQuoteOK)
		hidecell10.setAttribute('value', document.getElementById("_"+selectChkObj.value+"_4").value);	
	else
		hidecell10.setAttribute('value', document.getElementById("PR_TYPE").value);	
	tdcell0.appendChild(hidecell10);
	frm.appendChild(hidecell10);
	
	if (ie4 && tableObj.tBodies[0])
	{
		tableObj.tBodies[0].appendChild(trrow2);
		
	}else
		tableObj.appendChild(trrow2);
		
	var trrow3=document.createElement("tr");
	trrow3.className="normal";
	trrow3.id="TR_UN_"+item_count+"_3";
	
	
	var tdcell= document.createElement("td");
	tdcell.setAttribute('width', '100px');
	trrow3.appendChild(tdcell);
	
	var tdcell13= document.createElement("td");
	var txtcel113=document.createTextNode("Value Units: ");
	tdcell13.appendChild(txtcel113);
	trrow3.appendChild(tdcell13);
	
	var tdcell14= document.createElement("td");
	if (!entireQuoteOK)
		var txtcell14=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_5").value);
	else
		var txtcell14=document.createTextNode(document.getElementById("VALUE_UNITS_CORE").value);
	var hidecell14=document.createElement('input');
	tdcell14.appendChild(txtcell14);
	trrow3.appendChild(tdcell14);
	hidecell14.setAttribute("type","hidden");
	hidecell14.setAttribute('id', 'VALUE_UNITS_CORE_'+item_count);
	hidecell14.setAttribute('name', 'VALUE_UNITS_CORE_'+item_count);
	if (!entireQuoteOK)
		hidecell14.setAttribute('value', document.getElementById("_"+selectChkObj.value+"_5").value);	
	else
		hidecell14.setAttribute('value', document.getElementById("VALUE_UNITS_CORE").value);	
	tdcell0.appendChild(hidecell14);
	frm.appendChild(hidecell14);
	
	var tdcell17= document.createElement("td");
	var txtcel117=document.createTextNode("Processor Core Qty: ");
	tdcell17.appendChild(txtcel117);
	trrow3.appendChild(tdcell17);
	
	var tdcell18= document.createElement("td");
	if (!entireQuoteOK)
		var txtcell18=document.createTextNode(document.getElementById("procCoreQty").value);
	else
		var txtcell18=document.createTextNode(document.getElementById("PR_CORE_QTY").value);
	var hidecell14=document.createElement('input');
	tdcell18.appendChild(txtcell18);
	trrow3.appendChild(tdcell18);	
	hidecell14.setAttribute("type","hidden");
	hidecell14.setAttribute('id', 'PR_CORE_QTY_'+item_count);
	hidecell14.setAttribute('name', 'PR_CORE_QTY_'+item_count);
	if (!entireQuoteOK)
		hidecell14.setAttribute('value', document.getElementById("procCoreQty").value);
	else
		hidecell14.setAttribute('value', document.getElementById("PR_CORE_QTY").value);		
	tdcell0.appendChild(hidecell14);
	frm.appendChild(hidecell14);
	
		
	var tdcell19= document.createElement("td");
	var txtcel119=document.createTextNode("Total: ");
	tdcell19.appendChild(txtcel119);
	trrow3.appendChild(tdcell19);
	
	var tdcell20= document.createElement("td");
	if (!entireQuoteOK)
		var txtcell20=document.createTextNode(document.getElementById("_"+selectChkObj.value+"_5").value*document.getElementById("procCoreQty").value);
	else
		var txtcell20=document.createTextNode(document.getElementById("PR_TOTAL_PRICE").value*document.getElementById("PR_CORE_QTY").value);

	var hidecell14=document.createElement('input');
	tdcell20.appendChild(txtcell20);
	trrow3.appendChild(tdcell20);
	hidecell14.setAttribute("type","hidden");
	hidecell14.setAttribute('id', 'PR_TOTAL_PRICE_'+item_count);
	hidecell14.setAttribute('name', 'PR_TOTAL_PRICE_'+item_count);
	if (!entireQuoteOK)
		hidecell14.setAttribute('value', document.getElementById("_"+selectChkObj.value+"_5").value*document.getElementById("procCoreQty").value);	
	else
		hidecell14.setAttribute('value', document.getElementById("PR_TOTAL_PRICE").value*document.getElementById("PR_CORE_QTY").value);	

	tdcell0.appendChild(hidecell14);
	frm.appendChild(hidecell14);
	
	if (ie4 && tableObj.tBodies[0])
		tableObj.tBodies[0].appendChild(trrow3);
	else
		tableObj.appendChild(trrow3);	
	
	var trrow5=document.createElement("tr");	
	trrow5.className="normal";
	trrow5.id="TR_UN_"+item_count+"_4";
	trrow5.height="10px";
	var tdcell22= document.createElement("td");
	tdcell22.colSpan=7;
	var hr11=document.createElement("hr");
	tdcell22.appendChild(hr11);
	trrow5.appendChild(tdcell22);	
	if (ie4 && tableObj.tBodies[0])
		tableObj.tBodies[0].appendChild(trrow5);
	else
		tableObj.appendChild(trrow5);
	vitem_index_arr[vitem_index++]=item_count;
		

}

function insertProduct(tableObj)
{
	
	var ie4=document.all?true:false;
	var frm=document.getElementById('quoteform');
	var trrow1=document.createElement("tr");
	trrow1.className="normal";
	trrow1.id="TR_"+item_count+"_1";
	
	
	
	var tdcell11= document.createElement("td");
	var txtcel111=document.createTextNode("Part #: ");
	tdcell11.appendChild(txtcel111);
	trrow1.appendChild(tdcell11);
	
	var tdcell12= document.createElement("td");
	var txtcell12=document.createTextNode((part_num?part_num:''));
	tdcell12.colSpan=2;
	tdcell12.appendChild(txtcell12);
	trrow1.appendChild(tdcell12);
	
	var hidecell12=document.createElement('input');
	hidecell12.setAttribute("type","hidden");
	hidecell12.setAttribute('name', 'PART_NUM_'+item_count);
	hidecell12.setAttribute('id', 'PART_NUM_'+item_count);
	hidecell12.setAttribute('value', part_num);	
	tdcell12.appendChild(hidecell12);
	frm.appendChild(hidecell12);
	
	var tdcell13= document.createElement("td");
	var txtcell13=document.createTextNode("Product Name: ");
	tdcell13.appendChild(txtcell13);
	trrow1.appendChild(tdcell13);
	
	var tdcell14= document.createElement("td");
	var txtcell14=document.createTextNode((part_name?part_name:''));
	tdcell14.appendChild(txtcell14);
	trrow1.appendChild(tdcell14);
	
	var hidecell14=document.createElement('input');
	hidecell14.setAttribute("type","hidden");
	hidecell14.setAttribute('name', 'PRODUCT_NAME_'+item_count);
	hidecell14.setAttribute('value', part_name);	
	tdcell14.appendChild(hidecell14);
	frm.appendChild(hidecell14);
	
	var tdcell15= document.createElement("td");
	tdcell15.colSpan=7;
	tdcell15.setAttribute('align', 'right');
	tdcell15.innerHTML='<input type="button" class="btn" value="Delete" onclick="javascript:deleteItem('+item_count+')" >';
	
	//tdcell15.appendChild(btn5);
	trrow1.appendChild(tdcell15);
	if (ie4 && tableObj.tBodies[0])
		tableObj.tBodies[0].appendChild(trrow1);
	else
		tableObj.appendChild(trrow1);
	
	var trrow2=document.createElement("tr");	
	trrow2.className="normal";
	trrow2.id="TR_"+item_count+"_2";	
	
	var tdcell21= document.createElement("td");
	var txtcel121=document.createTextNode("Product Description: ");
	tdcell21.setAttribute('valign', 'top');
	tdcell21.appendChild(txtcel121);
	trrow2.appendChild(tdcell21);	
		
	var tdcell22= document.createElement("td");
	if (part_desc)
	{
		var txtcel122=document.createTextNode(part_desc);
		var hidecell22=document.createElement('input');
		hidecell22.setAttribute("type","hidden");
		hidecell22.setAttribute('name','PART_DESC_'+item_count);
		hidecell22.setAttribute('value', part_desc);	
		tdcell22.appendChild(hidecell22);
		tdcell22.setAttribute('valign', 'top');
		tdcell22.setAttribute('width', '200px');
		tdcell22.appendChild(txtcel122);
		
		frm.appendChild(hidecell22);
	
	}
	else
	{
		
		var txtcel122=document.createElement('textarea');
		txtcel122.setAttribute('cols', '20');
		txtcel122.setAttribute('rows', '3');
		//txtcel122.setAttribute("type","text");
		txtcel122.setAttribute('id', 'PART_DESC_'+item_count);
		if (ie4)
			txtcel122.setAttribute('name','PART_DESC_'+item_count);
		//txtcel122.setAttribute('value', user_part_desc);
		
		if (part_group_desc!='')
			user_part_desc=part_group_desc;
		txtcel122.value= user_part_desc;
		txtcel122.setAttribute('maxlength', '255');
		
		tdcell22.appendChild(txtcel122);
		if (!ie4)
		{
			var hidecell22=document.createElement('input');
			hidecell22.setAttribute("type","hidden");
			hidecell22.setAttribute('name','PART_DESC_'+item_count);
			hidecell22.setAttribute('value', '');	
			tdcell22.appendChild(hidecell22);
			frm.appendChild(hidecell22);
		}
		
		user_part_desc='';
	}
	
	
	tdcell22.colSpan=2;
	trrow2.appendChild(tdcell22);	
	
	if (!lineItemOk)
	{
		var tdcell23= document.createElement("td");
		var txtcel123=document.createTextNode("# of users:");
		tdcell23.appendChild(txtcel123);
		trrow2.appendChild(tdcell23);
	
	
		var tdcell24= document.createElement("td");
		var txtcell24=document.createElement('input');
		txtcell24.setAttribute('size', '9');
		txtcell24.setAttribute("type","text");
		txtcell24.setAttribute('id', 'NO_OF_USERS_'+item_count);
		if (ie4)
			txtcell24.setAttribute('name', 'NO_OF_USERS_'+item_count);
		txtcell24.setAttribute('value', '');
		txtcell24.setAttribute('maxlength', '9');	
	
		tdcell24.appendChild(txtcell24);
		trrow2.appendChild(tdcell24);	
	
		if (!ie4)
		{
			var hidecell24=document.createElement('input');
			hidecell24.setAttribute("type","hidden");
			hidecell24.setAttribute('name', 'NO_OF_USERS_'+item_count);
			hidecell24.setAttribute('value', '');	
			tdcell24.appendChild(hidecell24);
			frm.appendChild(hidecell24);
		}
	}
	
		
	
	var tdcell25= document.createElement("td");
	var txtcel125=document.createTextNode("List Price("+country_code+"): ");
	tdcell25.appendChild(txtcel125);
	trrow2.appendChild(tdcell25);
	
	var tdcell26= document.createElement("td");
	var txtcell26=document.createTextNode((vol_price?vol_price:''));
	tdcell26.appendChild(txtcell26);
	trrow2.appendChild(tdcell26);
	
	var hidecell26=document.createElement('input');
	hidecell26.setAttribute("type","hidden");
	hidecell26.setAttribute('name', 'VOLUME_PRICE_'+item_count);
	hidecell26.setAttribute('value', vol_price);	
	tdcell26.appendChild(hidecell26);
	frm.appendChild(hidecell26);
	
	if (lineItemOk)
	{
		var tdcell26= document.createElement("td");
		tdcell26.colSpan=2;
		trrow2.appendChild(tdcell26);
	}
	
	if (ie4 && tableObj.tBodies[0])
		tableObj.tBodies[0].appendChild(trrow2);
	else
		tableObj.appendChild(trrow2);
		
		
	var trrow3=document.createElement("tr");	
	trrow3.className="normal";
	trrow3.id="TR_"+item_count+"_3";	
	if (!lineItemOk)
	{
		
		var tdcell31= document.createElement("td");
		var txtcel131=document.createTextNode("Operating System/Platform: ");
		tdcell31.appendChild(txtcel131);
		trrow3.appendChild(tdcell31);		
		
		var tdcell32= document.createElement("td");
		var txtcell32=document.createElement('input');
		
		tdcell32.colSpan=2;
		txtcell32.setAttribute('size', '10');
		txtcell32.setAttribute("type","text");
		txtcell32.setAttribute('id', 'OS_PLATFORM_'+item_count);
		if (ie4)
			txtcell32.setAttribute('name', 'OS_PLATFORM_'+item_count);
		txtcell32.setAttribute('value', '');
		txtcell32.setAttribute('maxlength', '10');	
		
		tdcell32.appendChild(txtcell32);
		trrow3.appendChild(tdcell32);	
	
		if (!ie4)
		{
			var hidecell32=document.createElement('input');
			hidecell32.setAttribute("type","hidden");
			hidecell32.setAttribute('name', 'OS_PLATFORM_'+item_count);
			hidecell32.setAttribute('value', '');	
			tdcell32.appendChild(hidecell32);
			frm.appendChild(hidecell32);
		}
	
		var tdcell33= document.createElement("td");
		var txtcel133=document.createTextNode(" # of Processors: ");
		tdcell33.appendChild(txtcel133);
		trrow3.appendChild(tdcell33);		
		
		var tdcell34= document.createElement("td");
		var txtcell34=document.createElement('input');
		txtcell34.setAttribute('size', '9');
		txtcell34.setAttribute("type","text");
		if (ie4)
			txtcell34.setAttribute('name', 'NO_OF_PROCESSORS_'+item_count);
		txtcell34.setAttribute('id', 'NO_OF_PROCESSORS_'+item_count);
		txtcell34.setAttribute('value', '');
		txtcell34.setAttribute('maxlength', '9');	
		
		tdcell34.appendChild(txtcell34);
		trrow3.appendChild(tdcell34);
	
		if (!ie4)
		{
			var hidecell34=document.createElement('input');
			hidecell34.setAttribute("type","hidden");
			hidecell34.setAttribute('name', 'NO_OF_PROCESSORS_'+item_count);
			hidecell34.setAttribute('value', '');	
			tdcell34.appendChild(hidecell34);
			frm.appendChild(hidecell34);
		}	
	}
	else
	{
		var tdcell34= document.createElement("td");
		tdcell34.colSpan=3;
		trrow3.appendChild(tdcell34);
	}
	var tdcell35= document.createElement("td");
	var txtcel135=document.createTextNode("Level Price("+country_code+"): ");
	
	var hidecell35=document.createElement('input');
	hidecell35.setAttribute("type","hidden");
	hidecell35.setAttribute('name','CURRENCY_CODE_'+item_count);
	hidecell35.setAttribute('id','CURRENCY_CODE_'+item_count);
	hidecell35.setAttribute('value', country_code);
		
	tdcell35.appendChild(hidecell35);
	tdcell35.appendChild(txtcel135);
	frm.appendChild(hidecell35);
	trrow3.appendChild(tdcell35);		
		
	var tdcell36= document.createElement("td");
	var txtcell36=document.createTextNode((level_price?level_price:''));
	tdcell36.setAttribute("id",'level_'+item_count);
	tdcell36.appendChild(txtcell36);
	trrow3.appendChild(tdcell36);
	
	var hidecell36=document.createElement('input');
	hidecell36.setAttribute("type","hidden");
	hidecell36.setAttribute('name', 'LEVEL_PRICE_'+item_count);
	hidecell36.setAttribute('id', 'LEVEL_PRICE_'+item_count);
	hidecell36.setAttribute('value', level_price);	
	tdcell36.appendChild(hidecell36);
	frm.appendChild(hidecell36);
	
	tdcell36.appendChild(txtcell36);
	trrow3.appendChild(tdcell36);	
	if (lineItemOk)
	{
		var tdcell26= document.createElement("td");
		tdcell26.colSpan=2;
		tdcell26.setAttribute('width', '200px');
		trrow3.appendChild(tdcell26);
	}
	if (ie4 && tableObj.tBodies[0])
		tableObj.tBodies[0].appendChild(trrow3);
	else
		tableObj.appendChild(trrow3);
	if (!lineItemOk || entireQuoteOK)
	{
		
		var trrow4=document.createElement("tr");	
		trrow4.className="normal";
		trrow4.id="TR_"+item_count+"_4";
		trrow4.height="10px";
		var tdcell41= document.createElement("td");
		tdcell41.colSpan=7;
		var hr41=document.createElement("hr");
		tdcell41.appendChild(hr41);
		trrow4.appendChild(tdcell41);	
		if (ie4 && tableObj.tBodies[0])
			tableObj.tBodies[0].appendChild(trrow4);
		else
			tableObj.appendChild(trrow4);
		
	}
	lineItemOk=false;
	part_desc='';
	part_num='';
	part_name='';
	part_no='';
	vol_price='';
	level_price='';
	user_part_desc='';
	part_group_desc='';
	document.getElementById('item_count').value=item_count;
	if (!lineItemOk)
		document.getElementById('part_num').focus();
	document.getElementById('prod_name').selectedIndex=-1;


}

function assignProductsInfo(frm)
{
	
	if (!ie4)
	{   
		
		for (var e = 0; e <frm.elements.length; e++)
		{
			
			var name=frm.elements.item(e).getAttribute('name')
			
			for(var i=0;i<=item_count;i++)
			{
			
				if (name=='NO_OF_USERS_'+i || name=='OS_PLATFORM_'+i || name=='NO_OF_PROCESSORS_'+i || name=='PART_DESC_'+i || name=='PR_CORE_QTY_'+i || name=='PR_TOTAL_PRICE_'+i ||
					  name=='SR_VENDOR_'+i || name=='SR_BRAND_'+i || name=='PR_VENDOR_'+i || name=='PR_ARCHITECTURE_'+i || name=='PR_BRAND_'+i || name=='PR_TYPE_'+i || name=='VALUE_UNITS_CORE_'+i)
				{
					
					if (document.getElementById(name))
						frm.elements.item(e).value=trim(document.getElementById(name).value);
					
				}
			}
		}
		
	}

	setPosition();
	document.getElementById('delete_items').value=delete_items;
	document.getElementById('prepage').style.visibility='visible';
	document.getElementById('submitblock').style.display='none';
	return true;
	
}

function deleteItem(index)
{
   document.getElementById("TR_"+index+"_1").style.display='none';
	document.getElementById("TR_"+index+"_2").style.display='none';
	document.getElementById("TR_"+index+"_3").style.display='none';
	if (document.getElementById("TR_"+index+"_4"))
		document.getElementById("TR_"+index+"_4").style.display='none';

	if (document.getElementById("TR_UN_"+index+"_1"))
	{
		document.getElementById("TR_UN_"+index+"_0").style.display='none';
		document.getElementById("TR_UN_"+index+"_1").style.display='none';
		document.getElementById("TR_UN_"+index+"_2").style.display='none';
		document.getElementById("TR_UN_"+index+"_3").style.display='none';
		document.getElementById("TR_UN_"+index+"_4").style.display='none';
	}
	
	/*if (document.getElementById('entire_index').value==index)
	{
		document.getElementById('entire_row').style.display='none';
		document.getElementById('value_units_cell').style.height=0;
		
	}*/
	delete_items+=index+'|';
	document.getElementById('part_num').focus();	
}

function trim(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function passToForm(frmName,aqno,sncid,type)
{
	document.getElementById('aqno').value=aqno;
	document.getElementById('sncid').value=sncid;
	document.getElementById('frmtyp').value=type;
	eval('document.'+frmName+'.submit()');
}

function passToQuoteForm(frmName,type)
{
	document.getElementById('frmtyp').value=type;
	eval('document.'+frmName+'.submit()');
}
function deleteDoc(btnName,docid)
{
	document.getElementById('docid').value=docid;
	if (!confirm('Delete this Document?'))
		return false;
	document.getElementById(btnName).click();
   
}

function changeContactInfo(btnName)
{
	document.getElementById('ch_info').value='YES';
	document.getElementById(btnName).click();
}
function debug() {
	var str = "Element Info\n";
	
	for (var index in document.forms) {
	
		if (document.forms[index].nodeType == 1) {
//			alert(document.forms[index].elements.item(0));
			str += "--] " + document.forms[index].nodeName+"\n";
			for (e = 0; e < document.forms[index].elements.length; e++) {
				str += "---] "
						+ document.forms[index].elements.item(e).nodeName 
						+ " - "
						+ document.forms[index].elements.item(e).getAttribute('name')
						+ "\n";
			}
		} 
	}
	t = document.getElementsByTagName('BODY');
	body = t[0];
	
	pre = document.createElement('pre');
	pre.setAttribute("style","position:absolute;border: 1px solid black;background-color:#EEEEEE; font-size: 10px;");
	text = document.createTextNode(str)	;
	pre.appendChild(text);
	body.appendChild(pre);

}

function validateInputNumber(obj,valLen,valType){
	var idx = obj.value.length-1;
	var txt = obj.value.charAt(idx);
			  
	if( ( (valType=='float') && ( (valLen < idx+1) || (txt!='0'&& txt!='1' &&  txt!='2' &&  txt!='3' &&  txt!='4' &&  txt!='5' &&  txt!='6' &&  txt!='7' &&  txt!='8' && txt!='9' && txt!='.') || (txt=='.' && idx!=obj.value.indexOf('.')) ) )
		|| ( (valType=='integer') && ( (valLen < idx+1) || (txt!='0'&& txt!='1' &&  txt!='2' &&  txt!='3' &&  txt!='4' &&  txt!='5' &&  txt!='6' &&  txt!='7' &&  txt!='8' && txt!='9') ) )  ){
			var val = '';
			for (i=0;i<=idx-1;i=i+1)
				val=val + obj.value.charAt(i);
			obj.value=val;
	}
	
	var chrLen = obj.value.length;
	var valChar = '';
		 	  
	for (i=0;i<=chrLen;i=i+1){
		txtChr = obj.value.charAt(i);
		if( ( (valType=='float') &&   (txtChr=='0'|| txtChr=='1' ||  txtChr=='2' ||  txtChr=='3' ||  txtChr=='4' ||  txtChr=='5' ||  txtChr=='6' ||  txtChr=='7' ||  txtChr=='8' || txtChr=='9' || txtChr=='.')   )
		 || ( (valType=='integer') &&   (txtChr=='0' || txtChr=='1' ||  txtChr=='2' ||  txtChr=='3' ||  txtChr=='4' ||  txtChr=='5' ||  txtChr=='6' ||  txtChr=='7' ||  txtChr=='8' || txtChr=='9')  )  ){
			valChar=valChar+txtChr;
		}
	}
			  
	obj.value=valChar;
}



