function allowInteger(obj){	
	if(obj.value != ""){
		var re2digit  = /(^-?\d\d*$)/;	
		if (obj.value.search(re2digit)==-1){ //if match failed
		alert("Please enter a whole number.")
				return false;
		}		
		return true;
	}		
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function mat_options_PopUp(fabric, width, height)
{
    window.open("mat_options.php?type="+fabric+"", "Mat_Options", "toolbar=no, menubar=no, width="+width+", height="+height+", status=no, scrollbars=yes", false)
}


function openswitcher(id){
	
	//alert("id_"+id);
	if(document.getElementById("id_"+id).style.display == 'block'){
	document.getElementById("id_"+id).style.display = 'none'

	}else{	
	document.getElementById("id_fabric").style.display = 'none'
	document.getElementById("id_stich").style.display = 'none'
	document.getElementById("id_uv").style.display = 'none'
	document.getElementById("id_"+id).style.display = 'block'
	}
}


function openswitcher_rectmat(id){
	
	//alert("id_"+id);
	if(document.getElementById("id_"+id).style.display == 'block'){
	document.getElementById("id_"+id).style.display = 'none'

	}else{	
	document.getElementById("id_fabric").style.display = 'none'
	document.getElementById("id_flap").style.display = 'none'
	document.getElementById("id_stich").style.display = 'none'
	document.getElementById("id_uv").style.display = 'none'
	document.getElementById("id_"+id).style.display = 'block'
	}
}

function openswitcher_rectpad(id){

	if(document.getElementById("id_"+id).style.display == 'block'){
	document.getElementById("id_"+id).style.display = 'none'
	}else{	
	document.getElementById("id_pvcvinyl").style.display = 'none'
	document.getElementById("id_"+id).style.display = 'block'
	}
}

function openswitcher_rectpad_foam(id){
	
	if(document.getElementById("id_"+id).style.display == 'block'){
	document.getElementById("id_"+id).style.display = 'none'
	}else{	
	document.getElementById("id_foam").style.display = 'none'
	document.getElementById("id_"+id).style.display = 'block'
	}
}


function openswitcher_MatFlap(id){

	if(document.getElementById("id_"+id).style.display == 'block'){
	document.getElementById("id_"+id).style.display = 'none'

	}else{	
	document.getElementById("id_fabric").style.display = 'none'
	document.getElementById("id_flap").style.display = 'none'
	document.getElementById("id_stich").style.display = 'none'
	document.getElementById("id_uv").style.display = 'none'
	document.getElementById("id_"+id).style.display = 'block'
	setTimeout("showFlapDetail();", 1000);
/*
		if(document.getElementById("chkroundmatselect2").checked)
		{
			var obj1 = (eval(document.getElementById("chkroundmatinchft_cm_mm1")));
			var obj2 = (eval(document.getElementById("chkroundmatinchft_cm_mm2")));
			if(obj1==null && obj2==null)
			{
				setTimeout("showFlapDetail('cms');", 1000);
			}
			else
			{
				setTimeout("showFlapDetail('mms');", 1000);
			}
		}
		else
		{
			setTimeout("showFlapDetail('inch');", 1000);
		}
*/
	}


}

function openswitcher_MatStich_Rect(id){

	if(document.getElementById("id_"+id).style.display == 'block'){
	document.getElementById("id_"+id).style.display = 'none'

	}else{	
	document.getElementById("id_fabric").style.display = 'none'
	document.getElementById("id_flap").style.display = 'none'
	document.getElementById("id_stich").style.display = 'none'
	document.getElementById("id_uv").style.display = 'none'
	document.getElementById("id_"+id).style.display = 'block'
	}


}
function openswitcher_MatStich(id){

	if(document.getElementById("id_"+id).style.display == 'block'){
	document.getElementById("id_"+id).style.display = 'none'

	}else{	
	document.getElementById("id_fabric").style.display = 'none'
	document.getElementById("id_stich").style.display = 'none'
	document.getElementById("id_uv").style.display = 'none'
	document.getElementById("id_"+id).style.display = 'block'
	}


}


function showFlapDetail(){

var metricType = 'inch';
	if(document.getElementById("chkroundmatselect2").checked)
	{
		var obj1 = (eval(document.getElementById("chkroundmatinchft_cm_mm1")));
		var obj2 = (eval(document.getElementById("chkroundmatinchft_cm_mm2")));
		if(obj1==null && obj2==null)
		{
			metricType = 'cms';
		}
		else
		{
			if(obj1.checked)
			{
				metricType = 'cms';
			}
			else
			{
				metricType = 'mms';
			}
		}
	}
	else
	{
			metricType = 'inch';
	}


$.ajax({
		  url: "ajax_function.php?action=showFlapcms&metricType="+metricType,
		  cache: false,
		  success: function(html){
//			$("flap_dtl").html(html);
			document.getElementById('flap_dtl').innerHTML =html;
			//$("flap_dtl").append(html);
		  }
		});
}


function openswitcher_rebounder(id){
	
	//alert("id_"+id);
	if(document.getElementById("id_"+id).style.display == 'block'){
	document.getElementById("id_"+id).style.display = 'none'

	}else{	
	document.getElementById("id_"+id).style.display = 'block'
	}
}

function openswitcher_PvcEndCap(id){
	
	if(document.getElementById("id_"+id).style.display == 'block'){
	document.getElementById("id_"+id).style.display = 'none'
	}else{	
	
	document.getElementById("id_pvcvinyl").style.display = 'none'
	document.getElementById("id_fabric").style.display = 'none'
	document.getElementById("id_"+id).style.display = 'block'
	document.getElementById("p_focus").focus();
	
	}


}

function openswitcher_tumbletrack(id){

	
	
	if(document.getElementById("id_"+id).style.display == 'block'){
		document.getElementById("id_"+id).style.display = 'none'
	
	}else{	
	document.getElementById("id_fabric").style.display = 'none'
	document.getElementById("id_pvcvinyl").style.display = 'none'
	document.getElementById("id_"+id).style.display = 'block'
	}

}




function matselected_rectpad_foam(id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges){
		
		
		
		var mat_pid = document.Form.pid.value;		
		var prc = '';
		
		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}		
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);

		if(cl==1){			
		document.getElementById("mainidtext_"+id).innerHTML= title+ prc;		
		//document.getElementById('nn_'+optval).value = title;
		document.getElementById('foam_size').value = title;
		document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		
		calPrice(optval, pPrice, currency, cur_sign);
		openswitcher(id);
	}
}

function matselected_rectpad(id,size,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges){
		
		
		var mat_pid = document.Form.pid.value;		
		var prc = '';
		if(title=='Jet Black Fabric' || title=='None'){
			prc='<br> + '+cur_sign+' '+0;
		}
		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		if(cl==2){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = " "+title+ prc;

		}else if(cl==1){
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainid_"+id).src=srce+".jpg";

		document.getElementById("mainidtext_"+id).innerHTML= size+"-Oz "+title+ prc;
		
		document.getElementById("text_"+id).innerHTML = title+ prc;		
		document.getElementById('nn_'+optval).value = title;
		document.getElementById("coloropt").value = title;
		document.getElementById("fabric_size").value = size;
		document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		
		calPrice();
		openswitcher_rectpad(id);
	}
}

function matselected_tumbletrack(id,fab_id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges){
		
		//var pPrice =document.getElementById('Actaul_priceP').value;
		
		var mat_pid = document.getElementById("MID").value;
		
		var prc = '';		
		if(title=='Jet Black Fabric' || title=='None'){
			prc='<br> + '+cur_sign+' '+0;
		}

		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}

	
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		

		if(cl==2){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = " "+title+ prc;
		}
		if(cl==1){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainid_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = title+ prc;
		
			if(optval == 'Fabric' && title !='None'){


				
		
				document.getElementById("imgsrc_"+id).src=srce+".jpg";
				document.getElementById("mainidtext_"+id).innerHTML= title+ prc;
				document.getElementById('nn_'+optval).value = title;

				document.getElementById('pid_Fabric').value = fab_id;
				document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
			}
		calPrice();
		openswitcher_tumbletrack(id);
		}
		

}



function matselected_rebounder(id,fab_id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges){
		
		//var pPrice =document.getElementById('Actaul_priceP').value;
		
		
		var mat_pid = document.getElementById("MID").value;
		
		var prc = '';		
		if(title=='Jet Black Fabric' || title=='None'){
			prc='<br> + '+cur_sign+' '+0;
		}

		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}

	
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		

		if(cl==2){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = " "+title+ prc;
		}
		if(cl==1){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainid_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = title+ prc;
		
			if(optval == 'Fabric' && title !='None'){


				
		
				document.getElementById("imgsrc_"+id).src=srce+".jpg";
				document.getElementById("mainidtext_"+id).innerHTML= title+ prc;
				document.getElementById('nn_'+optval).value = title;

				document.getElementById('pid_Fabric').value = fab_id;
				document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
			}
		calPrice();
		openswitcher_rebounder(id);
		}
		

}

function matselected(id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges){
		
		var pPrice =document.getElementById('Actaul_priceP').value;
		
		var mat_pid = document.Form.MID.value;

		if(mat_pid=='1005' || mat_pid=='1006')
		{
			customPrice = new Array(3)
			customPrice["10"]=109.95
			customPrice["12"]=119.95
			customPrice["14"]=144.95
			var mesunit = 0;
			if (eval(document.getElementById('Length1').value) > eval(document.getElementById('Width1').value))
			{
				mesunit = document.getElementById('Length1').value;
			}
			else
			{
				mesunit = document.getElementById('Width1').value;
			}

			if(mat_pid=='1006')
			{
				if ((mesunit>0) && (mesunit<=150))
				{
					pPrice= customPrice["10"];
				}
				if ((mesunit>150) && (mesunit<=180))
				{
					pPrice = customPrice["12"];
				}
				if ((mesunit>180) && (mesunit<=230))
				{
					pPrice= customPrice["14"];
				}
			}
			else if(mat_pid=='1005')
			{
				if ((mesunit>0) && (mesunit<=130))
				{
					pPrice= customPrice["10"];
				}
				if ((mesunit>130) && (mesunit<=160))
				{
					pPrice = customPrice["12"];
				}
				if ((mesunit>160) && (mesunit<=200))
				{
					pPrice= customPrice["14"];
				}
			}
		
		}
		var prc = '';		
		if(title=='Jet Black Fabric' || title=='None'){
			prc='<br> + '+cur_sign+' '+0;
		}

		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}

		//alert('minhaj'+curr_charges);
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		if(optval == 'UVProtection' && title !='None'){
			var srce1 = (document.getElementById("Img_"+imgsrcs).src).split('.jpg');
			var srce =srce1[0];
		}


		if(cl==2){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = title+ prc;
		
		if(optval == 'UVProtection' && title =='None'){
		document.getElementById("waranty_text").innerHTML = "<span>&nbsp;</span>";
		}else if(optval == 'UVProtection' && title =='DuraClip'){
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 3-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 5-yrs.";
		}else if(optval == 'UVProtection'){
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 2-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 4-yrs.";
		}
		
		}else if(cl==1){
		
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainid_"+id).src=srce+".jpg";
		
		if(optval == 'UVProtection' && title !='None'){
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainidtext_"+id).innerHTML= title+ prc;
		}else{
		document.getElementById("mainidtext_"+id).innerHTML= title+ prc;
		}
		if(optval == 'UVProtection' && title =='None'){
		
		document.getElementById("warranty_uv").innerHTML = "<span>&nbsp;</span>";
		document.getElementById("waranty_text").innerHTML = "<span>&nbsp;</span>";
		document.getElementById("remove_uvp").value="true";
		
		
		}else if(optval == 'UVProtection' && title =='DuraClip'){
		document.getElementById("warranty_uv").innerHTML = "&nbsp;&nbsp;Adds 3-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 5-yrs.";
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 3-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 5-yrs.";
		}else if(optval == 'UVProtection'){
			
		document.getElementById("warranty_uv").innerHTML = "&nbsp;&nbsp;Adds 2-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 4-yrs.";
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 2-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 4-yrs.";
		}
		
		document.getElementById("text_"+id).innerHTML = title+ prc;
		document.getElementById('nn_'+optval).value = title;
		document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
		

		add_price_colorswatch(optval, pPrice, currency, cur_sign,title);

		if(optval == 'Fabric'){	
			var sunshield_imgTitle = document.getElementById('mainidtext_uv').innerHTML.split('<');
			
			if(document.getElementById('Img_chocolate_brown_sunshield')){
				
					document.getElementById('Img_chocolate_brown_sunshield').src= srce + '_chocolate_brown_sunshield.jpg';						
					if(document.getElementById('mainidtext_uv').innerHTML !=''){
						
						document.getElementById("mainid_uv").src=srce + '_chocolate_brown_sunshield.jpg';										
					}
			}
			if(document.getElementById('Img_army_green_sunshield')){
				
					document.getElementById('Img_army_green_sunshield').src= srce + '_army_green.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_army_green.jpg';					
					}
			}
			if(document.getElementById('Img_pacific_blue_sunshield')){
					document.getElementById('Img_pacific_blue_sunshield').src= srce + '_pacific_blue_sunshield.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_pacific_blue_sunshield.jpg';					
					}
			}
			if(document.getElementById('Img_snowball_white_sunshield')){				
					document.getElementById('Img_snowball_white_sunshield').src= srce + '_snowball_white_sunshield.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_snowball_white_sunshield.jpg';					
					}
			}			
			if(document.getElementById('Img_jet_black_sunshield')){
					document.getElementById('Img_jet_black_sunshield').src= srce + '_jet_black_sunshield.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_jet_black_sunshield.jpg';						
					}
			}
			if(sunshield_imgTitle[0]=='Jet Black SunShield'){
				document.getElementById("mainid_uv").src=srce + '_jet_black_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Pacific Blue SunShield'){
				document.getElementById("mainid_uv").src=srce + '_pacific_blue_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Chocolate Brown SunShield'){
				document.getElementById("mainid_uv").src=srce + '_chocolate_brown_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Snowball White SunShield'){
				document.getElementById("mainid_uv").src=srce + '_snowball_white_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Army Green SunShield'){
				document.getElementById("mainid_uv").src=srce + '_army_green.jpg';
			}else{
				document.getElementById("mainid_uv").src='matfabrics/defult_uv.jpg';
			}
			if(document.getElementById('remove_uv_image')){
					document.getElementById('remove_uv_image').value= document.getElementById('remove_uv_image').value;
			}
			if(document.getElementById('Img_duraclip')){
			document.getElementById('Img_duraclip').src= srce + '_duraclip.jpg';			
			
			if(document.getElementById('mainidtext_uv').innerHTML !=''){			
			
			var title_duraclip = document.getElementById("mainidtext_uv").innerHTML.split("<");			
				if(title_duraclip[0]=='None'){
					document.getElementById("mainid_uv").src='matfabrics/defult_uv.jpg';	
				}
				else{
				document.getElementById("mainid_uv").src=srce + '_duraclip.jpg';				
				}
			}
			}			
		}		
		if(title=='None'){
			document.getElementById("remove_txt").style.display="none";
		}
		if(title !='None' && optval !='Fabric'){
			document.getElementById("remove_txt").style.display="block";
		}
		openswitcher(id);
	}
	if(title == 'None'){
		
		var nonesel =document.getElementById('remove_uv_image').value;
		document.getElementById("imgsrc_"+id).src= nonesel;
		document.getElementById("mainid_"+id).src= nonesel;		
		document.getElementById("id_"+id).style.display= 'none';		
	}	
}



function matselected_rectmat(id,fabric_pid,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges){

		
		var pPrice =document.getElementById('Actaul_priceP').value;
		//alert(fabric_pid);
		var mat_pid = document.Form.MID.value;

		if(mat_pid=='1005' || mat_pid=='1006')
		{
			customPrice = new Array(3)
			customPrice["10"]=109.95
			customPrice["12"]=119.95
			customPrice["14"]=144.95
			var mesunit = 0;
			if (eval(document.getElementById('Length1').value) > eval(document.getElementById('Width1').value))
			{
				mesunit = document.getElementById('Length1').value;
			}
			else
			{
				mesunit = document.getElementById('Width1').value;
			}

			if(mat_pid=='1006')
			{
				if ((mesunit>0) && (mesunit<=150))
				{
					pPrice= customPrice["10"];
				}
				if ((mesunit>150) && (mesunit<=180))
				{
					pPrice = customPrice["12"];
				}
				if ((mesunit>180) && (mesunit<=230))
				{
					pPrice= customPrice["14"];
				}
			}
			else if(mat_pid=='1005')
			{
				if ((mesunit>0) && (mesunit<=130))
				{
					pPrice= customPrice["10"];
				}
				if ((mesunit>130) && (mesunit<=160))
				{
					pPrice = customPrice["12"];
				}
				if ((mesunit>160) && (mesunit<=200))
				{
					pPrice= customPrice["14"];
				}
			}
		
		}
		var prc = '';		
		if(title=='Jet Black Fabric' || title=='None'){
			prc='<br> + '+cur_sign+' '+0;
		}

		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}

		//alert('minhaj'+curr_charges);
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		if(optval == 'UVProtection' && title !='None'){
			var srce1 = (document.getElementById("Img_"+imgsrcs).src).split('.jpg');
			var srce =srce1[0];
		}


		if(cl==2){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = title+ prc;
		
		if(optval == 'UVProtection' && title =='None'){
		document.getElementById("waranty_text").innerHTML = "<span>&nbsp;</span>";
		}else if(optval == 'UVProtection' && title =='DuraClip'){
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 3-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 5-yrs.";
		}else if(optval == 'UVProtection'){
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 2-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 4-yrs.";
		}
		
		}else if(cl==1){
		
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainid_"+id).src=srce+".jpg";
		
		if(optval == 'UVProtection' && title !='None'){
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainidtext_"+id).innerHTML= title+ prc;
		}else{
		document.getElementById("mainidtext_"+id).innerHTML= title+ prc;
		}
		if(optval == 'UVProtection' && title =='None'){
		
		document.getElementById("warranty_uv").innerHTML = "<span>&nbsp;</span>";
		document.getElementById("waranty_text").innerHTML = "<span>&nbsp;</span>";
		document.getElementById("remove_uvp").value="true";
		
		
		}else if(optval == 'UVProtection' && title =='DuraClip'){
		document.getElementById("warranty_uv").innerHTML = "&nbsp;&nbsp;Adds 3-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 5-yrs.";
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 3-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 5-yrs.";
		}else if(optval == 'UVProtection'){
			
		document.getElementById("warranty_uv").innerHTML = "&nbsp;&nbsp;Adds 2-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 4-yrs.";
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 2-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 4-yrs.";
		}
		
		document.getElementById("text_"+id).innerHTML = title+ prc;
		document.getElementById('nn_'+optval).value = title;
		
		document.getElementById('Fabric_pid').value = fabric_pid;

		if(id=='uv'){
			document.getElementById('UVProtection_pid').value = fabric_pid;
		}else{

			document.getElementById('UVProtection_pid').value = '1002';
		}
		
		document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		
		add_price_colorswatch_rectmat(mat_pid);
		//calPrice(mat_pid);
		if(optval == 'Fabric'){	
			var sunshield_imgTitle = document.getElementById('mainidtext_uv').innerHTML.split('<');
			
			if(document.getElementById('Img_chocolate_brown_sunshield')){
				
					document.getElementById('Img_chocolate_brown_sunshield').src= srce + '_chocolate_brown_sunshield.jpg';						
					if(document.getElementById('mainidtext_uv').innerHTML !=''){
						
						document.getElementById("mainid_uv").src=srce + '_chocolate_brown_sunshield.jpg';										
					}
			}
			if(document.getElementById('Img_army_green_sunshield')){
				
					document.getElementById('Img_army_green_sunshield').src= srce + '_army_green.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_army_green.jpg';					
					}
			}
			if(document.getElementById('Img_pacific_blue_sunshield')){
					document.getElementById('Img_pacific_blue_sunshield').src= srce + '_pacific_blue_sunshield.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_pacific_blue_sunshield.jpg';					
					}
			}
			if(document.getElementById('Img_snowball_white_sunshield')){				
					document.getElementById('Img_snowball_white_sunshield').src= srce + '_snowball_white_sunshield.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_snowball_white_sunshield.jpg';					
					}
			}			
			if(document.getElementById('Img_jet_black_sunshield')){
					document.getElementById('Img_jet_black_sunshield').src= srce + '_jet_black_sunshield.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_jet_black_sunshield.jpg';						
					}
			}
			if(sunshield_imgTitle[0]=='Jet Black SunShield'){
				document.getElementById("mainid_uv").src=srce + '_jet_black_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Pacific Blue SunShield'){
				document.getElementById("mainid_uv").src=srce + '_pacific_blue_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Chocolate Brown SunShield'){
				document.getElementById("mainid_uv").src=srce + '_chocolate_brown_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Snowball White SunShield'){
				document.getElementById("mainid_uv").src=srce + '_snowball_white_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Army Green SunShield'){
				document.getElementById("mainid_uv").src=srce + '_army_green.jpg';
			}else{
				document.getElementById("mainid_uv").src='matfabrics/defult_uv.jpg';
			}
			if(document.getElementById('remove_uv_image')){
					document.getElementById('remove_uv_image').value= document.getElementById('remove_uv_image').value;
			}
			if(document.getElementById('Img_duraclip')){
			document.getElementById('Img_duraclip').src= srce + '_duraclip.jpg';			
			
			if(document.getElementById('mainidtext_uv').innerHTML !=''){			
			
			var title_duraclip = document.getElementById("mainidtext_uv").innerHTML.split("<");			
				if(title_duraclip[0]=='None'){
					document.getElementById("mainid_uv").src='matfabrics/defult_uv.jpg';	
				}
				else{
				document.getElementById("mainid_uv").src=srce + '_duraclip.jpg';				
				}
			}
			}			
		}		
		if(title=='None'){
			document.getElementById("remove_txt").style.display="none";
		}
		if(title !='None' && optval !='Fabric'){
			document.getElementById("remove_txt").style.display="block";
		}

		
		openswitcher_rectmat(id);
	}
	if(title == 'None'){
		
		var nonesel =document.getElementById('remove_uv_image').value;
		document.getElementById("imgsrc_"+id).src= nonesel;
		document.getElementById("mainid_"+id).src= nonesel;		
		document.getElementById("id_"+id).style.display= 'none';		
	}	
}


function matflapselected(id,flap_id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges)
{		
//	alert(title)
	var pPrice =document.getElementById('Actaul_priceP').value;

	var mat_pid = document.Form.MID.value;
	var prc = '';
	var mm_flag = false;
	var metric_type = document.getElementById('chkroundmatselect2').checked;
//	alert(metric_type+'   '+mat_pid);
	if(mat_pid=="1029" || mat_pid=="1030")
	{
		var metric_mm = document.Form.chkmetricmat;
//		alert(metric_mm[0].checked+'  '+metric_mm[1].checked)
		mm_flag = true;
	}
	if(title!='No Flap' && metric_type==true)
	{
		var pos = title.indexOf(" ");
		var title_new = title.substring(0, pos);
		var title_r = title.substring(pos);
		var pos1 = title_r.indexOf("Flap");
		var title_r1 = title_r.substring(pos1);
		if(mm_flag == true)
		{
			if(metric_mm[1].checked)
			{
				title_new = round_decimals((parseFloat(title_new) * 25.4), 2);
				title = title_new+ ' mms '+title_r1;
			}
			else
			{
				title_new = round_decimals((parseFloat(title_new) * 2.54), 2);
				title = title_new+ ' cms '+title_r1;
			}
		}
		else
		{
			title_new = round_decimals((parseFloat(title_new) * 2.54), 2);
			title = title_new+ ' cms '+title_r1;
		}
//		alert(title+'  '+pos+'  '+title_new+'  '+title_r+'  '+pos1+'  '+title_r1);
	}	


		if(title=='No Flap'){
			prc='<br> + '+cur_sign+' '+0;
		}

		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}

		
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		if(cl==2){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = " "+title+ prc;
		}
		if(cl==1){
		
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
	
		document.getElementById("mainid_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = title+ prc;
		
		if(optval == 'Flap' && title !='None'){

		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainidtext_"+id).innerHTML= title+ prc;
		
		document.getElementById("nn_"+optval).value = title;
		
		document.getElementById(optval+'_pid').value =flap_id ;

		
		var flapsize=title.split(" ");
		
		if(flapsize[0]=="No")
			var flapsize1 = 0;
		else
			var flapsize1 = flapsize[0];
		document.getElementById(optval+'_size').value = flapsize1;
		document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
			
		}

		
		
		if(title=='None'){

			document.getElementById("remove_txt_flap").style.display="none";
		}
		if(title !='None' ){
			if(title=="No Flap")
				document.getElementById("remove_txt_flap").style.display="none";
		
			else
				document.getElementById("remove_txt_flap").style.display="block";

		
		calPrice(mat_pid);
		openswitcher_MatFlap(id);
		}
		
		}
		if(title == 'None'){
		
		
		var nonesel =document.getElementById('remove_flap_image').value;
		
		document.getElementById("mainidtext_"+id).innerHTML= "No Flap</br>+ $ 0";

		document.getElementById("imgsrc_"+id).src= nonesel;
		
		document.getElementById("mainid_"+id).src= nonesel;	
		
		document.getElementById('nn_'+optval).value = "No Flap";
		
		document.getElementById('price_'+optval).value = "0";
		
		document.getElementById(optval+'_size').value = "0";

	
		document.getElementById("id_"+id).style.display= 'none';
		calPrice(mat_pid);
	}	
		
}
function matstichselected(id,stich_id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges)
{		
//	alert(cl)
		var pPrice =document.getElementById('Actaul_priceP').value;
	
		var mat_pid = document.Form.MID.value;
		var prc = '';
		
		
		if(title=='Normal'){
			prc='<br> + '+cur_sign+' '+0;
		}

		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}
		
		if(title=='2 Rows')
			title1 = 'Two Extra Rows';
		else if(title=='4 Rows')
			title1 = 'Four Extra Rows';
		else
			title1 = title;
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		if(cl==2){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = " "+title1+ prc;
		}

	if(cl==1){
		
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
	
		document.getElementById("mainid_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = title1+ prc;
		
		if(optval == 'Stich' && title !='None'){

		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainidtext_"+id).innerHTML= title1+ prc;
		
		document.getElementById("nn_"+optval).value = title;
		
		document.getElementById(optval+'_pid').value =stich_id ;

		
		
		//document.getElementById(optval+'_size').value = flapsize1;
		document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
			
		}

		
		
		if(title=='None'){

			document.getElementById("remove_txt_stich").style.display="none";
		}
		if(title !='None' ){
			if(title=="Normal")
				document.getElementById("remove_txt_stich").style.display="none";
		
			else
				document.getElementById("remove_txt_stich").style.display="block";

		
		getRound_Mat_Price(mat_pid);
		openswitcher_MatStich(id);
		}
		
		}
		
		if(title == 'None'){
		
		
		var nonesel =document.getElementById('remove_stich_image').value;
		
		document.getElementById("mainidtext_"+id).innerHTML= "Normal</br>+ $ 0";

		document.getElementById("imgsrc_"+id).src= nonesel;
		
		document.getElementById("mainid_"+id).src= nonesel;	
		
		document.getElementById('nn_'+optval).value = "Normal";
		
		document.getElementById('price_'+optval).value = "0";
		
		document.getElementById(optval+'_size').value = "0";
		
		document.getElementById("text_"+id).innerHTML = "Normal"+ prc;

	
		document.getElementById("id_"+id).style.display= 'none';
		getRound_Mat_Price(mat_pid);
	}	
		
}


function matstichselected_rect(id,stich_id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges)
{
			
	
		var pPrice =document.getElementById('Actaul_priceP').value;
	
		var mat_pid = document.Form.MID.value;
		var prc = '';
		
		
		if(title=='Normal'){
			prc='<br> + '+cur_sign+' '+0;
		}
		
		if(title=='2 Rows')
			title1 = 'Two Extra Rows';
		else if(title=='4 Rows')
			title1 = 'Four Extra Rows';
		else
			title1 = title;

		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}

		
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		if(cl==2){
			
			
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = " "+title1+ prc;
		}
		if(cl==1){
		
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
	
		document.getElementById("mainid_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = title1+ prc;
		
		if(optval == 'Stich' && title !='None'){

		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainidtext_"+id).innerHTML= title1+ prc;
		
		document.getElementById("nn_"+optval).value = title;
		
		document.getElementById(optval+'_pid').value =stich_id ;

		
		
		//document.getElementById(optval+'_size').value = flapsize1;
		document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
			
		}

		
		
		if(title=='None'){

			document.getElementById("remove_txt_stich").style.display="none";
		}
		if(title !='None' ){
			if(title=="Normal")
				document.getElementById("remove_txt_stich").style.display="none";
		
			else
				document.getElementById("remove_txt_stich").style.display="block";

		
		calPrice(mat_pid);
		openswitcher_MatStich_Rect(id);
		}
		
		}
		if(title == 'None'){
		
		
		var nonesel =document.getElementById('remove_stich_image').value;
		
		document.getElementById("mainidtext_"+id).innerHTML= "Normal</br>+ $ 0";

		document.getElementById("imgsrc_"+id).src= nonesel;
		
		document.getElementById("mainid_"+id).src= nonesel;	
		
		document.getElementById('nn_'+optval).value = "Normal";
		
		document.getElementById('price_'+optval).value = "0";
		
		document.getElementById(optval+'_size').value = "0";
		document.getElementById("text_"+id).innerHTML = "Normal"+ prc;

	
		document.getElementById("id_"+id).style.display= 'none';
		calPrice(mat_pid);
	}	
		

}
function matstichselected_oct(id,stich_id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges)
{		
	
		var pPrice =document.getElementById('Actaul_priceP').value;
	
		var mat_pid = document.Form.MID.value;
		var prc = '';
		
		
		if(title=='Normal'){
			prc='<br> + '+cur_sign+' '+0;
		}
		if(title=='2 Rows')
			title1 = 'Two Extra Rows';
		else if(title=='4 Rows')
			title1 = 'Four Extra Rows';
		else
			title1 = title;

		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}

		
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		if(cl==2){
			
			
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = " "+title1+ prc;
		}
		if(cl==1){
		
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
	
		document.getElementById("mainid_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = title1+ prc;
		
		if(optval == 'Stich' && title !='None'){

		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainidtext_"+id).innerHTML= title1+ prc;
		
		document.getElementById("nn_"+optval).value = title;
		
		document.getElementById(optval+'_pid').value =stich_id ;

		
		
		//document.getElementById(optval+'_size').value = flapsize1;
		document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
			
		}

		
		
		if(title=='None'){

			document.getElementById("remove_txt_stich").style.display="none";
		}
		if(title !='None' ){
			if(title=="Normal")
				document.getElementById("remove_txt_stich").style.display="none";
		
			else
				document.getElementById("remove_txt_stich").style.display="block";

		
		calPrice(mat_pid);
		openswitcher_MatStich(id);
		}
		
		}
		if(title == 'None'){
		
		
		var nonesel =document.getElementById('remove_stich_image').value;
		
		document.getElementById("mainidtext_"+id).innerHTML= "Normal</br>+ $ 0";

		document.getElementById("imgsrc_"+id).src= nonesel;
		
		document.getElementById("mainid_"+id).src= nonesel;	
		
		document.getElementById('nn_'+optval).value = "Normal";
		
		document.getElementById('price_'+optval).value = "0";
		
		document.getElementById(optval+'_size').value = "0";
		document.getElementById("text_"+id).innerHTML = "Normal"+ prc;

	
		document.getElementById("id_"+id).style.display= 'none';
		calPrice(mat_pid);
	}	
		
}

function PvcEndCap_selected(id,pvc_ID,srce,title,size,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges){
	
	
	
	var mat_pid = document.getElementById('MID').value;		
		var prc = '';
		if(title=='Jet Black Fabric' || title=='None'){
			prc='+ '+cur_sign+' '+0;
		}
		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}
		if(price != 0)
			 prc='+ '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		if(cl==2){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = " "+title+ prc;
		document.getElementById("xx").innerHTML = " "+ prc;

		}else if(cl==1){
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainid_"+id).src=srce+".jpg";

		document.getElementById("mainidtext_"+id).innerHTML= size+"-Oz "+title+"<br>"+ prc;
		
		document.getElementById("text_"+id).innerHTML = title+ prc;		
		document.getElementById('nn_'+optval).value = title;
		document.getElementById("size_"+optval).value = size;
		document.getElementById("fabric_size").value = size+'-Oz';
		document.getElementById("pid_PVC").value = pvc_ID;



		document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		
		calPrice();
		openswitcher_PvcEndCap(id);
	}
}


function PvcEndCap_selectedout(id,uv_pid,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs){
document.getElementById("imgsrc_"+id).src=document.getElementById("mainid_"+id).src;
var ttsst=document.getElementById("mainidtext_"+id).innerHTML;

	if(ttsst != '<font color="#ff0000">Please select fabric.</font>'){
		document.getElementById("text_"+id).innerHTML=ttsst;

		if(id == 'uv')
		document.getElementById("waranty_text").innerHTML = document.getElementById("warranty_"+id).innerHTML;
	}
}


function matselected_OctMat(id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs,curr_charges){
		
		var pPrice =document.getElementById('Actaul_priceP').value;
		
		var mat_pid = document.Form.MID.value;

		if(mat_pid=='1005' || mat_pid=='1006')
		{
			customPrice = new Array(3)
			customPrice["10"]=109.95
			customPrice["12"]=119.95
			customPrice["14"]=144.95
			var mesunit = 0;
			if (eval(document.getElementById('Length1').value) > eval(document.getElementById('Width1').value))
			{
				mesunit = document.getElementById('Length1').value;
			}
			else
			{
				mesunit = document.getElementById('Width1').value;
			}

			if(mat_pid=='1006')
			{
				if ((mesunit>0) && (mesunit<=150))
				{
					pPrice= customPrice["10"];
				}
				if ((mesunit>150) && (mesunit<=180))
				{
					pPrice = customPrice["12"];
				}
				if ((mesunit>180) && (mesunit<=230))
				{
					pPrice= customPrice["14"];
				}
			}
			else if(mat_pid=='1005')
			{
				if ((mesunit>0) && (mesunit<=130))
				{
					pPrice= customPrice["10"];
				}
				if ((mesunit>130) && (mesunit<=160))
				{
					pPrice = customPrice["12"];
				}
				if ((mesunit>160) && (mesunit<=200))
				{
					pPrice= customPrice["14"];
				}
			}
		
		}
		var prc = '';		
		if(title=='Jet Black Fabric' || title=='None'){
			prc='<br> + '+cur_sign+' '+0;
		}

		if(curr_charges != ''){
			curr_charges = curr_charges/100;
		}

		//alert('minhaj'+curr_charges);
		if(price != 0)
			 prc='<br> + '+cur_sign+' '+round_decimals((price*currency + price*currency*curr_charges ), 2);
		
		if(optval == 'UVProtection' && title !='None'){
			var srce1 = (document.getElementById("Img_"+imgsrcs).src).split('.jpg');
			var srce =srce1[0];
		}


		if(cl==2){
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("text_"+id).innerHTML = title+ prc;
		
		if(optval == 'UVProtection' && title =='None'){
		document.getElementById("waranty_text").innerHTML = "<span>&nbsp;</span>";
		}else if(optval == 'UVProtection' && title =='DuraClip'){
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 3-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 5-yrs.";
		}else if(optval == 'UVProtection'){
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 2-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 4-yrs.";
		}
		
		}else if(cl==1){
		
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainid_"+id).src=srce+".jpg";
		
		if(optval == 'UVProtection' && title !='None'){
		
		document.getElementById("imgsrc_"+id).src=srce+".jpg";
		document.getElementById("mainidtext_"+id).innerHTML= title+ prc;
		}else{
		document.getElementById("mainidtext_"+id).innerHTML= title+ prc;
		}
		if(optval == 'UVProtection' && title =='None'){
		
		document.getElementById("warranty_uv").innerHTML = "<span>&nbsp;</span>";
		document.getElementById("waranty_text").innerHTML = "<span>&nbsp;</span>";
		document.getElementById("remove_uvp").value="true";
		
		
		}else if(optval == 'UVProtection' && title =='DuraClip'){
		document.getElementById("warranty_uv").innerHTML = "&nbsp;&nbsp;Adds 3-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 5-yrs.";
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 3-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 5-yrs.";
		}else if(optval == 'UVProtection'){
			
		document.getElementById("warranty_uv").innerHTML = "&nbsp;&nbsp;Adds 2-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 4-yrs.";
		document.getElementById("waranty_text").innerHTML = "&nbsp;&nbsp;Adds 2-yrs to perimeter<br> &nbsp;&nbsp;warranty for total of 4-yrs.";
		}
		
		document.getElementById("text_"+id).innerHTML = title+ prc;
		document.getElementById('nn_'+optval).value = title;
		document.getElementById("price_"+optval).value = round_decimals((price*currency + price*currency*curr_charges ), 2);
		

		add_price_colorswatch_OctMat(optval, pPrice, currency, cur_sign,title);

		if(optval == 'Fabric'){	
			var sunshield_imgTitle = document.getElementById('mainidtext_uv').innerHTML.split('<');
			
			if(document.getElementById('Img_chocolate_brown_sunshield')){
				
					document.getElementById('Img_chocolate_brown_sunshield').src= srce + '_chocolate_brown_sunshield.jpg';						
					if(document.getElementById('mainidtext_uv').innerHTML !=''){
						
						document.getElementById("mainid_uv").src=srce + '_chocolate_brown_sunshield.jpg';										
					}
			}
			if(document.getElementById('Img_army_green_sunshield')){
				
					document.getElementById('Img_army_green_sunshield').src= srce + '_army_green.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_army_green.jpg';					
					}
			}
			if(document.getElementById('Img_pacific_blue_sunshield')){
					document.getElementById('Img_pacific_blue_sunshield').src= srce + '_pacific_blue_sunshield.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_pacific_blue_sunshield.jpg';					
					}
			}
			if(document.getElementById('Img_snowball_white_sunshield')){				
					document.getElementById('Img_snowball_white_sunshield').src= srce + '_snowball_white_sunshield.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_snowball_white_sunshield.jpg';					
					}
			}			
			if(document.getElementById('Img_jet_black_sunshield')){
					document.getElementById('Img_jet_black_sunshield').src= srce + '_jet_black_sunshield.jpg';					
					if(document.getElementById('mainidtext_uv').innerHTML !=''){						
					document.getElementById("mainid_uv").src=srce + '_jet_black_sunshield.jpg';						
					}
			}
			if(sunshield_imgTitle[0]=='Jet Black SunShield'){
				document.getElementById("mainid_uv").src=srce + '_jet_black_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Pacific Blue SunShield'){
				document.getElementById("mainid_uv").src=srce + '_pacific_blue_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Chocolate Brown SunShield'){
				document.getElementById("mainid_uv").src=srce + '_chocolate_brown_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Snowball White SunShield'){
				document.getElementById("mainid_uv").src=srce + '_snowball_white_sunshield.jpg';
			}else if(sunshield_imgTitle[0]=='Army Green SunShield'){
				document.getElementById("mainid_uv").src=srce + '_army_green.jpg';
			}else{
				document.getElementById("mainid_uv").src='matfabrics/defult_uv.jpg';
			}
			if(document.getElementById('remove_uv_image')){
					document.getElementById('remove_uv_image').value= document.getElementById('remove_uv_image').value;
			}
			if(document.getElementById('Img_duraclip')){
			document.getElementById('Img_duraclip').src= srce + '_duraclip.jpg';			
			
			if(document.getElementById('mainidtext_uv').innerHTML !=''){			
			
			var title_duraclip = document.getElementById("mainidtext_uv").innerHTML.split("<");			
				if(title_duraclip[0]=='None'){
					document.getElementById("mainid_uv").src='matfabrics/defult_uv.jpg';	
				}
				else{
				document.getElementById("mainid_uv").src=srce + '_duraclip.jpg';				
				}
			}
			}			
		}		
		if(title=='None'){
			document.getElementById("remove_txt").style.display="none";
		}
		if(title !='None' && optval !='Fabric'){
			document.getElementById("remove_txt").style.display="block";
		}
		openswitcher(id);
	}
	if(title == 'None'){
		
		var nonesel =document.getElementById('remove_uv_image').value;
		document.getElementById("imgsrc_"+id).src= nonesel;
		document.getElementById("mainid_"+id).src= nonesel;		
		document.getElementById("id_"+id).style.display= 'none';		
	}	
}


function matselectedout(id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs){
document.getElementById("imgsrc_"+id).src=document.getElementById("mainid_"+id).src;
var ttsst=document.getElementById("mainidtext_"+id).innerHTML;

	if(ttsst != '<font color="#ff0000">Please select fabric.</font>'){
		document.getElementById("text_"+id).innerHTML=ttsst;

		if(id == 'uv')
		document.getElementById("waranty_text").innerHTML = document.getElementById("warranty_"+id).innerHTML;
	}
}


function matflapselectedout(id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs){

document.getElementById("imgsrc_"+id).src=document.getElementById("mainid_"+id).src;
var ttsst=document.getElementById("mainidtext_"+id).innerHTML;
	
	if(ttsst != '<font color="#ff0000">Please select fabric.</font>'){
		document.getElementById("text_"+id).innerHTML=ttsst;

		if(id == 'uv')
		document.getElementById("waranty_text").innerHTML = document.getElementById("warranty_"+id).innerHTML;
	}
	
}

function matstichselectedout(id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs){

document.getElementById("imgsrc_"+id).src=document.getElementById("mainid_"+id).src;
var ttsst=document.getElementById("mainidtext_"+id).innerHTML;
	
	if(ttsst != '<font color="#ff0000">Please select fabric.</font>'){
		document.getElementById("text_"+id).innerHTML=ttsst;

		if(id == 'uv')
		document.getElementById("waranty_text").innerHTML = document.getElementById("warranty_"+id).innerHTML;
	}
	
}

function matselectedout_tumbletrack(id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs){

document.getElementById("imgsrc_"+id).src=document.getElementById("mainid_"+id).src;
var ttsst=document.getElementById("mainidtext_"+id).innerHTML;
	
	if(ttsst != '<font color="#ff0000">Please select fabric.</font>'){
		document.getElementById("text_"+id).innerHTML=ttsst;

		
	}
}
function matselectedout_rebounder(id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs){

document.getElementById("imgsrc_"+id).src=document.getElementById("mainid_"+id).src;
var ttsst=document.getElementById("mainidtext_"+id).innerHTML;
	
	if(ttsst != '<font color="#ff0000">Please select fabric.</font>'){
		document.getElementById("text_"+id).innerHTML=ttsst;

		
	}
}
function matselectedout_foam(id,srce,title,price,optval,cl,pPrice,currency, cur_sign,imgsrcs){
var ttsst=document.getElementById("mainidtext_"+id).innerHTML;	
}


function add_price_colorswatch_rectmat(mat_pid)
{
	

	calPrice(mat_pid);

	/*if(cur_sign == '$'){
		var prAr= pPrice.split('$');
		var totPrice = prAr[1];	
		
		
	}else{		
		var totPrice = pPrice.substring(4);
		
		
	}
		
		if(document.getElementById('nn_Fabric').value != ''){
			
			totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById("price_Fabric").value));		
			document.getElementById('price').value=totPrice;
		}
		
		if(document.getElementById('nn_UVProtection').value != ''){
			
			totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById("price_UVProtection").value));		
			document.getElementById('price').innerHTML=totPrice;
		}
	
	qty = document.getElementById('quantity').value;	
	if(qty == '')
	{
		qty = 1;
	}
	
	document.getElementById('price').innerHTML = cur_sign+""+round_decimals((totPrice * qty), 2);*/
}






function add_price_colorswatch(optval, pPrice,currency, cur_sign, title)
{	
	var pid =  document.getElementById('MID').value;
	getRound_Mat_Price(pid);
	
/*	if(cur_sign == '$'){
		var prAr= pPrice.split('$');
		var totPrice = prAr[1];	
		
		
	}else{		
		var totPrice = pPrice.substring(4);
		
		
	}
		if(document.getElementById('nn_Fabric').value != ''){
			
			totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById("price_Fabric").value));		
			document.getElementById('price').value=totPrice;
		}
		
		if(document.getElementById('nn_UVProtection').value != ''){
			
			totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById("price_UVProtection").value));		
			document.getElementById('price').innerHTML=totPrice;
		}
	
	qty = document.getElementById('quantity').value;	
	if(qty == '')
	{
		qty = 1;
	}
	
	document.getElementById('price').innerHTML = cur_sign+""+round_decimals((totPrice * qty), 2);
	*/
}

function add_price_colorswatch_OctMat(optval, pPrice,currency, cur_sign, title)
{	
	var pid =  document.getElementById('MID').value;
	calPrice(pid);
	
/*if(cur_sign == '$'){
		var prAr= pPrice.split('$');
		var totPrice = prAr[1];	
		
		
	}else{		
		var totPrice = pPrice.substring(4);
		
		
	}
		if(document.getElementById('nn_Fabric').value != ''){
			
			totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById("price_Fabric").value));		
			document.getElementById('price').value=totPrice;
		}
		
		if(document.getElementById('nn_UVProtection').value != ''){
			
			totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById("price_UVProtection").value));		
			document.getElementById('price').innerHTML=totPrice;
		}
	
	qty = document.getElementById('quantity').value;	
	if(qty == '')
	{
		qty = 1;
	}
	
	document.getElementById('price').innerHTML = cur_sign+""+round_decimals((totPrice * qty), 2);*/
	
}



function chk_fabric(type){	
	
	if(document.getElementById("mainidtext_"+type).innerHTML=='' && type=='fabric'){
		document.getElementById("mainidtext_"+type).innerHTML="<font color='#ff0000'>Please select fabric.</font>";
	}
}

function round_decimals(original_number, decimals) 
{
	var result1 = original_number * Math.pow(10, decimals)
	var result2 = Math.round(result1)
	var result3 = result2 / Math.pow(10, decimals)
	return pad_with_zeros(result3, decimals)
}
function pad_with_zeros(rounded_value, decimal_places) 
{
	var value_string = rounded_value.toString()
    var decimal_location = value_string.indexOf(".")
    if (decimal_location == -1) 
	{
		decimal_part_length = 0
        value_string += decimal_places > 0 ? "." : ""
    }
    else 
	{
        decimal_part_length = value_string.length - decimal_location - 1
    }
    var pad_total = decimal_places - decimal_part_length
    if (pad_total > 0) 
	{
        for (var counter = 1; counter <= pad_total; counter++)
            value_string += "0"
	}
    return value_string
}


// fuction to validate decimals
function validate_decimal(ElementId)
{
//alert("aaaaa");
var varValue = document.getElementById(ElementId).value;
if(isNaN(varValue))
{
alert("Please enter numeric data");
document.getElementById (ElementId).value=""; document.getElementById(ElementId).focus();
return false;
}

else
{


if(/\./.test(varValue)){
	var arrParts = varValue.split('.');

	if(arrParts[1].length > 3)
	{
		var temp_str = arrParts[1].toString(); 
		var temp_char=temp_str.substr(0,1)
		

		var a = parseFloat(arrParts[1])/10;

		if(temp_char=='0')
			a = '0'+a;
		document.getElementById(ElementId).value = parseFloat(arrParts[0]+"."+a);
	}
}
	

}

return true;

}
