var resultDropdownName="";
var selname='sele_id_';
var Totelement="";

function GotoForChange(DropdownName,norow,opid,productid,catid)
	{
		
	
		var SelectedIndex=document.getElementById(DropdownName).selectedIndex;
		var Selectedvalue=document.getElementById(DropdownName).options[SelectedIndex].value;
		
		
		
		var url = "ajax-sel-attribute.php?catid="+catid+"&proid="+productid+"&dropId="+Selectedvalue;
		
		//alert(url);
		
		var isWorking=false;
		if (!isWorking && http)
		{
			http.open("GET", url, true);
			http.onreadystatechange = handleHttpResponse;
			isWorking = true;
			http.send(null);
		}
		
	
	}
	
	<!-- ================= S T A R T     A J A X ================ -->
var http = getHTTPObject(); 
function getHTTPObject() {
   var ro;
    var browser = navigator.appName;
    
    if(browser == "Microsoft Internet Explorer")
	{
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
	{
        ro = new XMLHttpRequest();
    }
    return ro;
}// JavaScript Document


function handleHttpResponse() 
{
	if (http.readyState == 4) 
	{
		if (http.responseText.indexOf('invalid') == -1) 
		{
			// Use the XML DOM to unpack the city and state data 
			var xmlDocument = http.responseXML;
			
			//alert(http.responseText);
			
			var topic = new Array();	
			topic=xmlDocument.getElementsByTagName("topic");
			//alert("tp"+topic);
			topicValue=topic.item(0).firstChild.nodeValue;
			//alert(topicValue);
			
			//alert(topicValue);
	
			
			
			if(topicValue=='CatList')
			{
				var xSel=new Array();
				var xVal=new Array();
				
				xSel = xmlDocument.getElementsByTagName('AttName');
				xVal = xmlDocument.getElementsByTagName('AttValue');
				xId = xmlDocument.getElementsByTagName('AttID');
				
				qId = xmlDocument.getElementsByTagName('qtyId');
				qVal = xmlDocument.getElementsByTagName('qtyVal');
							
				prcVal = xmlDocument.getElementsByTagName('lastPrc');	
				wtVal = xmlDocument.getElementsByTagName('lastWt');
				
				var q_index=document.getElementById('quantity').selectedIndex;
				var q=document.getElementById('quantity').options[q_index].text;
				
				//var q_index=document.getElementById('quantity').selectedIndex;
				//var q=document.getElementById('quantity').options[q_index].text;
				
				
					//alert(xId.length);
					
					var aname=new Array();
					for(var j=0;j<xId.length;j++)
					{	
					    
					    var theid11 = xId.item(j).firstChild.nodeValue;					
						var a_index=document.getElementById(selname+theid11).selectedIndex;
						aname[j]=document.getElementById(selname+theid11).options[a_index].text;			
					}
				
					for(var j=0;j<xId.length;j++)
					{						
						var theid1 = xId.item(j).firstChild.nodeValue;						
						document.getElementById(selname+theid1).options.length = 0;					
					}
					
					//alert(xId.length);
					 var previous_dropdown_id ='';
					 var k;
					for(var j=0;j<xId.length;j++)
					{
						
						var thetext = xSel.item(j).firstChild.nodeValue;
						var theval = xVal.item(j).firstChild.nodeValue;	
						var theid = xId.item(j).firstChild.nodeValue;
						var current_dropdown_id = theid;
						if(current_dropdown_id !=previous_dropdown_id)
						{
							k=-1;
						}
														 
						//var option = new Option(thetext,theval);
						k=k+1;
						document.getElementById(selname+theid).options[k]= new Option(thetext,theval);
						
						//alert("'"+aname[j]+"'=='"+thetext+"'");
						
						if(aname[j] == trim(thetext))
						{
						 //alert("K=="+k);	
						 document.getElementById(selname+theid).selectedIndex = k;	
						 //alert("Hi"+j);
						}
						previous_dropdown_id = current_dropdown_id ;
					}
					
					document.getElementById('quantity').options.length = 0;	
					
					for(var k=0; k<qId.length; k++)
					{
						//alert("K=="+k);
						
						var qty1 = qId.item(k).firstChild.nodeValue;
						var qty2 = qVal.item(k).firstChild.nodeValue;
						
						//var optionQ = new Option(qty2,qty1);
						document.getElementById('quantity').options[k]= new Option(qty2,qty1);
						
						
						if(q==qty2){
							
						document.getElementById('quantity').selectedIndex=k;	
						}
						
					}
					
					//doprc(document.getElementById('quantity').value,document.getElementById('p_info').value,document.getElementById('upmarkprice').value,document.getElementById('flagminusplus').value);
					
					//alert(offset);
					var prc1 = prcVal.item(0).firstChild.nodeValue;				
					var wt1 = wtVal.item(0).firstChild.nodeValue;	
					
					// var daysperce=document.getElementById('days').value ;
//				 
//				 if(daysperce!=75){
//					document.getElementById('totalprintin').value=prc12;
//				 }else
//				 {
//					 var total_after_days_perc=((parseFloat(daysperce)*parseFloat(prc1))/100);
//					 document.getElementById('totalprintin').value=total_after_days_perc;
//					 document.getElementById('pas').value=prc12;
//				 }
					
					 
					document.getElementById('baseprc').value='$'+prc1;					
					prc12=prc1.replace(',','');
					document.getElementById('totalprintin').value=prc12;
					document.getElementById('totalWt').value=wt1;
					
					
					 //var daysperce=document.getElementById('days').value ;
//				 
//				 if(daysperce!=75){
//					 
//					
//					document.getElementById('baseprc').value='$'+prc1;					
//					prc12=prc1.replace(',','');
//					
//					document.getElementById('totalprintin').value=prc12;
//					document.getElementById('totalWt').value=wt1;
//					 
//					 
//				 }else
//				 {
//					
//					 
//					 var total_after_days_perc=((parseFloat(daysperce)*parseFloat(prc1))/100);
//					 
//					 //alert(total_after_days_perc);
//					 var tot_prc_dayperc=parseFloat(prc1)+parseFloat(total_after_days_perc);
//					 alert(tot_prc_dayperc);
//					document.getElementById('baseprc').value='$'+tot_prc_dayperc;					
//					prc12=prc1.replace(',','');
//				
//					document.getElementById('totalprintin').value=prc12;
//					document.getElementById('totalWt').value=wt1;
//					 
//					 //document.getElementById('totalprintin').value=total_after_days_perc;
//					 document.getElementById('pas').value=prc12;
//					 
//				 }
//					
					
					
					
					
					doprc(document.getElementById('quantity').value,document.getElementById('p_info').value,document.getElementById('upmarkprice').value,document.getElementById('flagminusplus').value);
	 	 
		//var peritval=prc12/250;
		//var peritvalform = new NumberFormat(peritval).toFormatted();
		//document.getElementById('per_it').innerHTML=peritvalform;
		
			
			}
			
			
		}
		isWorking = false;
	}
}
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function removeSelectOption(selectId) {
 var select = document.getElementById(selectId);
 var kids = select.childNodes; 
 var numkids = kids.length; 
 for (var i = 0; i < numkids; i++) {
     
   select.removeChild(kids[i]);
  
    }
}
