function blinkIt() {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags('blink').length;i++){
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}

//setInterval('blinkIt()',500)
/* ==== Get Interior, exterior colors, brands, style by selected vertical id========= */ 
var selected_id = new Array();
var selected_brand = new Array();
var selected_brandname = new Array();
var optionproductrelation = new Array();
var alloptions = new Array(); //For achieving options selected issue.
var allpopularoptions = new Array(); //For achieving options selected issue.
var all_product_rows = new Array(); //For achieving options selected issue.
var picture_image_set = "";
var performance_data_set = "";
var warranty_set = "";
var how_to_measure_set = "";
var how_to_install_set = "";
var testimonials_set = "";
var sort_by = "";
var bHarshal = "";

function get_data(){
	//alert("GET DATA");
	vertical_id = $('vertical').value;
	interior_color = $('interior_colors').value;
	exterior_color = $('exterior_colors').value;
	brand_id = $('brands').value;
		
	new ajax('ajax.php', {postBody: 'method=get_data&vertical_id='+vertical_id+'&interior_color='+interior_color+'&exterior_color='+exterior_color+'&brand_id='+brand_id, onComplete: get_data_callback});
	$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	$("WAIT").toggle();
	$("COVER").toggle();
	$("COVER").style.height = Screen.getDocumentHeight()+'px';
}
function get_data_callback(request){
	/* ADDED BY VISHAL SHAH */
	if($('vertical').value == 11){
			document.getElementById('door_window').innerHTML = "Window";
	}else{
		document.getElementById('door_window').innerHTML = "Door";
	}
	/* ADDED BY VISHAL SHAH */
	$("WAIT").toggle();
	$("COVER").toggle();
	//alert("GET DATA CALLBACK : " + request.responseText);
	vertical_cmb = $('vertical');
	int_color_cmb = $('interior_colors');
	ext_color_cmb = $('exterior_colors');
	brand_cmb = $('brands');
	style_cmb = $('styles');
	callout_cmb = $('callouts');
	
	int_color_index = int_color_cmb.selectedIndex;
	ext_color_index = ext_color_cmb.selectedIndex;
		
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			int_cmb = int_color_cmb.options.length;
			for(i=0; i< int_cmb; i++){
				int_color_cmb.options[0] = null;
			}
			ext_cmb = ext_color_cmb.options.length;
			for(i=0; i< ext_cmb; i++){
				ext_color_cmb.options[0] = null;
			}
			br_cmb = brand_cmb.options.length;
			for(i=0; i< br_cmb; i++){
				brand_cmb.options[0] = null;
			}
			st_cmb = style_cmb.options.length;
			for(i=0; i< st_cmb; i++){
				style_cmb.options[0] = null;
			}
			co_cmb = callout_cmb.options.length;
			for(i=0; i< co_cmb; i++){
				callout_cmb.options[0] = null;
			}
			if(response.RESULT=="OK"){
				if(response.INTERIOR_ID.length>0){
					for(i=0; i<response.INTERIOR_ID.length; i++){
						var optn = new Option();
						optn.value = response.INTERIOR_ID[i];
						optn.text = response.INTERIOR_VALUES[i];
						if(response.INTERIOR_VALUES[i] == "White")
							optn.selected = " Selected";
						int_color_cmb.options[int_color_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = 0;
					optn.text = "No Color Found";
					int_color_cmb.options[int_color_cmb.options.length] = optn;
				}
				if(response.EXTERIOR_ID.length>0){
					for(i=0; i<response.EXTERIOR_ID.length; i++){
						var optn = new Option();
						optn.value = response.EXTERIOR_ID[i];
						optn.text = response.EXTERIOR_VALUES[i];
						if(response.EXTERIOR_VALUES[i] == "White")
							optn.selected = " Selected";
						ext_color_cmb.options[ext_color_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = 0;
					optn.text = "No Color Found";
					ext_color_cmb.options[ext_color_cmb.options.length] = optn;
				}
				if(response.BRAND_ID.length>0){
					if(response.BRAND_ID.length > 1){
						var optn = new Option();
						optn.value = '0';
						optn.text = 'All Brands';
						brand_cmb.options[brand_cmb.options.length] = optn;
					}
					for(i=0; i<response.BRAND_ID.length; i++){
						var optn = new Option();
						optn.value = response.BRAND_ID[i];
						optn.text = response.BRAND_VALUES[i];
						brand_cmb.options[brand_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = 0;
					optn.text = "No Brand Found";
					brand_cmb.options[brand_cmb.options.length] = optn;
				}
				if(response.STYLE_ID.length>0){
					for(i=0; i<response.STYLE_ID.length; i++){
						var optn = new Option();
						optn.value = response.STYLE_ID[i];
						optn.text = response.STYLE_VALUES[i];
						style_cmb.options[style_cmb.options.length] = optn;
					}
				}else{
						var optn = new Option();
						optn.value = 0;
						optn.text = "No Style Found";
						style_cmb.options[style_cmb.options.length] = optn;
				}
				if(response.CALLOUT != ""){
					if($('vertical').value == 11)
						var default_val = '24W36H';
					else if($('vertical').value == 7)
						var default_val = '16W46H';
					else	 
						var default_val = '72W80H';	
					$('callout').style.display = "block";
					$('nocallout').style.display = "none";
					
					//alert(response.CALLOUT.length);
					if(response.CALLOUT.length>0){
						for(i=0; i<response.CALLOUT.length; i++){
							var optn = new Option();
							optn.value = response.CALLOUT[i];
							optn.text = response.CALLOUT[i];
							if(optn.value == default_val)
								optn.selected = " Selected";
							/*if(i == 0)
								optn.selected = " Selected";*/
							callout_cmb.options[callout_cmb.options.length] = optn;
						}
					}else{
						var optn = new Option();
						optn.value = 0;
						optn.text = "No Callout Found";
						callout_cmb.options[callout_cmb.options.length] = optn;
					}
					//setWHValueFromCallOut(response.CALLOUT[0]);
					setWHValueFromCallOut(default_val);
					get_price_list();
/*					var firstCallout = response.CALLOUT[0];
					var partCallout = firstCallout.split("W");
					var w = partCallout[0];
					var partCalloutH = partCallout[1].split("H");
					var h = partCalloutH[0];
					$('width').value = w;
					$('height').value = h;
					$('widthTempToShow').innerHTML = w;
					$('heightTempToShow').innerHTML = h;
*/				}else{
					$('callout').style.display = "none";
					$('nocallout').style.display = "block";
					$('width').value = 24;
					$('height').value = 35;
					get_price_list();
				}
			}
		}
	}
}
function set_style_using_size(){
	//alert("SET STYLE USING SIZE");
	vertical_id = $('vertical').value;
	width_val = $('width').value;
	width_inch_val = $('width_inch').value;
	height_val = $('height').value;
	height_inch_val = $('height_inch').value;
		
	new ajax('ajax.php', {postBody: 'method=set_style_using_size&vertical_id='+vertical_id+'&width_val='+width_val+'&width_inch_val='+width_inch_val+'&height_val='+height_val+'&height_inch_val='+height_inch_val, onComplete: set_style_using_size_callback});
	$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	$("WAIT").toggle();
	$("COVER").toggle();
	$("COVER").style.height = Screen.getDocumentHeight()+'px';
}
function set_style_using_size_callback(request){
	$("WAIT").toggle();
	$("COVER").toggle();
	//alert("SET STYLE USING SIZE CALLBACK : "+request.responseText);
	style_cmb = $('styles');
	var cur_style = style_cmb.value;	
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			st_cmb = style_cmb.options.length;
			for(i=0; i< st_cmb; i++){
				style_cmb.options[0] = null;
			}
			if(response.RESULT=="OK"){
				if(response.STYLE_ID.length>0){
					for(i=0; i<response.STYLE_ID.length; i++){
						var optn = new Option();
						optn.value = response.STYLE_ID[i];
						optn.text = response.STYLE_VALUES[i];
						if(response.STYLE_ID[i] == cur_style)
							optn.selected = " Selected";
						style_cmb.options[style_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = 0;
					optn.text = "No Style Found";
					style_cmb.options[style_cmb.options.length] = optn;
				}
			}
		}
	}
	get_price_list();
}
/* ======================================================================== */
function set_style_using_callout(){
	//alert("SET STYLE USING CALLOUT");
	vertical_id = $('vertical').value;
	width_val = $('width').value;
	width_inch_val = $('width_inch').value;
	height_val = $('height').value;
	height_inch_val = $('height_inch').value;
		
	new ajax('ajax.php', {postBody: 'method=set_style_using_callout&vertical_id='+vertical_id+'&width_val='+width_val+'&width_inch_val='+width_inch_val+'&height_val='+height_val+'&height_inch_val='+height_inch_val, onComplete: set_style_using_callout_callback});
	$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	$("WAIT").toggle();
	$("COVER").toggle();
	$("COVER").style.height = Screen.getDocumentHeight()+'px';
}
function set_style_using_callout_callback(request){
	//alert(request);
	$("WAIT").toggle();
	$("COVER").toggle();
	//alert("SET STYLE USING CALLOUT CALLBACK : "+request.responseText);
	int_color_cmb = $('interior_colors');
	ext_color_cmb = $('exterior_colors');
	style_cmb = $('styles');
	int_color_index = int_color_cmb.selectedIndex;
	ext_color_index = ext_color_cmb.selectedIndex;
	var cur_style = style_cmb.value;	
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			int_cmb = int_color_cmb.options.length;
			for(i=0; i< int_cmb; i++){
				int_color_cmb.options[0] = null;
			}
			ext_cmb = ext_color_cmb.options.length;
			for(i=0; i< ext_cmb; i++){
				ext_color_cmb.options[0] = null;
			}
			st_cmb = style_cmb.options.length;
			for(i=0; i< st_cmb; i++){
				style_cmb.options[0] = null;
			}
			if(response.RESULT=="OK"){
				if(response.INTERIOR_ID.length>0){
					for(i=0; i<response.INTERIOR_ID.length; i++){
						var optn = new Option();
						optn.value = response.INTERIOR_ID[i];
						optn.text = response.INTERIOR_VALUES[i];
						if(response.INTERIOR_VALUES[i] == "White")
							optn.selected = " Selected";
						int_color_cmb.options[int_color_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = 0;
					optn.text = "No Color Found";
					int_color_cmb.options[int_color_cmb.options.length] = optn;
				}
				if(response.EXTERIOR_ID.length>0){
					for(i=0; i<response.EXTERIOR_ID.length; i++){
						var optn = new Option();
						optn.value = response.EXTERIOR_ID[i];
						optn.text = response.EXTERIOR_VALUES[i];
						if(response.EXTERIOR_VALUES[i] == "White")
							optn.selected = " Selected";
						ext_color_cmb.options[ext_color_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = 0;
					optn.text = "No Color Found";
					ext_color_cmb.options[ext_color_cmb.options.length] = optn;
				}
				if(response.STYLE_ID.length>0){
					for(i=0; i<response.STYLE_ID.length; i++){
						var optn = new Option();
						optn.value = response.STYLE_ID[i];
						optn.text = response.STYLE_VALUES[i];
						if(response.STYLE_ID[i] == cur_style)
							optn.selected = " Selected";
						style_cmb.options[style_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = 0;
					optn.text = "No Style Found";
					style_cmb.options[style_cmb.options.length] = optn;
				}
			}
		}
	}
	get_price_list();
}
/* ======================================================================== */
/* ============ Get Exterior Colors list from selected interior color ========= */
function get_exterior_colors(){
	//alert("GET EXTERIOR COLORS");
	interior_color = $('interior_colors').value;
	vertical_id = $('vertical').value;
	
	new ajax ('ajax.php', {postBody: 'method=get_exterior_colors&int_color='+interior_color+'&vertical_id='+vertical_id, onComplete: get_exterior_colors_callback });
	$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	$("WAIT").toggle();
	$("COVER").toggle();
	$("COVER").style.height = Screen.getDocumentHeight()+'px';
}
function get_exterior_colors_callback(request){
	$("WAIT").toggle();
	$("COVER").toggle();
	combo = $('exterior_colors');
	brand_cmb = $('brands');
	//alert("GET EXTERIOR COLORS : "+request.responseText);
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			current_option = combo.options.length;
			for(i=0; i< current_option; i++){
				combo.options[0] = null;
			}
			brand_cmb_option = brand_cmb.options.length;
			for(i=0; i< brand_cmb_option; i++){
				brand_cmb.options[0] = null;
			}
			if(response.RESULT=="OK"){
				for(i=0; i<response.EXTERIOR_ID.length; i++){
					var optn = new Option();
					optn.value = response.EXTERIOR_ID[i];
					optn.text = response.EXTERIOR_VALUES[i];
					if(response.EXTERIOR_VALUES[i] == "White")
							optn.selected = " Selected";
					combo.options[combo.options.length] = optn;
				}
				if(response.BRAND_ID.length > 0){
					if(response.BRAND_ID.length > 1){
						var optn = new Option();
						optn.value = '0';
						optn.text = 'All Brands';
						brand_cmb.options[brand_cmb.options.length] = optn;
					}
					for(i=0; i<response.BRAND_ID.length; i++){
						var optn = new Option();
						optn.value = response.BRAND_ID[i];
						optn.text = response.BRAND_LIST[i];
						brand_cmb.options[brand_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = "";
					optn.text = "No Brand Found";
					brand_cmb.options[brand_cmb.options.length] = optn;
				}
			}
		}
	}
	get_price_list();
}
/* ======================================================================== */
/* =================== Get Brand list from interior and exterior colors  =========== */
function get_brand_list(){
	//alert("GET BRAND");
	interior_color = $('interior_colors').value;
	exterior_color = $('exterior_colors').value;
	vertical_id = $('vertical').value;
	
	new ajax ('ajax.php', {postBody: 'method=get_brand_name&int_color='+interior_color+'&ext_color='+exterior_color+'&vertical_id='+vertical_id, onComplete: get_brand_list_callback});
	$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	$("WAIT").toggle();
	$("COVER").toggle();
	$("COVER").style.height = Screen.getDocumentHeight()+'px';
}
function get_brand_list_callback(request){
	$("WAIT").toggle();
	$("COVER").toggle();
	combo = $('brands');
	//alert("GET BRAND CALLBACK : "+request.responseText);
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			current_option = combo.options.length;
			for(i=0; i< current_option; i++){
				combo.options[0] = null;
			}
			if(response.RESULT=="OK"){
				if(response.BRAND_ID.length > 0){
					if(response.BRAND_ID.length > 1){
						var optn = new Option();
						optn.value = '0';
						optn.text = 'All Brands';
						combo.options[combo.options.length] = optn;
					}
					for(i=0; i<response.BRAND_ID.length; i++){
						var optn = new Option();
						optn.value = response.BRAND_ID[i];
						optn.text = response.BRAND_LIST[i];
						combo.options[combo.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = "";
					optn.text = "No Brand Found";
					combo.options[combo.options.length] = optn;
				}
			}
		}
	}
	get_price_list();
}
/* =============================================================================== */
/* ============= get the list of the produt and display in the middle area =========== */
function get_price_list(){
	//alert("GET PRICE LIST");
	state_val = $('state').value;
	vertical_id = $('vertical').value;
	interior_color = $('interior_colors').value;
	exterior_color = $('exterior_colors').value;
	brand_id= $('brands').value;
	app_id = $('app').value;
	style_id = $('styles').value;
	width_val = $('width').value;
	width_inch_val = $('width_inch').value;
	height_val = $('height').value;
	height_inch_val = $('height_inch').value;
	min_price_val = $('demo_from').value;
	max_price_val = $('demo_to').value;
	// FOr Doors Storms and other have Replacement only so no need to so New product
	if(vertical_id == '2' || vertical_id == '9'){ //vertical_id == '3' || 
		$("app").value="1";
		$("app").disabled="disabled";
	}else{
		$("app").disabled="";	
	}	
	if(state_val==0){
		alert('Please select State Value');
		return false;
	}else{
		takealloptions();
		new ajax ('ajax.php', {postBody: 'method=get_product&vertical_id='+vertical_id+'&interior_color='+interior_color+'&exterior_color='+exterior_color+'&brand_id='+brand_id+'&app_id='+app_id+'&style_id='+style_id+'&width='+width_val+'&width_inch='+width_inch_val+'&height='+height_val+'&height_inch='+height_inch_val+'&state_id='+state_val+'&min_price_val='+min_price_val+'&max_price_val='+max_price_val , onComplete: get_price_list_callback , userVariable:Array(width_val,height_val,interior_color,exterior_color,min_price_val,max_price_val,width_inch_val,height_inch_val,vertical_id)});
		$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
		$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
		$("WAIT").toggle();
		$("COVER").toggle();
		$("COVER").style.height = Screen.getDocumentHeight()+'px';
	}
}
function get_price_list_callback(request , variable){
	$("WAIT").toggle();
	$("COVER").toggle();
	//alert("GET PRICE LIST CALLBACK : "+request.responseText);
	var width = variable[0];
	var height = variable[1];
	var interior_color = variable[2];
	var exterior_color = variable[3];
	// PRICES FROM SLIDER
	var min_price = variable[4];
	var max_price = variable[5];
	var width_inch = variable[6];
	var height_inch = variable[7];
	var vertical_id = variable[8];	
	var final_width = parseFloat(width)+parseFloat(width_inch);
	var final_height = parseFloat(height)+parseFloat(height_inch);
	var temp_maximum_price=0;
	var temp_minimum_price=0;
	var totalproductloop=0;
	var fraction_final_width = convertToFraction(final_width);
	var fraction_final_height = convertToFraction(final_height);
	/**** variable to display tab in option popup ***/
	/*wholesale = false;
	crystal = false;
	simonton = false;
	lang = false;*/
	/***********************************************/
	$('product_data').update("");
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			if(response.RESULT=="OK"){	
				// SET DYNAMIC SIZE FOR THE PRODUCT COMMENTED ON 27_08_2010
				/*combo_w = $('width');//alert(" combo_w >> "+response.DYN_MIN_WIDTH+" >> "+response.DYN_MAX_WIDTH+" >> "+response.ORIG_WIDTH);
				current_option_w = combo_w.options.length;
				for(i_cmb_w=0; i_cmb_w < current_option_w; i_cmb_w++){
					combo_w.options[0] = null;
				}
				for(i_cmb_w=parseInt(response.DYN_MIN_WIDTH); i_cmb_w <= parseInt(response.DYN_MAX_WIDTH); i_cmb_w++){
					var optn_w = new Option();
					optn_w.value = i_cmb_w;
					optn_w.text = i_cmb_w;
					if(i_cmb_w == parseInt(response.ORIG_WIDTH))
							optn_w.selected = " Selected";
					combo_w.options[combo_w.options.length] = optn_w;
				}
				combo_h = $('height');//alert(" combo_h >> "+response.DYN_MIN_HEIGHT+" >> "+response.DYN_MAX_HEIGHT+" >> "+response.ORIG_HEIGHT);
				current_option_h = combo_h.options.length;
				for(i_cmb_h=0; i_cmb_h < current_option_h; i_cmb_h++){
					combo_h.options[0] = null;
				}
				for(i_cmb_h=parseInt(response.DYN_MIN_HEIGHT); i_cmb_h <= parseInt(response.DYN_MAX_HEIGHT); i_cmb_h++){
					var optn_h = new Option();
					optn_h.value = i_cmb_h;
					optn_h.text = i_cmb_h;
					if(i_cmb_h == parseInt(response.ORIG_HEIGHT))
							optn_h.selected = " Selected";
					combo_h.options[combo_h.options.length] = optn_h;
				}*/
				///////////////////////////////////////////
				// MAKE NONE FOR DYNAMIC TAB 
				var num_total_brand_in_table = parseInt(response.ALL_BRAND_OF_TABLE.length) + 1;
				for(q = 1; q < num_total_brand_in_table; q++)
				{
					if(($(q+'__1') != null && $(q+'__2') != null) || ($(q+'__1') == "block" && $(q+'__2') == "block"))
					{	
						$(q+'__1').style.display = "none";
						$(q+'__2').style.display = "none";
					}
				}
				var brand_name_exist = new Array();
					for(iloop=0; iloop<response.ALL_BRAND.length; iloop++){
						var brand_name = response.ALL_BRAND[iloop].name;//alert(response.ALL_BRAND[i].id);
						brand_name_exist[brand_name.toLowerCase()] = brand_name.toLowerCase();//alert(brand_name_exist);
						brand_name_exist[brand_name.toLowerCase()] = false;//alert(brand_name_exist);
					}
					// Reset the Global Array
					optionproductrelation = new Array();
					for(x=0; x<response.HP.length; x++){
						optionproductrelation[x] = response.HP[x];
						//var brand_name = response.ALL_BRAND[i].name;
						//brand_name_exist[brand_name.toLowerCase()] = brand_name.toLowerCase();
						//brand_name_exist[brand_name.toLowerCase()] = false;
					}
				picture_image_set = "<link href=\"thumbnailviewer.css\" rel=\"stylesheet\" type=\"text/css\"><script src=\"thumbnailviewer.js\" language=\"javascript\" type=\"text/javascript\"></script>";
				performance_data_set = "[";
				warranty_set = "[";
				how_to_measure_set = "[";
				how_to_install_set = "[";
				testimonials_set = "[";

				var tempHtml = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
				if(!Object.isArray(response.PRODUCT)){ 
					selected_brand = new Array();
					formdata = new Array();
					var m=0;
					var h=0;
					var i=0;
					var z=0;
					var dynamictabid="";
					//var x=0;
					selected_id = new Array();
					for(var prop in response.PRODUCT){
						//var selected_brand = new Array();
						selected_brand[h]=prop;//h++;
						for(i=0; i<response.PRODUCT[prop].length; i++){
							id= response.PRODUCT[prop][i].id;
							vsku= response.PRODUCT[prop][i].vsku; 
							image= response.PRODUCT[prop][i].vimage;
							brand_image= response.PRODUCT[prop][i].brand_image;
							best_flag= response.PRODUCT[prop][i].best_flag;
							prfm_data= response.PRODUCT[prop][i].prfm_data;
							var parts = prfm_data.split('.');
							if(parts[parts.length-1] == "pdf"){
								var prfm_datafinal = '<a href="documents/'+prfm_data+'" onclick="return GB_showCenter(\'Performance Data\', this.href, 600, 700)">';
								var pfmd = 'documents/'+prfm_data;
							}else{
								var prfm_datafinal = '<a href="images/vinyl-windows-pictures/'+prfm_data+'" onclick="return GB_showImage(\'Performance Data\', this.href)">';
								var pfmd = 'images/vinyl-windows-pictures/'+prfm_data;
							}
							warranty= response.PRODUCT[prop][i].warranty;
							measure= response.PRODUCT[prop][i].measure;
							install= response.PRODUCT[prop][i].install;
							testimonial= response.PRODUCT[prop][i].testimonial;
							brochure= response.PRODUCT[prop][i].brochure;
							vdesc= response.PRODUCT[prop][i].vdesc;
							vproduct = response.PRODUCT[prop][i].vproduct;						
							ratings = response.PRODUCT[prop][i].ratings;
							quality1 = response.PRODUCT[prop][i].quality;
							price = response.PRODUCT[prop][i].price;
							iaddinfo = response.PRODUCT[prop][i].iaddinfo; 
							/////After changing the lookup of the add to cart display list like box with discount
							base_price = parseFloat(response.PRODUCT[prop][i].base_price)+parseFloat(response.PRODUCT[prop][i].shipping_charge);
							online_disc_price = (price/9).toFixed(2);
							our_disc_price = (base_price - online_disc_price - price).toFixed(2);
							// FOR CALLOUT VERTICAL ID 3 & 7
							framesizewidth = response.PRODUCT[prop][i].framesizewidth;
							framesizeheight = response.PRODUCT[prop][i].framesizeheight;
							roughopeningwidth = response.PRODUCT[prop][i].roughopeningwidth;
							roughopeningheight = response.PRODUCT[prop][i].roughopeningheight;
							// SET MINIMUM PRICE AND MAXIMUM PRICE FOR SLIDER
							if((parseFloat(price) >= parseFloat(temp_maximum_price)) || temp_maximum_price == 0){
								temp_maximum_price = parseFloat(price);
							}
							if((parseFloat(price) <= parseFloat(temp_minimum_price)) || temp_minimum_price == 0){
								temp_minimum_price = parseFloat(price);
							}
							// FOR SHOWING PROJECTION RANGE
							proj_range = response.PRODUCT[prop][i].proj_range;
							if(proj_range != "no" && proj_range != "0" && proj_range != "" && proj_range != " "){
								projection_range = "<b>Projection Range:</b> "+proj_range;
							}else{
								projection_range = "";
							}
							brand_id = response.PRODUCT[prop][i].brand_id;
							brand_name = response.PRODUCT[prop][i].brand_name;
							selected_id[z] = prop+":"+id+":"+price+":"+base_price;
							z++;
							// FOR SHOWING THE MULTIPLE IMAGE AND PDFS
							//var image_set = [{'caption': 'Flower', 'url': 'http://static.flickr.com/119/294309231_a3d2a339b9.jpg'},{'caption': 'Nice waterfall', 'url': 'http://www.widerange.org/images/large/plitvicka.jpg'}];
							//picture_image_set += "{'caption': '"+vsku+"', 'url': '../images/vinyl-windows-pictures/"+image+"'}, ";
							picture_image_set += '<a href="images/vinyl-windows-pictures/'+image+'" rel="thumbnail" title="'+vsku+'"><img src="images/vinyl-windows-pictures/'+image+'" style="width: 50px; height: 50px; border:0" /></a>';
							performance_data_set += "{'caption': '"+vsku+"', 'url': '../"+pfmd+"'}, ";
							warranty_set += "{'caption': '"+vsku+"', 'url': '../documents/"+warranty+"'}, ";
							how_to_measure_set += "{'caption': '"+vsku+"', 'url': '../documents/"+measure+"'}, ";
							how_to_install_set += "{'caption': '"+vsku+"', 'url': '../documents/"+install+"'}, ";
							testimonials_set += "{'caption': '"+vsku+"', 'url': '../documents/"+testimonial+"'}, ";

							if(m%2 == 0){
								bg = '';				
							}else{
								bg = '';						
							}
							//if((parseFloat(price) >= parseFloat(min_price)) && (parseFloat(price) <= parseFloat(max_price))){ // this if is used for display record as per price. 
							//dynamictabid += brand_id+"::";
							//Start Show tab as per the product.
							if($(brand_id+'__1') != null && $(brand_id+'__2') != null){
								$(brand_id+'__1').style.display = "block";
								$(brand_id+'__2').style.display = "block";
							}
							//$(brand_id+'__3').class.name = "button_all";
							//End
							tempHtml += '<tr><td><div id="ppp'+totalproductloop+'" title="'+totalproductloop+'"><table border="0" width="100%" cellspacing="0" cellpadding="0">';
							tempHtml += '<tr id="product_row_price'+totalproductloop+'" name="product_row_price[]" title="'+price+'-'+brand_id+'"><td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr bgcolor="'+bg+'">'+
										'<td align="left" valign="top" class="content_3" style="padding:5px 0px 5px 0px"><strong>'+vsku+'&nbsp;&nbsp;&nbsp;&nbsp;</strong> <a href="javascript:;" onclick="show_moreinfo_popup(\''+vsku+'\',\''+escape(vdesc)+'\');"><i>View Description</i></a></td>'+
										'<td width="135" align="left" valign="top"  style="padding:5px 0px 5px 0px" class="content_3" rowspan="4">';
										if(vertical_id != '3'){
											tempHtml += '<img src="images/'+brand_image+'" border="0" width="110" alt="'+brand_name+'" title="'+brand_name+'">';
										}else{	
											tempHtml += '&nbsp;';
										}
										tempHtml += '</td><td width="135" align="left" valign="top"  style="padding:5px 0px 5px 0px" class="content_3" rowspan="4"><a href="images/vinyl-windows-pictures/'+image+'" onclick="return GB_showImage(\''+vsku+'\', this.href)"><img src="images/vinyl-windows-pictures/'+image+'" border="0" width="60" height="80"></a><br><a href="images/vinyl-windows-pictures/'+image+'" onclick="return GB_showImage(\''+vsku+'\', this.href)"><img src="images/zoom.jpg" border="0"></a></td>'+										
										'<td width="208" align="left" valign="top"  style="padding:5px 0px 5px 0px" class="content_3" rowspan="5"><table width="100%" border="0"><tr><td><table width="100%" border="0" id="retail_'+prop+'_'+id+'_table" style="display:none"><tr><td><strong>Retail Price</strong></td><td align="right"><div id="option_'+prop+'_'+id+'_base_price" ><strong>$ '+base_price+'</strong></div></td></tr><tr><td><strong>&minus; <font color="#FF0000">Our Discount</font></strong></td><td align="right" style="color:#FF0000"><div id="option_'+prop+'_'+id+'_our_disc_price"><strong>$ '+our_disc_price+'</strong></div></td></tr><tr><td><strong>&minus; <font color="#FF0000">Online Discount</font></strong></td><td align="right" style="color:#FF0000"><div id="option_'+prop+'_'+id+'_online_disc_price"><strong>$ '+online_disc_price+'</strong></div></td></tr><tr><td colspan="2"><hr></td></tr></table></td></tr><tr><td><table width="100%" border="0"><tr><td><font color="#0000FF"><strong>Online Price</strong></font></td><td align="right"><div id="option_'+prop+'_'+id+'_price"><strong>$ '+price+'</strong></div></td></tr></table></td></tr><tr><td colspan="2" align="right"><img src="images/button_hever_12.png" onclick=\'show_add_to_cart_popup("'+id+'","'+prop+'","'+final_width+'","'+final_height+'","'+interior_color+'","'+exterior_color+'","'+iaddinfo+'");\' style="cursor:pointer"></td></tr></table></td>'+
										'</tr>';
							if(vertical_id == 3 || vertical_id == 7 || vertical_id == 11){		
								tempHtml += '<tr bgcolor='+bg+'><td align="left" valign="top"  style="padding:5px 0px 5px 0px" class="content_2">';
								if(vertical_id != 11){
									tempHtml += '<strong>Callout Desc:	</strong>'+final_width+'W'+final_height+'H&nbsp; ';
								}
								tempHtml += '<strong>Interior color:	</strong> '+interior_color+' &nbsp; <strong>Exterior Color:	</strong>'+exterior_color+' &nbsp; '+projection_range+'</td></tr>';
								tempHtml += '<tr bgcolor='+bg+'><td align="left" valign="top"  style="padding:5px 0px 5px 0px"class="content_2">';
								if(vertical_id == 7){
									tempHtml += '<strong>Frame Size W x H (Inches):	</strong>'+framesizewidth+' x '+framesizeheight+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
								}
								if(vertical_id == 11){
									tempHtml += '<strong>Window Size W x H (Inches):	</strong>'+roughopeningwidth+' x '+roughopeningheight+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
								}else{
									if(vertical_id == 3){
										// Below is for Crystal aluminum sliding patio door only take off 3/4 & other sliding doors will be 1/2
										if(image == 'crystal_aluminum_patio_door.jpg' || image == 'crystal_aluminum_patio_3lite_door.jpg'){
											var rowidth = convertToFraction_exact_3by4(roughopeningwidth);
										}else{
											var rowidth = convertToFraction_exact_1by2(roughopeningwidth);	
										}
										tempHtml += '<strong>Exact Size W x H (Inches):	</strong> '+rowidth+' x '+convertToFraction_exact_1by2(roughopeningheight)+'&nbsp;&nbsp;&nbsp;';
									}
									tempHtml += '<strong>Rough Opening W x H (Inches):	</strong> '+roughopeningwidth+' x '+roughopeningheight+'</td></tr>';
								}
							}else{
								tempHtml += '<tr bgcolor='+bg+'><td align="left" valign="top"  style="padding:5px 0px 5px 0px" class="content_2"><strong>Width:	</strong><font color="#0000FF"><strong>'+fraction_final_width+'</strong></font> &nbsp; <strong>Height:	</strong><font color="#0000FF"><strong>'+fraction_final_height+'</strong></font> &nbsp; <strong>Interior color:	</strong> <font color="#0000FF"><strong>'+interior_color+'</strong></font> &nbsp; <strong>Exterior Color:	</strong><font color="#0000FF"><strong>'+exterior_color+'</strong></font> &nbsp; '+projection_range+'</td></tr>';
							}
							tempHtml += '<!--<tr bgcolor='+bg+'><td align="left" valign="top"  style="padding:5px 0px 5px 0px"class="content_2"><strong>Interior color:	</strong> '+interior_color+' &nbsp; <strong>Exterior Color:	</strong>'+exterior_color+' </td><td align="left" valign="top">&nbsp;</td></tr>-->'+
										'<tr bgcolor='+bg+'><td align="left" valign="top"  style="padding:5px 0px 5px 0px" class="content_2"><div id="option_'+prop+'_'+id+'" ><strong>OPTIONS:	</strong></div></td></tr>'+
										'<tr bgcolor='+bg+'><td align="left" valign="top" style="padding:5px 0px 5px 0px" class="content_2"><table border="0" cellspacing="0" cellpadding="0">'+
												'<tr><td class="content_2"><strong>Quality :</strong> <font color="#0000FF"><strong>'+quality1 +'</strong></font> </td>'+
												'</tr>'+
											'</table></td></tr>'+
										  '<tr bgcolor='+bg+'><td align="left" valign="top" class="content_2" style="padding:5px 0px 5px 0px">'+prfm_datafinal+'Performance Data</a><!-- | <a href="images/vinyl-windows-pictures/'+image+'" onclick="return GB_showImage(\''+vsku+'\', this.href)">Pictures</a>--> | <a href="documents/'+warranty+'"  onclick="return GB_showCenter(\'Warranty\', this.href, 600, 700)">Warranty</a> | <a href="documents/'+measure+'"  onclick="return GB_showFullScreen(\'How to measure\', this.href, 600, 700)">How to measure</a> | <a href="documents/'+install+'" onclick="return GB_showFullScreen(\'How to Install\', this.href, 600, 700)">How to install</a> | <a href="documents/'+testimonial+'"  onclick="return GB_showFullScreen(\'Testimonials\', this.href, 600, 700)">Testimonials</a> | <a href="documents/'+brochure+'"  onclick="return GB_showFullScreen(\'Brochure\', this.href, 600, 700)">Brochure</a></td>';
						  
						  /* == condtion for best flag to display ==== */
						  if(best_flag==1){		
						  var text_desc = '- Shorter Lead-times<br>- 2 Year In Home Customer Service Warranty<br>- Life-time Glass Breakage Warranty<br>- Best Consumer Warranty in The Industry';		  var text_title1 = 'Customers Choice - Best Value!!';
						  //tempHtml+= '<td colspan="2" align="left" valign="top" class="content_3" style="padding: 5px 0px;"> <a href="javascript:;" onclick="show_moreinfo_popup(\''+escape(text_title1)+'\',\''+escape(text_desc)+'\');" style="font-size:18px;color:red;text-decoration:none"><img src=\'images/bestvalue.gif\' border=0></a></td>';
						  }
						  tempHtml+= '</tr>'+
						  '<tr><td colspan="4"><hr /></td></tr></table></td></tr>';
							tempHtml += '</table></div></td></tr>';			  
							totalproductloop++;										  
							//}// this is end of price related record display
							/**** select tab according to availalbe product in the middle part ***/
							//var brand_name_exist = brand_name.toLowerCase();
							brand_name_exist[brand_name.toLowerCase()] = true;//alert(brand_name_exist);
							/***********************************************/
							/******* code for brand tabs and options inside each brand tab in option popup ******/
							var bstr = brand_name.toLowerCase();
							// NULL THE WHOLE BOTTOM OPTIONS OTHER THAN POPULAR OPTIONS
							//$('yuitabview'+bstr).innerHTML = "";
							chkTemp2 = document.getElementsByName('chk');
								for (iloopone = 0; iloopone < chkTemp2.length; iloopone++){
									chkTemp2[iloopone].checked = false;
								}
							////////////////
							//formdata[bstr] =	bstr+"_opt_pop_html";
							formdata[bstr] = "<form name='"+bstr+"' >";
							formdata[bstr] += '<ul class="yui-nav">';
							/******* code to generate tabs inside each brand in option popup ******************/			 
							if(!Object.isArray(response.OPT_GROUP_NAME)){
										for(var ogn in response.OPT_GROUP_NAME){
											if(ogn == prop){ 
												for(k=0; k<response.OPT_GROUP_NAME[ogn].length; k++){
													 formdata[bstr] +='<li';
													 if(k==0) formdata[bstr] +=' title="active" class="selected"';
													 formdata[bstr] +=' onclick="open_subtab_content('+(k+1)+','+bstr+');"><a href="#'+bstr+'tab'+(k+1)+'"><em>'+response.OPT_GROUP_NAME[ogn][k]+'</em></a></li>';
												}
											}
										}
									}
							/******* end of  code to generate tabs inside each brand in option popup ******************/			 									
							formdata[bstr] += '</ul>';
							formdata[bstr] += '<div class="yui-content">';
							/// For removing the popular options run time.
							chkTemp = document.getElementsByName('popular_options');
							for (ilooptwo = 0; ilooptwo < chkTemp.length; ilooptwo++){
									chkTemp[ilooptwo].checked = false;
								}
							chkTemp_add_to_cart = document.getElementsByName('popular_options_add_to_cart');
							for (ilooptwo = 0; ilooptwo < chkTemp_add_to_cart.length; ilooptwo++){
									chkTemp_add_to_cart[ilooptwo].checked = false;
								}
							///////////////////popular options removing end///////////////////////	
							/******* code to generate options checkbox inside each options of each brand in option popup ******************/			 
							if(!Object.isArray(response.OPT_GROUP_NAME)){
								for(var ogn in response.OPT_GROUP_NAME){
									if(ogn == prop){
										for(k=0; k<response.OPT_GROUP_NAME[ogn].length; k++){
											formdata[bstr] += '<div';
											if(k==0) formdata[bstr] +=' class=""';
											formdata[bstr] += ' id="#'+bstr+'tab'+(k+1)+'"><p>'+
											  '<table border="0">';
												if(!Object.isArray(response.OPT_NAME)){
													for(var on in response.OPT_NAME){
														if(on == prop){
															for(j=0; j<response.OPT_NAME[on][response.OPT_GROUP_NAME[ogn][k]].length; j++){
																var tempstr = response.OPT_NAME[on][response.OPT_GROUP_NAME[ogn][k]][j].opt_name;
																//optionproductrelation[x] = prop+"="+id+"="+tempstr;
																//x++;
																formdata[bstr] +='<tr>'+
																	  '<td style="cursor:pointer;"><input type="checkbox" name="chk" value="'+response.OPT_NAME[on][response.OPT_GROUP_NAME[ogn][k]][j].opt_id+'_'+response.OPT_NAME[on][response.OPT_GROUP_NAME[ogn][k]][j].opt_popular+'"></td>'+
																	  '<td class="content_3"><span><strong>'+
																		response.OPT_NAME[on][response.OPT_GROUP_NAME[ogn][k]][j].opt_name +
																		'</strong></span><!-- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Starting at $'+
																		response.OPT_NAME[on][response.OPT_GROUP_NAME[ogn][k]][j].opt_price+' &nbsp;&nbsp;'+ 
																		response.OPT_NAME[on][response.OPT_GROUP_NAME[ogn][k]][j].opt_unit+' )-->'+
																		' &nbsp;&nbsp;<a href="javascript:void(0)" class="link" onclick=show_option_desc_popup("'+escape(response.OPT_NAME[on][response.OPT_GROUP_NAME[ogn][k]][j].opt_name)+'","'+escape(response.OPT_NAME[on][response.OPT_GROUP_NAME[ogn][k]][j].opt_desc)+'"); >More Info</a>'+
																		'</td>'+
																		'</tr>';
															}
														}
													}
												}
											formdata[bstr] +='</table>'+
																	'</p>'+
																'</div>';
										}
										formdata[bstr] +=  '</div> </form>';
											//n = h + 2;	
										$('yuitabview'+bstr).innerHTML = formdata[bstr];
										    (function() { 
							                    var cn = document.body.className.toString();
							                    if (cn.indexOf('yui-skin-sam') == -1) {
								                      document.body.className += " yui-skin-sam";
							                    }
						                  	})();
                							var yuitabview2 = new YAHOO.widget.TabView('yuitabview'+bstr);
									}
								}
							}else{$('yuitabview'+bstr).innerHTML = '';}
							m++;
						}
						//selected_brandname = new Array();
						selected_brandname[h] = brand_name;
						h++;
								/*chkTemp1 = document.getElementsByName('chk');
								for (i = 0; i < chkTemp1.length; i++)
									alert(i + "_" + chkTemp1[i].checked + "_" + chkTemp1[i].value);
								for (j = 0; j < alloptions.length; j++)
									alert(j + "_" + alloptions[j]);*/
						/******* end of code to generate options checkbox inside each options of each brand in option popup ******************/			 
						/******* end of code for option tabs and options inside each tab in option popup ******/
						$('final_min_price').innerHTML = temp_minimum_price;
						$('final_max_price').innerHTML = temp_maximum_price;
						$('demo_from').value = temp_minimum_price;
						$('demo_to').value = temp_maximum_price;
						$('temp_demo_from').value = temp_minimum_price;
						$('temp_demo_to').value = temp_maximum_price;
						$('totalproductloop').value = totalproductloop;
						$('temp_panes').value = response.PANES;
					}
					var noproduct = "no";
				}else{
					$('final_min_price').innerHTML = 0;
					$('final_max_price').innerHTML = 5000;
					$('demo_from').value = 0;
					$('demo_to').value = 5000;
					$('temp_demo_from').value = 0; 
					$('temp_demo_to').value = 5000;
					
					var noproduct = "yes";
					/* Modified by Vishal Shah */
					if(vertical_id == 10){
						tempHtml += '<tr align="left" class="content_3" style="font-size:20px"><td><div id="main_contact"><img src="images/woodclad.jpg" width="1008" height="720"></td></tr>';
					}else{
						tempHtml += '<tr align="left" class="content_3" style="font-size:20px"><td><div id="main_contact"><div class="cont"><p>Having Trouble?</p></div><div class="font_we"><p>We\'re Here to Help!</p></div><div class="font_para"><div class="p"><p class="p">Thank you for choosing Custom Order Online, Inc.</p><p>Out goal is to provide you with the best Custom Service<br> available. We will be happy to help you with anything that<br> you may need while purchasing your windows and doors.</p><p class="p">sales@customorderonline.com</p><p class="p">866-589-9367</p><br><p class="p">LOOKING FOR INFORMATION ABOUT...<br>Products, Technical specifications and<br>our company\'s history, see our <a href="index.php?view=terms">About Us</a> or our <a href="index.php?view=faq">FAQ</a> pages.</p></p></div></div></div></td></tr>';
					}
				}
				//START FOR DYNAMIC TAB
				/*splitids = dynamictabid.split("::");
				<!--<br><br><br>Your search criteria did not yield any results.<br><br> Perhaps we do not carry the product or the sizes you have selected.<br><br> Please change your search criteria to re-run the or contact our office<br><br> at 8665899367 or sales@customorderonline.com for assistance.-->
				for(c=0;c<splitids.length-1;c++)
				{
					$(splitids[c]+'__1').style.display = "block";
					$(splitids[c]+'__2').style.display = "block";
				}*/
				//END
				//picture_image_set = picture_image_set.substr(0,picture_image_set.length-2);
				//picture_image_set += "];";	
				//$('picture_gallery_data').innerHTML = picture_image_set;
				performance_data_set = performance_data_set.substr(0,performance_data_set.length-2);
				performance_data_set += "];"; 
				warranty_set = warranty_set.substr(0,warranty_set.length-2);
				warranty_set += "];"; 
				how_to_measure_set = how_to_measure_set.substr(0,how_to_measure_set.length-2);
				how_to_measure_set += "];"; 
				how_to_install_set = how_to_install_set.substr(0,how_to_install_set.length-2);
				how_to_install_set += "];"; 
				testimonials_set = testimonials_set.substr(0,testimonials_set.length-2);
				testimonials_set += "];"; 

				//picture_image_set = '+picture_image_set+';
				if(performance_data_set != "];"){
					tempHtml +='<tr><td><script type="text/javascript">performance_data_set = '+performance_data_set+';warranty_set = '+warranty_set+';how_to_measure_set = '+how_to_measure_set+';how_to_install_set = '+how_to_install_set+';testimonials_set = '+testimonials_set+';</script></td></tr></table>';
				}
				put_pictures(picture_image_set);
				$('product_data').update(tempHtml);
				$('product_data').show();
				$('middle_portion_for_replace').style.display = "block";
				var blocknonebrand = new Array();
				for(iloopthree=0; iloopthree<selected_brand.length; iloopthree++){
					blocknonebrand[selected_brand[iloopthree]] = selected_brand[iloopthree];
				}
				/**** Display or hide the tab of option popup according to the product displayed in the middle *******/
					//response.ALL_BRAND_OF_TABLE.length
					for(iloopfour=0; iloopfour<response.ALL_BRAND_OF_TABLE.length; iloopfour++){
						var brand_name = response.ALL_BRAND_OF_TABLE[iloopfour].name;
						if($(brand_name.toLowerCase()+'_tab') != null)
						{
							$(brand_name.toLowerCase()+'_tab').style.display = "none";
						}
					}
					for(iloopfive=0; iloopfive<response.ALL_BRAND.length; iloopfive++){
						var brand_name = response.ALL_BRAND[iloopfive].name;
						if($(brand_name.toLowerCase()+'_tab') != null)
						{
							//if(blocknonebrand.length > 0)
							//{
								if(response.ALL_BRAND[iloopfive].prefix == blocknonebrand[response.ALL_BRAND[iloopfive].prefix]){
									$(brand_name.toLowerCase()+'_tab').style.display = "";
								}else{
									$(brand_name.toLowerCase()+'_tab').style.display = "none";
								}
							//}
							/*else if(selected_brand.length != 1)
							{
								$(brand_name.toLowerCase()+'_tab').style.display = "";
							}*/
						}
					}
					$('testimonial_scroller').style.display = 'block'; //TESTIMONIAL SCROLLER ENABLE CODE
				/*************************************************************************************************/
			}
		}else{
			alert('An error occurred while searching. Please contact our office at 8665899367 or email sales@customorderonline.com for assistance');
			return false;
		}
	}
	if(noproduct != "yes"){
		placealloptions();
		take_all_row_for_sort(totalproductloop,sort_by);
	}
}
/*function takealloptions(){
	chkTemp1 = document.getElementsByName('chk');
	for (iloopsix = 0; iloopsix < chkTemp1.length; iloopsix++){
		alloptions[iloopsix] = chkTemp1[iloopsix].checked;
	}
	chkTemp = document.getElementsByName('popular_options');
	for (iloopseven = 0; iloopseven < chkTemp.length; iloopseven++){
		allpopularoptions[iloopseven] = chkTemp[iloopseven].checked;
	}
}
function placealloptions(){
	chkTemp1 = document.getElementsByName('chk');
	//if(chkTemp1.length == alloptions.length){
		for (iloopeight = 0; iloopeight < chkTemp1.length; iloopeight++){
			chkTemp1[iloopeight].checked = alloptions[iloopeight];
		}
		chkTemp = document.getElementsByName('popular_options');
		if(chkTemp.length == allpopularoptions.length){
			for (iloopnine = 0; iloopnine < chkTemp.length; iloopnine++){
				chkTemp[iloopnine].checked = allpopularoptions[iloopnine];
			}
		}
		apply_options();	
	//}
}*/
function takealloptions(){
/*	chkTemp1 = document.getElementsByName('chk');
	for (iloopsix = 0; iloopsix < chkTemp1.length; iloopsix++){
		if(chkTemp1[iloopsix].checked == true){	
			alloptions[iloopsix] = chkTemp1[iloopsix].value;
		}
	}
*/	chkTemp = document.getElementsByName('popular_options');
	for (iloopseven = 0; iloopseven < chkTemp.length; iloopseven++){
		if(chkTemp[iloopseven].checked == true)
			allpopularoptions[iloopseven] = chkTemp[iloopseven].value;
	}
	chkTemp_add_to_cart = document.getElementsByName('popular_options_add_to_cart');
	for (iloopseven = 0; iloopseven < chkTemp_add_to_cart.length; iloopseven++){
		if(chkTemp_add_to_cart[iloopseven].checked == true)
			allpopularoptions[iloopseven] = chkTemp_add_to_cart[iloopseven].value;
	}
}
function placealloptions(){
	chkTemp1 = document.getElementsByName('chk');
	//if(chkTemp1.length == alloptions.length){
		for (iloopeight = 0; iloopeight < chkTemp1.length; iloopeight++){
			for(iloopeight2 =0;iloopeight2 < allpopularoptions.length;iloopeight2++){
				var pop_opt_val = chkTemp1[iloopeight].value;
				var sel_pop_opt = pop_opt_val.split("_");
				if(parseInt(sel_pop_opt[1]) == parseInt(allpopularoptions[iloopeight2])){
					chkTemp1[iloopeight].checked = true;
				}
			}
		}
		chkTemp = document.getElementsByName('popular_options');
		//if(chkTemp.length == allpopularoptions.length){
			for (iloopnine = 0; iloopnine < chkTemp.length; iloopnine++){
				for(iloopnine2 =0;iloopnine2 < allpopularoptions.length;iloopnine2++){
					//var pop_opt_val = chkTemp1[iloopnine].value;
					//var sel_pop_opt = pop_opt_val.split("_");
					if(parseInt(chkTemp[iloopnine].value) == parseInt(allpopularoptions[iloopnine2])){
						chkTemp[iloopnine].checked = true;
					}
				}
			}
		//}
		chkTemp_add_to_cart = document.getElementsByName('popular_options_add_to_cart');
		//if(chkTemp.length == allpopularoptions.length){
			for (iloopnine = 0; iloopnine < chkTemp_add_to_cart.length; iloopnine++){
				for(iloopnine2 =0;iloopnine2 < allpopularoptions.length;iloopnine2++){
					//var pop_opt_val = chkTemp1[iloopnine].value;
					//var sel_pop_opt = pop_opt_val.split("_");
					if(parseInt(chkTemp_add_to_cart[iloopnine].value) == parseInt(allpopularoptions[iloopnine2])){
						chkTemp_add_to_cart[iloopnine].checked = true;
					}
				}
			}
		//}
		apply_options();	
	//}
}
function removealloptions(){
	chkTemp1 = document.getElementsByName('chk');
	//if(chkTemp1.length == alloptions.length){
		for (iloopeight = 0; iloopeight < chkTemp1.length; iloopeight++){
			//for(iloopeight2 =0;iloopeight2 < allpopularoptions.length;iloopeight2++){
				//var pop_opt_val = chkTemp1[iloopeight].value;
				//var sel_pop_opt = pop_opt_val.split("_");
				//if(parseInt(sel_pop_opt[1]) == parseInt(allpopularoptions[iloopeight2])){
			chkTemp1[iloopeight].checked = false;
				//}
			//}
		}
		chkTemp = document.getElementsByName('popular_options');
		//if(chkTemp.length == allpopularoptions.length){
			for (iloopnine = 0; iloopnine < chkTemp.length; iloopnine++){
				//for(iloopnine2 =0;iloopnine2 < allpopularoptions.length;iloopnine2++){
					//var pop_opt_val = chkTemp1[iloopnine].value;
					//var sel_pop_opt = pop_opt_val.split("_");
					//if(parseInt(chkTemp[iloopnine].value) == parseInt(allpopularoptions[iloopnine2])){
				chkTemp[iloopnine].checked = false;
					//}
				//}
			}
		//}
		chkTemp_add_to_cart = document.getElementsByName('popular_options_add_to_cart');
		//if(chkTemp.length == allpopularoptions.length){
			for (iloopnine = 0; iloopnine < chkTemp_add_to_cart.length; iloopnine++){
				//for(iloopnine2 =0;iloopnine2 < allpopularoptions.length;iloopnine2++){
					//var pop_opt_val = chkTemp1[iloopnine].value;
					//var sel_pop_opt = pop_opt_val.split("_");
					//if(parseInt(chkTemp[iloopnine].value) == parseInt(allpopularoptions[iloopnine2])){
				chkTemp_add_to_cart[iloopnine].checked = false;
					//}
				//}
			}
		//}
		apply_options();	
	//}
}
function take_all_row_for_sort(totalproductloop,sort_by){
	sort_by = sort_by;
	s = sort_by;
	all_product_rows = new Array();
	tempArray = new Array();
	for (iloopten = 0; iloopten < totalproductloop; iloopten++){
		val = "ppp" + iloopten;
		all_product_rows[iloopten] = $(val).innerHTML;
	}
	for (iloopten = 0; iloopten < totalproductloop; iloopten++){
		for (iloopten1 = 0; iloopten1 < totalproductloop; iloopten1++){
			val = "ppp" + iloopten;
			var a = all_product_rows[iloopten1];
			if(a.search("product_row_price" + iloopten) != "-1"){
				tempArray[iloopten] = all_product_rows[iloopten1];
				iloopten1 = 1000;
			}
		}
	} 
	for (iloopten = 0; iloopten < totalproductloop; iloopten++){
		all_product_rows[iloopten] = tempArray[iloopten];
	}
	do_sorting(s);
}
function do_sorting(s){
	rowTemp = all_product_rows.length; 	
	var iloopten, rowTemp;
	var price_array = new Array();
	var my_array = new Array();
	for (iloopeleven = 0; iloopeleven < rowTemp; iloopeleven++){
		valTemp = $('product_row_price'+iloopeleven).title;
		priceTemp = valTemp.split("-");
		price_array[iloopeleven] = parseFloat(priceTemp[0]);
		my_array[iloopeleven] = iloopeleven;
	}
	var lenloop = price_array.length, ilooptwelve, iloopthirteen, stoploop;
	for (ilooptwelve=0; ilooptwelve < lenloop; ilooptwelve++){
		for (iloopthirteen=0, stoploop=lenloop-ilooptwelve; iloopthirteen < stoploop; iloopthirteen++){
			if(s == 'desc'){
				if (price_array[iloopthirteen] < price_array[iloopthirteen+1]){
					swap(price_array, iloopthirteen, iloopthirteen+1);
					firstIndex = iloopthirteen;
					secondIndex = iloopthirteen+1;
					var temp = my_array[firstIndex];
					my_array[firstIndex] = my_array[secondIndex];
					my_array[secondIndex] = temp;
				}
			}else{
				if (price_array[iloopthirteen] > price_array[iloopthirteen+1]){
					swap(price_array, iloopthirteen, iloopthirteen+1);
					firstIndex = iloopthirteen;
					secondIndex = iloopthirteen+1;
					var temp = my_array[firstIndex];
					my_array[firstIndex] = my_array[secondIndex];
					my_array[secondIndex] = temp;
				}
			}
		}
	}
	for (iloopten = 0; iloopten < price_array.length; iloopten++){
		var val = "ppp" + iloopten;
		$(val).innerHTML = all_product_rows[my_array[iloopten]];
	}
}
function swap(items, firstIndex, secondIndex){
    var temp = items[firstIndex];
    items[firstIndex] = items[secondIndex];
    items[secondIndex] = temp;
}
function swapIndex(items, firstIndex, secondIndex){
    var temp = firstIndex;
    items[firstIndex] = secondIndex;
    items[secondIndex] = temp;
}
/* =============================================================================== */
/* ==== Show option popup to display the options availalbe for specific brands ==== */
function show_option_popup(){
	if($('product_data').innerHTML.length < 200) {
		alert('Please select Product first.');
		return false;
	}
/*	var arr = $$('#popular_options');
	for(k=0;k<arr.length;k++){
		arr[k].checked = false;			
	}
*/	yuitabview1.set('activeIndex','0');
	$("option_popup").style.left = (Screen.getViewportWidth()/2 - (800/2))+"px";
	$("option_popup").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-250)+"px";
	$("option_popup").toggle();
	$("option").toggle();
	$("option").style.height = Screen.getDocumentHeight()+'px';
}
/* =============================================================================== */
/* ==== Hide option popup which displays the options availalbe for specific brands ==== */
function hide_option_popup(){
	$("option_popup").toggle();
	$("option").toggle();
}
/* =============================================================================== */
/* ======== To displays the description (popup) about options (More Info)  =============== */
function show_option_desc_popup(opt_name,opt_desc){
	opt_name = unescape(opt_name);
	opt_desc = unescape(opt_desc);
	$("option_desc_popup").style.left = (Screen.getViewportWidth()/2 - (400/2))+"px";
	$("option_desc_popup").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-150)+"px";
	$("opt_name").innerHTML = "<strong>"+opt_name+"</strong>";
	$("opt_desc").innerHTML = opt_desc;
	$("option_desc_popup").toggle();
	$("option_desc").toggle();
	//$("option_desc").style.height = Screen.getDocumentHeight()+'px';
}
/* =============================================================================== */
/* ======== Hide the description (popup) about options (More Info)  =============== */
function hide_option_desc_popup(){
	$("option_desc_popup").toggle();
	$("option_desc").toggle();
}
/* =============================================================================== */
function select_by_popular_option(chkbox){
	var val = chkbox.value;
	var flag = false;
	if(chkbox.checked == true)
		flag = true;
	else
		flag = false;
	for(j=0;j<document.forms.length;j++){
		for(i=0;i<document.forms[j].length;i++){
			var opt_id = document.forms[j].chk[i].value;
			var myopt_id = opt_id.split("_");
			if(myopt_id[1] == val){
				document.forms[j].chk[i].checked = flag;
			}
		}
	}
	temp_po = document.getElementsByName('popular_options');
	temp_poatc = document.getElementsByName('popular_options_add_to_cart');
	for (iloopone = 0; iloopone < temp_po.length; iloopone++){
		temp_poatc[iloopone].checked = temp_po[iloopone].checked;
	}
}
function apply_options(){
	var optname;
	var final_price;	
	var final_base_price;	
	var h;
	var m;
	var i;
	var j;
	var k;
	var n;
	var price;
	var optprice;
	var temp_maximum_price=0;
	var temp_minimum_price=0;
	$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	$("WAIT").toggle();
	$("COVER").toggle();
	$("COVER").style.height = Screen.getDocumentHeight()+'px';
	for(m=0;m<selected_id.length;m++){
		optname="<strong>Options: </strong> <span style='color:#600'>";
		final_price="<strong>$ ";
		final_base_price="<strong>$ ";
		var sel_id = selected_id[m].split(":");
		price = parseFloat(sel_id[2]);
		base_price = parseFloat(sel_id[3]);
		if(document.getElementById('option_'+sel_id[0]+'_'+sel_id[1]) != null){
			for(j=0;j<document.forms.length;j++){
				for(i=0;i<document.forms[j].length;i++){
					for(k=0;k<selected_brandname.length;k++){	
						if(document.forms[j].name == selected_brandname[k].toLowerCase() && sel_id[0] == selected_brand[k]){									
							if(document.forms[j].chk[i].checked == true){
								//var optname = selected_brand[k]+"_html";
								var firsttemp = document.forms[j].chk[i].value;
								var secondtemp = firsttemp.split("_");
								var tempformval = secondtemp[0];
								for(n=0;n<optionproductrelation.length;n++){
								//OPTIONDATA : wwh_16_26_6.97_1_2009 Stimulus Tax Credit for Windows
								// 5th argument Option Unit....1=per sq.ft,2=per window,3=per UI,4=per sash,5=Percent
									var option_data = optionproductrelation[n].split("_");
									if(tempformval == option_data[2]){
										if(sel_id[0] == option_data[0]){
											if(sel_id[1] == option_data[1]){
												// Options values set from here
												//optname += tempformval +", " ;//alert(optname);alert(option_data[4]);
												optname += option_data[5] +", " ;
												// Price calculation goes here.
												if(option_data[4] == 1){
													var fixval = 144;
													var wi = parseFloat($('width').value)+parseFloat($('width_inch').value);
													var he = parseFloat($('height').value)+parseFloat($('height_inch').value);
													var multwh = parseFloat(wi)*parseFloat(he);
													var sqft = parseFloat(multwh)/parseFloat(fixval);
													optprice = parseFloat(sqft)*parseFloat(option_data[3]);
												}else if(option_data[4] == 2){
													optprice = parseFloat(option_data[3]);
												}else if(option_data[4] == 3){
													var wi = parseFloat($('width').value)+parseFloat($('width_inch').value);
													var he = parseFloat($('height').value)+parseFloat($('height_inch').value);
													var ui = parseFloat(wi)+parseFloat(he);
													optprice = parseFloat(ui)*parseFloat(option_data[3]);
												}else if(option_data[4] == 4){
													optprice = parseFloat(option_data[3])*parseFloat($('temp_panes').value);
												}else if(option_data[4] == 5){
													optprice = (parseFloat(price)*parseFloat(option_data[3]))/100;
												}else if(option_data[4] == 6){
													optprice = parseFloat(option_data[3]);
												}else{
													optprice = parseFloat(option_data[3]);
												}
												price = parseFloat(price)+parseFloat(optprice);//alert(price);
												base_price = parseFloat(base_price)+parseFloat(optprice);
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		optname = optname.substr(0,optname.length-2);
		optname += "</span>";
		var final_set_price = price.toFixed(2);
		var final_set_base_price = base_price.toFixed(2);
		final_price += final_set_price+"</strong>";
		final_base_price += final_set_base_price+"</strong>";
		final_online_disc_price = (price/9).toFixed(2);
		final_our_disc_price = (base_price - final_online_disc_price - price).toFixed(2);
		if($('option_'+sel_id[0]+'_'+sel_id[1]) != null)
			$('option_'+sel_id[0]+'_'+sel_id[1]).update(optname);
		if($('option_'+sel_id[0]+'_'+sel_id[1]+'_price') != null){	
			$('option_'+sel_id[0]+'_'+sel_id[1]+'_price').update(final_price);
			$('option_'+sel_id[0]+'_'+sel_id[1]+'_base_price').update(final_base_price);
			//$('option_'+sel_id[0]+'_'+sel_id[1]+'_our_disc_price').update("(<strong>$ "+final_our_disc_price+"</strong>)");
			//$('option_'+sel_id[0]+'_'+sel_id[1]+'_online_disc_price').update("(<strong>$ "+final_online_disc_price+"</strong>)");
			$('option_'+sel_id[0]+'_'+sel_id[1]+'_our_disc_price').update("<strong> "+final_our_disc_price+"</strong>");
			$('option_'+sel_id[0]+'_'+sel_id[1]+'_online_disc_price').update("<strong> "+final_online_disc_price+"</strong>");
		}
		if(parseFloat(final_set_price) >= parseFloat(final_set_base_price)){
			$('retail_'+sel_id[0]+'_'+sel_id[1]+'_table').style.display = "none";	
		}else{
			$('retail_'+sel_id[0]+'_'+sel_id[1]+'_table').style.display = "block";	
		}
		// SET SLIDER AS PER OPTION CHANGES START	
		var price_brand = $('product_row_price'+m).title;
		var dash_price_brand = price_brand.split("-");
		$('product_row_price'+m).title = final_set_price+"-"+dash_price_brand[1];
		//SET MIN AND MAX VALUE OF SLIDER
		if((parseFloat(final_set_price) >= parseFloat(temp_maximum_price)) || temp_maximum_price == 0)
		{
			temp_maximum_price = parseFloat(final_set_price);
		}
		if((parseFloat(final_set_price) <= parseFloat(temp_minimum_price)) || temp_minimum_price == 0)
		{
			temp_minimum_price = parseFloat(final_set_price);
		}
		$('final_min_price').innerHTML = temp_minimum_price;
		$('final_max_price').innerHTML = temp_maximum_price;
		$('demo_from').value = temp_minimum_price;
		$('demo_to').value = temp_maximum_price;
		$('temp_demo_from').value = temp_minimum_price;
		$('temp_demo_to').value = temp_maximum_price;
		// SET SLIDER AS PER OPTION CHANGES END
	}
	$("WAIT").toggle();
	$("COVER").toggle();
	take_all_row_for_sort(all_product_rows.length,sort_by);
	//do_sorting();
}
/* ======== To displays the add to cart (popup) about options (More Info)  =============== */
function show_add_to_cart_popup(id,brand,w,h,int_color,ext_color,additional_info){//return false;
	//opt_name = unescape(opt_name);
	//opt_desc = unescape(opt_desc);
	$("qty").value = "1";
	$('consumable_1').value = "0";	
	$('consumable_2').value = "0";	
	$('consumable_3').value = "0";		
	var id_ac = unescape(id);//alert(id_ac);
	var brand_ac = unescape(brand);//alert(brand_ac);
	var w_ac = unescape(w);
	var h_ac = unescape(h);
	var int_color_ac = unescape(int_color);
	var ext_color_ac = unescape(ext_color);
	var additional_info_ac = unescape(additional_info);	
	var temp_popup_price = "option_"+brand_ac+"_"+id_ac+"_price";
	var temp1_popup_price = $(temp_popup_price).innerHTML;
	var temp2_popup_price = temp1_popup_price.split(' ');
	var temp3_popup_price = temp2_popup_price[1];
	var temp4_popup_price = temp3_popup_price.split('<');
	var popup_price = temp4_popup_price[0];
	if(additional_info_ac == "1"){
		$("operating_pane_show_hide").style.display = "block";
	}else{
		$('operating_pane').value = "";
		$("operating_pane_show_hide").style.display = "none";
	}
	if(additional_info_ac == "2"){
		$("proporation_show_hide").style.display = "block";
	}else{
		$('proporation').value = "";
		$("proporation_show_hide").style.display = "none";
	}
	if(additional_info_ac == "3"){
		$("select_handling").style.display = "block";
		$("handling_option1").checked = true;
	}else{
		$("handling_option1").checked = false;
		$("handling_option2").checked = false;
		$("handling_option3").checked = false;
		$("handling_option4").checked = false;
	}
	$("add_to_cart_popup").style.left = (Screen.getViewportWidth()/2 - (400/2))+"px";
	$("add_to_cart_popup").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-150)+"px";
	//$("opt_name").innerHTML = "<strong>"+opt_name+"</strong>";
	//$("opt_desc").innerHTML = opt_desc;
	$("id_ac").value = id_ac;
	$('brand_ac').value = brand_ac;
	$('w_ac').value = w_ac;
	$('h_ac').value = h_ac;
	$('int_color_ac').value = int_color_ac;
	$('ext_color_ac').value = ext_color_ac;
	$('additional_info_ac').value = additional_info_ac;
	$('popup_price_ac').value = popup_price;	
	$('popup_price').innerHTML = popup_price;
	$('windows_base_price').innerHTML = popup_price;	
	$("add_to_cart_popup").toggle();
	$("add_to_cart").toggle();
	//$("add_to_cart").style.height = Screen.getDocumentHeight()+'px';
}
/* =============================================================================== */
/* ======== Hide the description (popup) about options (More Info)  =============== */
function hide_add_to_cart_popup(){
	$("add_to_cart_popup").toggle();
	$("add_to_cart").toggle();
}
/* =============================================================================== */
function add_to_cart(){ 
	var id_ac = $('id_ac').value;
	var brand_ac = $('brand_ac').value;
	var w_ac = $('w_ac').value;
	var h_ac = $('h_ac').value;
	var int_color_ac = $('int_color_ac').value;
	var ext_color_ac = $('ext_color_ac').value;
	var additional_info_ac = $('additional_info_ac').value;
	
	var options_ac = $('option_'+brand_ac+'_'+id_ac).innerHTML;
	var price_ac = $('option_'+brand_ac+'_'+id_ac+'_price').innerHTML;
	var state_ac = $('state').value;
	var app_ac = $('app').value;
	//var quality_ac = $('quality').value;
	//var ext_color_ac = $(+'ext_color_ac').value;option_wwh_16_price    option_wwh_16

	var qty = $('qty').value;
	//var consumable = $('consumable').value;
	//var consumable = '1';
	var consumable_1 = $('consumable_1').value;
	var consumable_price_1 = $('consumable_price_1').value;
	var consname_1 = $('consname_1').value;
	var consumable_2 = $('consumable_2').value;
	var consumable_price_2 = $('consumable_price_2').value;
	var consname_2 = $('consname_2').value;
	var consumable_3 = $('consumable_3').value;
	var consumable_price_3 = $('consumable_price_3').value;
	var consname_3 = $('consname_3').value;
	if($('operating_pane_show_hide').style.display == "block"){
		if($('operating_pane').value == ""){
			alert("Please select operating pane (outside looking in)");
			show_add_to_cart_popup(id_ac,brand_ac,w_ac,h_ac,int_color_ac,ext_color_ac,additional_info_ac);
			return false;
		}	
	}
	var operating_pane = $('operating_pane').value;
	if($('proporation_show_hide').style.display == "block"){
		if($('proporation').value == ""){
			alert("Please select proporation");
			show_add_to_cart_popup(id_ac,brand_ac,w_ac,h_ac,int_color_ac,ext_color_ac,additional_info_ac);
			return false;
		}	
	}
	var proporation = $('proporation').value;
	if($('handling_option1').checked == true)
		var handling_option = $('handling_option1').value;
	else if($('handling_option2').checked == true)
		var handling_option = $('handling_option2').value;
	else if($('handling_option3').checked == true)
		var handling_option = $('handling_option3').value;
	else if($('handling_option4').checked == true)
		var handling_option = $('handling_option4').value;
	else	
		var handling_option = "";
	var location = $('location').value;
	if(qty == "" || qty <= 0){
		alert('Please enter proper Value');
		return false;
	}else{
		new ajax ('ajax.php', {postBody: 'method=add_to_cart&product_master_id='+id_ac+'&brand_prefix='+brand_ac+'&width='+w_ac+'&height='+h_ac+'&interior_color='+int_color_ac+'&exterior_color='+ext_color_ac+'&quantity='+qty+'&options_ac='+options_ac+'&price_ac='+price_ac+'&state_id='+state_ac+'&app_id='+app_ac+'&operating_pane='+operating_pane+'&proporation='+proporation+'&handling_option='+handling_option+'&additional_info='+additional_info_ac+'&consumable_1='+consumable_1+'&consumable_price_1='+consumable_price_1+'&consname_1='+consname_1+'&consumable_2='+consumable_2+'&consumable_price_2='+consumable_price_2+'&consname_2='+consname_2+'&consumable_3='+consumable_3+'&consumable_price_3='+consumable_price_3+'&consname_3='+consname_3+'&location='+location , onComplete: add_to_cart_callback , userVariable:Array()});
		$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
		$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
		$("WAIT").toggle();
		$("COVER").toggle();
		$("COVER").style.height = Screen.getDocumentHeight()+'px';
	}
}
function add_to_cart_callback(request , variable){
	$("WAIT").toggle();
	$("COVER").toggle();
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			if(response.RESULT=="OK"){
				$('final_price_cart').innerHTML = "$ "+response.FINALCARTPRICE;
				if(response.FINALCARTPRICE == "" || response.FINALCARTPRICE == "0.00" || response.FINALCARTPRICE == "0"){
					$('shopping_cart_img').innerHTML = '<img src="images/emptyshoppingcart.png" border="0"/>';
				}else{
					$('shopping_cart_img').innerHTML = '<img src="images/fullshoppingcart.png" border="0"/>';	
				}
			}
		}
	}
}

function shopping_cart(del_id){
	new ajax('ajax.php', {postBody: 'method=shopping_cart&del_id='+del_id, onComplete: shopping_cart_callback});
}
function shopping_cart_callback(request){//alert("End");
	//$("WAIT").toggle();
	//$("COVER").toggle();
	//alert(request.responseText);
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			//alert(request.responseText);
			if(response.RESULT=="OK"){
				//$('middle_portion_for_replace').innerHTML = response.CARTPRODUCTLIST;
				$('product_data').innerHTML = response.CARTPRODUCTLIST;
				$('middle_portion_for_replace').style.display = "none";
				$('product_data').style.display = "block";
				$('final_price_cart').innerHTML = "$ "+response.FINALCARTPRICE;
				if(response.FINALCARTPRICE == "" || response.FINALCARTPRICE == "0.00" || response.FINALCARTPRICE == "0"){
					$('shopping_cart_img').innerHTML = '<img src="images/emptyshoppingcart.png" border="0"/>';
				}else{
					$('shopping_cart_img').innerHTML = '<img src="images/fullshoppingcart.png" border="0"/>';	
				}
			}
		}
	}//alert("es");
}
function put_pictures(val){
	vertical_id = $('vertical').value;
	interior_color = $('interior_colors').value;
	exterior_color = $('exterior_colors').value;
	brand_id = $('brands').value;
		
	new ajax('ajax.php', {postBody: 'method=put_pictures&val='+val, onComplete: put_pictures_callback});
	$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	$("WAIT").toggle();
	$("COVER").toggle();
	$("COVER").style.height = Screen.getDocumentHeight()+'px';
}
function put_pictures_callback(request){
	$("WAIT").toggle();
	$("COVER").toggle();
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			//alert(request.responseText);
			if(response.RESULT=="OK"){
			}
		}
	}
}
function confDelete(del_id){
	if(confirm("Are you sure you want to Delete this product from Shopping Cart?")){
		shopping_cart(del_id);	
	}
}
function calculateCart(){
	var fp = $('final_price').value;
	var sc = $('shipping_charge').value;
	// For Extra Calculation of Tube of Caulking and etc...
	var toce = $('tube_of_caulking_extra').value;
	var wike = $('window_installation_kit_extra').value;
	var mcte = $('matching_coil_stock_extra').value;
	var la = $('lowe_argon_extra').value;
	var cg = $('colonial_grids_extra').value;
	var toce_price = $('tube_of_caulking_extra_price').value;
	var wike_price = $('window_installation_kit_extra_price').value;
	var mcte_price = $('matching_coil_stock_extra_price').value;
	var la_price = $('lowe_argon_extra_price').value;
	var cg_price = $('colonial_grids_extra_price').value;
	/// JOPLIN FUND ///
	var joplin_fund_temp = $('joplin_fund').value;
	
	if(toce == "" || isNaN(toce) || parseFloat(toce) < 0){
		$('tube_of_caulking_extra').value = 0;
		toce = 0;
	}
	if(wike == "" || isNaN(wike) || parseFloat(wike) < 0){
		$('window_installation_kit_extra').value = 0;
		wike = 0;
	}
	if(mcte == "" || isNaN(mcte) || parseFloat(mcte) < 0){
		$('matching_coil_stock_extra').value = 0;
		mcte = 0;
	}
	if(la == "" || isNaN(la) || parseFloat(la) < 0){
		$('lowe_argon_extra').value = 0;
		la = 0;
	}
	if(cg == "" || isNaN(cg) || parseFloat(cg) < 0){
		$('colonial_grids_extra').value = 0;
		cg = 0;
	}
	if(joplin_fund_temp == "" || isNaN(joplin_fund_temp) || parseFloat(joplin_fund_temp) < 0){
		$('joplin_fund').value = 0;
		joplin_fund_temp = 0;
	}
	var tot_toce = parseFloat(toce)*parseFloat(toce_price);
	$('tube_of_caulking_extra_fnl').innerHTML = tot_toce.toFixed(2);
	$('tot_tub_total_consum').innerHTML = parseInt(toce) + parseInt($('tub_total_consum').value);	
	var tot_wike = parseFloat(wike)*parseFloat(wike_price);
	$('window_installation_kit_extra_fnl').innerHTML = tot_wike.toFixed(2);	
	$('tot_win_total_consum').innerHTML = parseInt(wike) + parseInt($('win_total_consum').value);	
	var tot_mcte = parseFloat(mcte)*parseFloat(mcte_price);
	$('matching_coil_stock_extra_fnl').innerHTML = tot_mcte.toFixed(2);	
	$('tot_mat_total_consum').innerHTML = parseInt(mcte) + parseInt($('mat_total_consum').value);	
	var tot_la = parseFloat(la)*parseFloat(la_price);
	var tot_cg = parseFloat(cg)*parseFloat(cg_price);
	$('options_qty_val').innerHTML = parseInt(la) + parseInt(cg);	
	var total_extra_consumables = parseFloat(tot_toce) + parseFloat(tot_wike) + parseFloat(tot_mcte) + parseFloat(tot_la) + parseFloat(tot_cg);
	// Above total_extra_consumbles variable added below
	// For Extra Calculation of Tube of Caulking and etc...
	if($('lift_gate_service').checked == true){
		var lgs = "48.00";	
	}else{
		var lgs = "0.00";			
	}
	if($('inside_delivery_service').checked == true){
		var ids = "98.00";	
	}else{
		var ids = "0.00";			
	}
	// PICKUP VALUE
	var pickup_val = $('pickup_discount').value;
	var ot = parseFloat(fp)+parseFloat(sc)+parseFloat(lgs)+parseFloat(ids)+parseFloat(total_extra_consumables)+parseFloat(joplin_fund_temp)-pickup_val;
	$('lift_service').value = lgs;
	$('lift_service_val').innerHTML = "<b>$ "+lgs+"</b>";
	$('inside_service').value = ids;
	$('inside_service_val').innerHTML = "<b>$ "+ids+"</b>";
	// EXTRA CONSUMABLES:	
	$('total_extra_consumables').value = total_extra_consumables;
	$('total_extra_consumables_val').innerHTML = "<b>$ "+total_extra_consumables.toFixed(2)+"</b>";
	$('lowe_argon_extra_fnl').innerHTML = tot_la.toFixed(2);	
	$('colonial_grids_extra_fnl').innerHTML = tot_cg.toFixed(2);
	$('joplin_fund_val').innerHTML = "<b>$ "+parseFloat(joplin_fund_temp).toFixed(2)+"</b>";
	// EXTRA CONSUMABLES:	
	$('order_total').value = ot;
	$('order_total_val').innerHTML = "<b>$ "+ot.toFixed(2)+"</b>";
//$ot = $('order_total').value;
}
/* ======================================================================== */
/* ======== To displays the more info on clicking on question mark  =============== */
function show_moreinfo_popup(info_name,info_desc){
	info_name = unescape(info_name);
	info_desc = unescape(info_desc);
	$("moreinfo_popup").style.left = (Screen.getViewportWidth()/2 - (400/2))+"px";
	$("moreinfo_popup").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-150)+"px";
	$("info_name").innerHTML = "<strong>"+info_name+"</strong>";
	$("info_desc").innerHTML = info_desc;
	$("moreinfo_popup").toggle();
	$("moreinfo").toggle();
	//$("option_desc").style.height = Screen.getDocumentHeight()+'px';
}
/* =============================================================================== */
/* ======== Hide displays the more info  =============== */
function hide_moreinfo_popup(){
	$("moreinfo_popup").toggle();
	$("moreinfo").toggle();
}
/* =============================================================================== */
/* ======== Copy Line Functionality =============== */
function copy_line(id){
	new ajax ('ajax.php', {postBody: 'method=copy_line&id='+id , onComplete: copy_line_callback , userVariable:Array()});
	$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	$("WAIT").toggle();
	$("COVER").toggle();
	$("COVER").style.height = Screen.getDocumentHeight()+'px';
}
function copy_line_callback(request , variable){
	$("WAIT").toggle();
	$("COVER").toggle();
	//alert(request.responseText);
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			if(response.RESULT=="OK"){	
			}
		}
	}
}
/* =============================================================================== */
// FUNCTIONS USED IN THE EDIT ORDER PAGE 
/* =====Update Order(when we change height/width at the time of edit order,From here basic product price is calculated.)====== */
function calculate_product_price(){ 
	var temp_state_id = $('temp_state_id').value;
	var width_ft = $('width_ft').value;
	var width_inch = $('width_inch').value;
	var height_ft = $('height_ft').value;
	var height_inch = $('height_inch').value;
	var temp_brand_prefix = $('temp_brand_prefix').value;
	var prod_master_id = $('prod_master_id').value;
	var isize_range_type = $('isize_range_type').value;
	
	new ajax ('ajax.php', {postBody: 'method=calculate_product_price&temp_state_id='+temp_state_id+'&width_ft='+width_ft+'&width_inch='+width_inch+'&height_ft='+height_ft+'&height_inch='+height_inch+'&temp_brand_prefix='+temp_brand_prefix+'&prod_master_id='+prod_master_id+'&isize_range_type='+isize_range_type, onComplete: calculate_product_price_callback , userVariable:Array()});
	//$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	//$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	//$("WAIT").toggle();
	//$("COVER").toggle();
	//$("COVER").style.height = Screen.getDocumentHeight()+'px';
}
function calculate_product_price_callback(request , variable){
//	$("WAIT").toggle();
//	$("COVER").toggle();
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			if(response.RESULT=="OK"){
					$('product_price').value = response.FINALPRICE;
			}		
		}
	}
	calculateChangeOrder();
}
/* ======================================================================== */
function calculateChangeOrder(){
	var qty = $('quantity').value;
	var price = 0;
	var optname = "";
	if(document.frmChangeOrder.options != null && document.frmChangeOrder.options != "" && document.frmChangeOrder.options != "undefined"){
		var num = document.frmChangeOrder.options.length;
	}else{
		var num = 0;
		var price = 0;
		var optname = "";
	}
	for(i=0;i<num;i++){	
		if(document.frmChangeOrder.options[i].checked == true){
			var val = document.frmChangeOrder.options[i].value;
			var option_data = val.split("_-_");
			optname += option_data[1] +", " ;
			if(option_data[2] == "sq.ft"){
				var fixval = 144;
				var wi = parseFloat($('width_ft').value)+parseFloat($('width_inch').value);
				var he = parseFloat($('height_ft').value)+parseFloat($('height_inch').value);
				var multwh = parseFloat(wi)*parseFloat(he);
				var sqft = parseFloat(multwh)/parseFloat(fixval);
				optprice = parseFloat(sqft)*parseFloat(option_data[3]);
			}else if(option_data[2] == "per window"){
				optprice = option_data[3];
			}else if(option_data[2] == "per UI"){
				var wi = parseFloat($('width_ft').value)+parseFloat($('width_inch').value);
				var he = parseFloat($('height_ft').value)+parseFloat($('height_inch').value);
				var ui = parseFloat(wi)+parseFloat(he);
				optprice = parseFloat(ui)*parseFloat(option_data[3]);
			}else if(option_data[2] == "per sash"){
				optprice = parseFloat(option_data[3])*parseFloat($('temp_panes_edit').value);
			}else if(option_data[2] == "Percent"){
				optprice = (parseFloat(price)*parseFloat(option_data[3]))/100;
			}else if(option_data[2] == "Range"){
				optprice = parseFloat(option_data[3]);
			}else{
				optprice = option_data[3];
			}
			price = parseFloat(price)+parseFloat(optprice);
		}
	}
	var consum_price = (parseFloat($('fprice_0').value)*parseFloat($('consumable_0').value))+(parseFloat($('fprice_1').value)*parseFloat($('consumable_1').value))+(parseFloat($('fprice_2').value)*parseFloat($('consumable_2').value))
	var final_price = (parseFloat($('product_price').value)+parseFloat(price)+parseFloat(consum_price))*$('quantity').value;
	$('amount').innerHTML = final_price.toFixed(2);
	$('final_amount').value = final_price.toFixed(2);
	$('final_options').value = optname.substr(0,optname.length-2);
	$('final_consumables').value = $('consname_0').value+"( "+$('consumable_0').value+" ), "+$('consname_1').value+"( "+$('consumable_1').value+" ), "+$('consname_2').value+"( "+$('consumable_2').value+" )#:#"+$('consumable_0').value+"-|-"+$('consumable_1').value+"-|-"+$('consumable_2').value;
}
/* VALIDATION WHEN SOMEBODY CLICKS ON GET PRICE WITHOUT SELECTING STATE AND PRODUCT DATA */
function checkProductInfo(){
	if($('state').value==0){
		alert('Please select State Value');
		return false;
	}else if($('product_data').innerHTML.length < 200) {
		alert('Please select Product first.');
		return false;
	}else{
		return true;
	}
}
/*-----------------------------------------------------------------------------------------*/
// Show hide the middle portion and its menu tab
function entryValue(){
	$('middle_portion_for_replace').style.display = "none";
	$('product_data').style.display = "block";	
}
// For enable disable submit button
function agreeTerms(){
  	if($('agreement').checked == true){
		$('btn_save').disabled = false;
	}else{
		$('btn_save').disabled = true;	
	}
}
// For adding data into Search
function add_search(){
	state_val = $('state').value;
	vertical_id = $('vertical').value;
	interior_color = $('interior_colors').value;
	exterior_color = $('exterior_colors').value;
	brand_id= $('brands').value;
	app_id = $('app').value;
	style_id = $('styles').value;
	width_val = $('width').value;
	width_inch_val = $('width_inch').value;
	height_val = $('height').value;
	height_inch_val = $('height_inch').value;
	min_price_val = $('demo_from').value;
	max_price_val = $('demo_to').value;

	if(state_val==0){
		return false;
	}else{
		new ajax ('ajax.php', {postBody: 'method=add_search&vertical_id='+vertical_id+'&interior_color='+interior_color+'&exterior_color='+exterior_color+'&brand_id='+brand_id+'&app_id='+app_id+'&style_id='+style_id+'&width='+width_val+'&width_inch='+width_inch_val+'&height='+height_val+'&height_inch='+height_inch_val+'&state_id='+state_val+'&min_price_val='+min_price_val+'&max_price_val='+max_price_val , onComplete: add_search_callback , userVariable:Array()});
//		$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
//		$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
//		$("WAIT").toggle();
//		$("COVER").toggle();
//		$("COVER").style.height = Screen.getDocumentHeight()+'px';
	}
}
function add_search_callback(request){ 
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			if(response.RESULT=="OK"){
			}		
		}
	}
}
function show_brandwise_data(brandpass){
	if(document.getElementById("state").value != 0){
		//document.getElementById("product_row_price").style.display = "none";
		//get_price_list();
		for(i=0;i<document.getElementById("totalproductloop").value;i++){
			var price_brand = document.getElementById("product_row_price"+i).title;
			var brand = price_brand.split("-");//alert(price_brand);
			if(brand[1] == brandpass || brandpass == 0){
				document.getElementById("product_row_price"+i).style.display = "block";
			}else{
				document.getElementById("product_row_price"+i).style.display = "none";
			}	
		}
	}	
}
function get_colorimages(){
	vertical_id = $('vertical').value;
	new ajax('ajax.php', {postBody: 'method=get_colorimages&vertical_id='+vertical_id, onComplete: get_colorimages_callback});
	//$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	//$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	//$("WAIT").toggle();
	//$("COVER").toggle();
	//$("COVER").style.height = Screen.getDocumentHeight()+'px';
}
function get_colorimages_callback(request){
	//$("WAIT").toggle();
	//$("COVER").toggle();
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			if(response.RESULT=="OK"){
				//$('img_color_all').innerHTML = response.ALL_IMAGES;
				$('img_color_all_int').innerHTML = response.ALL_IMAGES;
				$('img_color_all_ext').innerHTML = response.ALL_IMAGES;
			}
		}
	}
}
function calculate_addtocart_popup_dynamic(){
	 var tot_price = parseFloat($('popup_price_ac').value)*parseFloat($('qty').value);	
	 $('windows_base_price').innerHTML = tot_price;
	 var cons_1 = parseFloat($('consumable_price_1').value)*parseFloat($('consumable_1').value);
	 $('cons_1_tot_price').innerHTML = cons_1.toFixed(2);
	 var cons_2 = parseFloat($('consumable_price_2').value)*parseFloat($('consumable_2').value);
	 $('cons_2_tot_price').innerHTML = cons_2.toFixed(2);
	 var cons_3 = parseFloat($('consumable_price_3').value)*parseFloat($('consumable_3').value);
	 $('cons_3_tot_price').innerHTML = cons_3.toFixed(2);
	 var tot_cons = parseFloat(cons_1) + parseFloat(cons_2) + parseFloat(cons_3); 
	 var tot = parseFloat(tot_price) + parseFloat(tot_cons);
	//var tot = parseFloat(tot_price);
	var tot_cons = parseFloat(tot_cons);
	 $('popup_price').innerHTML = tot.toFixed(2);
	 $('popup_price_consums').innerHTML = tot_cons.toFixed(2);
}
function validateValues(){
	if($("qty").value == "" || isNaN($("qty").value) || $("qty").value == "0"){
		$("qty").value = "1";
		alert("Please enter Quantity in Number Greater than 0");	
		$("qty").focus();
		return false;
	}
	if($("consumable_1").value == "" || isNaN($("consumable_1").value)){
		$("consumable_1").value = "0";
		alert("Please enter Consumables in Number");	
		$("consumable_1").focus();
		return false;
	}
	if($("consumable_2").value == "" || isNaN($("consumable_2").value)){
		$("consumable_2").value = "0";
		alert("Please enter Consumables in Number");	
		$("consumable_2").focus();
		return false;
	}
	if($("consumable_3").value == "" || isNaN($("consumable_3").value)){
		$("consumable_3").value = "0";
		alert("Please enter Consumables in Number");	
		$("consumable_3").focus();
		return false;
	}
	calculate_addtocart_popup_dynamic();
}
function convertToFraction(val){
	if ((val % 1)!=0) { 
		var val1 = val.toString();
		newval = val1.split(".");
		if(parseInt(newval[1]) == parseInt("125"))
			return newval[0]+' 1/8';
		if(parseInt(newval[1]) == parseInt("25"))
			return newval[0]+' 1/4';
		if(parseInt(newval[1]) == parseInt("375"))
			return newval[0]+' 3/8';
		if(parseInt(newval[1]) == parseInt("5"))
			return newval[0]+' 1/2';
		if(parseInt(newval[1]) == parseInt("625"))
			return newval[0]+' 5/8';
		if(parseInt(newval[1]) == parseInt("75"))
			return newval[0]+' 3/4';
		if(parseInt(newval[1]) == parseInt("875"))
			return newval[0]+' 7/8';
	}else{
		return val;
	}
}
function setWHValueFromCallOut(val){
	//alert("SET WHVALUE FROM CALLOUT");
	var firstCallout = val;//response.CALLOUT[0];
	var partCallout = firstCallout.split("W");
	var w = partCallout[0];
	var partCalloutH = partCallout[1].split("H");
	var h = partCalloutH[0];
	$('width').value = w;
	$('height').value = h;//alert("H");
	//$('widthTempToShow').innerHTML = w;
	//$('heightTempToShow').innerHTML = h;
	//get_price_list();
}
function setWHValueFromCallOutForEditOrder(val){
	var firstCallout = val;//response.CALLOUT[0];
	var partCallout = firstCallout.split("W");
	var w = partCallout[0];
	var partCalloutH = partCallout[1].split("H");
	var h = partCalloutH[0];//alert(w);alert(h);
	$('width_ft').value = w;
	$('height_ft').value = h;
	
	calculate_product_price();
}
function open_subtab_content(tab_id,brand_name){
	if(tab_id == 1){
		if($('#'+brand_name+'tab'+tab_id) != null){
			$('#'+brand_name+'tab'+tab_id).setAttribute('class',"yui-hidden");
		}
	}else{
		if($('#'+brand_name+'tab'+tab_id) != null){
			$('#'+brand_name+'tab'+tab_id).setAttribute('class',"");
		}
	}
}
function get_stock_windows(selected_id){
	state_val = $('state').value;
	vertical_id = $('vertical').value;
	interior_color = $('interior_colors').value;
	exterior_color = $('exterior_colors').value;
	brand_id= $('brands').value;
	app_id = $('app').value;
	style_id = $('styles').value;
	width_val = $('width').value;
	width_inch_val = $('width_inch').value;
	height_val = $('height').value;
	height_inch_val = $('height_inch').value;
	min_price_val = $('demo_from').value;
	max_price_val = $('demo_to').value;
	// FOr Doors Storms and other have Replacement only so no need to so New product
	if(vertical_id == '2' || vertical_id == '3' || vertical_id == '9'){
		$("app").value="1";
		$("app").disabled="disabled";
	}else{
		$("app").disabled="";	
	}		
	if(state_val==0){
		alert('Please select State Value');
		return false;
	}else{
		//takealloptions();
		new ajax ('ajax.php', {postBody: 'method=stock_windows&vertical_id='+vertical_id+'&interior_color='+interior_color+'&exterior_color='+exterior_color+'&brand_id='+brand_id+'&app_id='+app_id+'&style_id='+style_id+'&width='+width_val+'&width_inch='+width_inch_val+'&height='+height_val+'&height_inch='+height_inch_val+'&state_id='+state_val+'&min_price_val='+min_price_val+'&max_price_val='+max_price_val+'&selected_id='+selected_id , onComplete: get_stock_windows_callback , userVariable:Array(width_val,height_val,interior_color,exterior_color,min_price_val,max_price_val,width_inch_val,height_inch_val,vertical_id,state_val)});
		$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
		$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
		$("WAIT").toggle();
		$("COVER").toggle();
		$("COVER").style.height = Screen.getDocumentHeight()+'px';
	}
}
function get_stock_windows_callback(request , variable){
	$("WAIT").toggle();
	$("COVER").toggle();
	var width = variable[0];
	var height = variable[1];
	var interior_color = variable[2];
	var exterior_color = variable[3];
	// PRICES FROM SLIDER
	var min_price = variable[4];
	var max_price = variable[5];
	var width_inch = variable[6];
	var height_inch = variable[7];
	var vertical_id = variable[8];
	var state_id = variable[9];
	var final_width = parseFloat(width)+parseFloat(width_inch);
	var final_height = parseFloat(height)+parseFloat(height_inch);
	var temp_maximum_price=0;
	var temp_minimum_price=0;
	var totalproductloop=0;
	var fraction_final_width = convertToFraction(final_width);
	var fraction_final_height = convertToFraction(final_height);
	/**** variable to display tab in option popup ***/
	/*wholesale = false;
	crystal = false;
	simonton = false;
	lang = false;*/
	/***********************************************/
	//$('product_data').update("");
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			if(response.RESULT=="OK"){	
				//var stock = response.RSSTOCK;
				if(response.LIST_STOCK != ""){
					//$('stock_vsku').innerHTML = stock[0].vsku;
					//$('stock_color').innerHTML = stock[0].color;
					//$('stock_option').innerHTML = stock[0].option;
					//$('stock_price').innerHTML = "$ "+stock[0].price;
					//$('stock_qty').innerHTML = stock[0].stock;
					//$('stock_sold').innerHTML = stock[0].sold;
					//if($('app').value == 2){
					//	$('app_popup1').checked = true;
					//}else if($('app').value == 1){
					//	$('app_popup2').checked = true;
					//}
					$('list_stock').innerHTML = response.LIST_STOCK;
				}else{
					//$('stock_vsku').innerHTML = "";
					//$('stock_color').innerHTML = "";
					//$('stock_option').innerHTML = "";
					//$('stock_price').innerHTML = "";
					//$('stock_qty').innerHTML = "";
					//$('stock_sold').innerHTML = "";
					alert("Cannot find result for given value data.Pls try again with other option.");	
					$('list_stock').innerHTML = "No Records Found";
				}
			}
		}else{
			alert('An error occurred while searching. Please contact our office at 8665899367 or email sales@customorderonline.com for assistance');
			return false;
		}
	}
}
/* ======== To displays the stock windows popup on clicking on question mark  =============== */
function show_stock_windows_popup(info_name,info_desc){
//	info_name = unescape(info_name);
//	info_desc = unescape(info_desc);
	$("stock_windows_popup").style.left = (Screen.getViewportWidth()/2 - (400/2))+"px";
	$("stock_windows_popup").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-150)+"px";
	///$("info_name").innerHTML = "<strong>"+info_name+"</strong>";
	//$("info_desc").innerHTML = info_desc;
	$("stock_windows_popup").toggle();
	$("stock_windows").toggle();
//	var abc = get_stock_windows();	
	if(get_stock_windows() == false){
		hide_stock_windows_popup();	
	}
	//$("option_desc").style.height = Screen.getDocumentHeight()+'px';
}
/* =============================================================================== */
/* ======== Hide displays the stock windows popup  =============== */
function hide_stock_windows_popup(){
	$("stock_windows_popup").toggle();
	$("stock_windows").toggle();
}
/* =============================================================================== */
function add_to_cart_for_stock(id, brand, width, height, color, option, price, app, state){ 
	var id_ac = id;
	var brand_ac = brand;
	var w_ac = width;
	var h_ac = height;
	var int_color_ac = color;
	var ext_color_ac = color;
	//var additional_info_ac = $('additional_info_ac').value;
	var options_ac = option;
	var price_ac = price;
	var state_ac = state;
	var app_ac = app;
	//var quality_ac = $('quality').value;
	//var ext_color_ac = $(+'ext_color_ac').value;option_wwh_16_price    option_wwh_16

	var qty = $('st_qty_'+id).value;
	//var consumable = $('consumable').value;
	if(qty == "" || qty <= 0){
		alert('Please enter proper Value of Quantity');
		return false;
	}else{
		new ajax ('ajax.php', {postBody: 'method=add_to_cart_for_stock&product_master_id='+id_ac+'&brand_prefix='+brand_ac+'&width='+w_ac+'&height='+h_ac+'&interior_color='+int_color_ac+'&exterior_color='+ext_color_ac+'&quantity='+qty+'&options_ac='+options_ac+'&price_ac='+price_ac+'&state_id='+state_ac+'&app_id='+app_ac , onComplete: add_to_cart_for_stock_callback , userVariable:Array()});
		$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
		$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
		$("WAIT").toggle();
		$("COVER").toggle();
		$("COVER").style.height = Screen.getDocumentHeight()+'px';
	}
}

function add_to_cart_for_stock_callback(request , variable){
	$("WAIT").toggle();
	$("COVER").toggle();
	//alert(request.responseText);
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			//alert(response.FINALCARTPRICE);
			hide_stock_windows_popup();	
			if(response.RESULT=="OK"){
					$('final_price_cart').innerHTML = "$ "+response.FINALCARTPRICE;
					if(response.FINALCARTPRICE == "" || response.FINALCARTPRICE == "0.00" || response.FINALCARTPRICE == "0"){
						$('shopping_cart_img').innerHTML = '<img src="images/emptyshoppingcart.png" border="0"/>';
					}else{
						$('shopping_cart_img').innerHTML = '<img src="images/fullshoppingcart.png" border="0"/>';	
					}
					shopping_cart('');
			}
		}
	}
}
function get_style_related_data(){
	//alert("GET DATA");
	vertical_id = $('vertical').value;
	interior_color = $('interior_colors').value;
	exterior_color = $('exterior_colors').value;
	brand_id = $('brands').value;
	style_id = $('styles').value;
	//	alert(style_id);
	new ajax('ajax.php', {postBody: 'method=get_style_related_data&vertical_id='+vertical_id+'&interior_color='+interior_color+'&exterior_color='+exterior_color+'&brand_id='+brand_id+'&style_id='+style_id, onComplete: get_style_related_data_callback});
	$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	$("WAIT").toggle();
	$("COVER").toggle();
	$("COVER").style.height = Screen.getDocumentHeight()+'px';
}
function get_style_related_data_callback(request){
	/* ADDED BY VISHAL SHAH */
	if($('vertical').value == 11){
			document.getElementById('door_window').innerHTML = "Window";
	}else{
		document.getElementById('door_window').innerHTML = "Door";
	}
	/* ADDED BY VISHAL SHAH */
	$("WAIT").toggle();
	$("COVER").toggle();
	//alert("GET DATA CALLBACK : " + request.responseText);
	vertical_cmb = $('vertical');
	int_color_cmb = $('interior_colors');
	ext_color_cmb = $('exterior_colors');
	brand_cmb = $('brands');
	callout_cmb = $('callouts');
	int_color_index = int_color_cmb.selectedIndex;
	ext_color_index = ext_color_cmb.selectedIndex;
//alert(response.DEFAULT_WIDTH);alert(response.DEFAULT_HEIGHT);
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			int_cmb = int_color_cmb.options.length;
			for(i=0; i< int_cmb; i++){
				int_color_cmb.options[0] = null;
			}
			ext_cmb = ext_color_cmb.options.length;
			for(i=0; i< ext_cmb; i++){
				ext_color_cmb.options[0] = null;
			}
			br_cmb = brand_cmb.options.length;
			for(i=0; i< br_cmb; i++){
				brand_cmb.options[0] = null;
			}
			co_cmb = callout_cmb.options.length;
			for(i=0; i< co_cmb; i++){
				callout_cmb.options[0] = null;
			}
			if(response.RESULT=="OK"){
				if(response.INTERIOR_ID.length>0){
					for(i=0; i<response.INTERIOR_ID.length; i++){
						var optn = new Option();
						optn.value = response.INTERIOR_ID[i];
						optn.text = response.INTERIOR_VALUES[i];
						if(response.INTERIOR_VALUES[i] == response.DEFAULT_INT_COLOR)
							optn.selected = " Selected";
						int_color_cmb.options[int_color_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = 0;
					optn.text = "No Color Found";
					int_color_cmb.options[int_color_cmb.options.length] = optn;
				}
				if(response.EXTERIOR_ID.length>0){
					for(i=0; i<response.EXTERIOR_ID.length; i++){
						var optn = new Option();
						optn.value = response.EXTERIOR_ID[i];
						optn.text = response.EXTERIOR_VALUES[i];
						if(response.EXTERIOR_VALUES[i] == response.DEFAULT_EXT_COLOR)
							optn.selected = " Selected";
						ext_color_cmb.options[ext_color_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = 0;
					optn.text = "No Color Found";
					ext_color_cmb.options[ext_color_cmb.options.length] = optn;
				}
				if(response.BRAND_ID.length>0){
					if(response.BRAND_ID.length > 1){
						var optn = new Option();
						optn.value = '0';
						optn.text = 'All Brands';
						brand_cmb.options[brand_cmb.options.length] = optn;
					}
					for(i=0; i<response.BRAND_ID.length; i++){
						var optn = new Option();
						optn.value = response.BRAND_ID[i];
						optn.text = response.BRAND_VALUES[i];
						brand_cmb.options[brand_cmb.options.length] = optn;
					}
				}else{
					var optn = new Option();
					optn.value = 0;
					optn.text = "No Brand Found";
					brand_cmb.options[brand_cmb.options.length] = optn;
				}
				if(response.CALLOUT != ""){
					var default_val = response.DEFAULT_CALLOUT;	
					$('callout').style.display = "block";
					$('nocallout').style.display = "none";
					
					//alert(response.CALLOUT.length);
					if(response.CALLOUT.length>0){
						for(i=0; i<response.CALLOUT.length; i++){
							var optn = new Option();
							optn.value = response.CALLOUT[i];
							optn.text = response.CALLOUT[i];
							if(optn.value == default_val)
								optn.selected = " Selected";
							/*if(i == 0)
								optn.selected = " Selected";*/
							callout_cmb.options[callout_cmb.options.length] = optn;
						}
					}else{
						var optn = new Option();
						optn.value = 0;
						optn.text = "No Callout Found";
						callout_cmb.options[callout_cmb.options.length] = optn;
					}
					//setWHValueFromCallOut(response.CALLOUT[0]);
					setWHValueFromCallOut(default_val);
					get_price_list();
/*					var firstCallout = response.CALLOUT[0];
					var partCallout = firstCallout.split("W");
					var w = partCallout[0];
					var partCalloutH = partCallout[1].split("H");
					var h = partCalloutH[0];
					$('width').value = w;
					$('height').value = h;
					$('widthTempToShow').innerHTML = w;
					$('heightTempToShow').innerHTML = h;
*/				}else{
					$('callout').style.display = "none";
					$('nocallout').style.display = "block";
					$('width').value = response.DEFAULT_WIDTH;
					$('height').value = response.DEFAULT_HEIGHT;
					get_price_list();
				}
			}
		}
	}
}

function start_album_image_upload(){
	document.getElementById('feedback').style.display = 'none';
    document.getElementById("WAIT1").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	document.getElementById("WAIT1").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	document.getElementById("WAIT1").style.display = '';
	document.getElementById("COVER1").style.display = '';
	document.getElementById("COVER1").style.height = Screen.getDocumentHeight()+'px';
    return true;
}

function album_image_upload_done(success,ext){
	document.getElementById("WAIT1").style.display = 'none';
	document.getElementById("COVER1").style.display = 'none';   
	if (success == 1){
		alert("Your Feedback has been sent sucessfully!!");
		window.location.reload();
	}else {
		alert("There is some problem in sending email to customers right now !!\n\nPlease try later on");
	}  
	return true;   
}

function start_shipping_claim_upload(){
	document.getElementById('shipping_claim').style.display = 'none';
    document.getElementById("WAIT1").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	document.getElementById("WAIT1").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	document.getElementById("WAIT1").style.display = '';
	document.getElementById("COVER1").style.display = '';
	document.getElementById("COVER1").style.height = Screen.getDocumentHeight()+'px';
    return true;
}

function shipping_claim_upload_done(success,ext){
	document.getElementById("WAIT1").style.display = 'none';
	document.getElementById("COVER1").style.display = 'none'; 	
	if (success == 1){
		alert("Your Shipping Claim Has been submitted Sucessfully.");
		window.location.reload();
	}else {
		alert("Shipping Claim Upload Failed !!\n\nPlease try later on");
	}  
	return true;   
}

function start_warranty_claim_upload(){
	document.getElementById('warranty_claim').style.display = 'none';
    document.getElementById("WAIT1").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	document.getElementById("WAIT1").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	document.getElementById("WAIT1").style.display = '';
	document.getElementById("COVER1").style.display = '';
	document.getElementById("COVER1").style.height = Screen.getDocumentHeight()+'px';
    return true;
}

function warranty_claim_upload_done(success,ext){
	document.getElementById("WAIT1").style.display = 'none';
	document.getElementById("COVER1").style.display = 'none'; 	
	if (success == 1){
		alert("Your Warranty Claim Has been submitted Sucessfully.");
		window.location.reload();
	}else {
		alert("Warranty Claim Upload Failed !!\n\nPlease try later on");
	}  
	return true;   
}

function apply_popular_options_add_to_cart(id,brand){
	var optname;
	var final_price;	
	var final_base_price;	
	var h;
	var m;
	var i;
	var j;
	var k;
	var n;
	var price;
	var optprice;
	var temp_maximum_price=0;
	var temp_minimum_price=0;
	$("WAIT").style.left = (Screen.getViewportWidth()/2 - (300/2))+"px";
	$("WAIT").style.top = (Screen.getScrollTop()+(Screen.getViewportHeight()/2)-50)+"px";
	$("WAIT").toggle();
	$("COVER").toggle();
	$("COVER").style.height = Screen.getDocumentHeight()+'px';
	for(m=0;m<selected_id.length;m++){
		optname="<strong>Options: </strong> <span style='color:#600'>";
		final_price="<strong>$ ";
		final_base_price="<strong>$ ";//alert(selected_id[m]);
		var sel_id = selected_id[m].split(":");//alert(sel_id[0]+" == "+brand+" && "+sel_id[1]+" == "+id);
		if(sel_id[0] == brand && sel_id[1] == id){
			price = parseFloat(sel_id[2]);
			base_price = parseFloat(sel_id[3]);
			if(document.getElementById('option_'+sel_id[0]+'_'+sel_id[1]) != null){
				for(j=0;j<document.forms.length;j++){
					for(i=0;i<document.forms[j].length;i++){
						for(k=0;k<selected_brandname.length;k++){	
							if(document.forms[j].name == selected_brandname[k].toLowerCase() && sel_id[0] == selected_brand[k]){									
								if(document.forms[j].chk[i].checked == true){
									//var optname = selected_brand[k]+"_html";
									var firsttemp = document.forms[j].chk[i].value;
									var secondtemp = firsttemp.split("_");
									var tempformval = secondtemp[0];
									for(n=0;n<optionproductrelation.length;n++){
									//OPTIONDATA : wwh_16_26_6.97_1_2009 Stimulus Tax Credit for Windows
									// 5th argument Option Unit....1=per sq.ft,2=per window,3=per UI,4=per sash,5=Percent
										var option_data = optionproductrelation[n].split("_");//alert(optionproductrelation[n]);
										if(tempformval == option_data[2]){//alert(option_data[2]);
											if(sel_id[0] == option_data[0]){
												if(sel_id[1] == option_data[1]){
													// Options values set from here
													//optname += tempformval +", " ;//alert(optname);alert(option_data[4]);
													optname += option_data[5] +", " ;
													// Price calculation goes here.
													if(option_data[4] == 1){
														var fixval = 144;
														var wi = parseFloat($('width').value)+parseFloat($('width_inch').value);
														var he = parseFloat($('height').value)+parseFloat($('height_inch').value);
														var multwh = parseFloat(wi)*parseFloat(he);
														var sqft = parseFloat(multwh)/parseFloat(fixval);
														optprice = parseFloat(sqft)*parseFloat(option_data[3]);
													}else if(option_data[4] == 2){
														optprice = parseFloat(option_data[3]);
													}else if(option_data[4] == 3){
														var wi = parseFloat($('width').value)+parseFloat($('width_inch').value);
														var he = parseFloat($('height').value)+parseFloat($('height_inch').value);
														var ui = parseFloat(wi)+parseFloat(he);
														optprice = parseFloat(ui)*parseFloat(option_data[3]);
													}else if(option_data[4] == 4){
														optprice = parseFloat(option_data[3])*parseFloat($('temp_panes').value);
													}else if(option_data[4] == 5){
														optprice = (parseFloat(price)*parseFloat(option_data[3]))/100;
													}else if(option_data[4] == 6){
														optprice = parseFloat(option_data[3]);
													}else{
														optprice = parseFloat(option_data[3]);
													}
													price = parseFloat(price)+parseFloat(optprice);//alert(price);
													base_price = parseFloat(base_price)+parseFloat(optprice);
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			optname = optname.substr(0,optname.length-2);
			optname += "</span>";
			var final_set_price = price.toFixed(2);
			var final_set_base_price = base_price.toFixed(2);
			final_price += final_set_price+"</strong>";
			final_base_price += final_set_base_price+"</strong>";
			final_online_disc_price = (price/9).toFixed(2);
			final_our_disc_price = (base_price - final_online_disc_price - price).toFixed(2);
			if($('option_'+sel_id[0]+'_'+sel_id[1]) != null)
				$('option_'+sel_id[0]+'_'+sel_id[1]).update(optname);
			if($('option_'+sel_id[0]+'_'+sel_id[1]+'_price') != null){	
				$('option_'+sel_id[0]+'_'+sel_id[1]+'_price').update(final_price);
				$('option_'+sel_id[0]+'_'+sel_id[1]+'_base_price').update(final_base_price);
				$('popup_price').update(final_set_price);
				//$('option_'+sel_id[0]+'_'+sel_id[1]+'_our_disc_price').update("(<strong>$ "+final_our_disc_price+"</strong>)");
				//$('option_'+sel_id[0]+'_'+sel_id[1]+'_online_disc_price').update("(<strong>$ "+final_online_disc_price+"</strong>)");
				$('option_'+sel_id[0]+'_'+sel_id[1]+'_our_disc_price').update("<strong> "+final_our_disc_price+"</strong>");
				$('option_'+sel_id[0]+'_'+sel_id[1]+'_online_disc_price').update("<strong> "+final_online_disc_price+"</strong>");
			}
			if(parseFloat(final_set_price) >= parseFloat(final_set_base_price)){
				$('retail_'+sel_id[0]+'_'+sel_id[1]+'_table').style.display = "none";	
			}else{
				$('retail_'+sel_id[0]+'_'+sel_id[1]+'_table').style.display = "block";	
			}
			// SET SLIDER AS PER OPTION CHANGES START	
			var price_brand = $('product_row_price'+m).title;
			var dash_price_brand = price_brand.split("-");
			$('product_row_price'+m).title = final_set_price+"-"+dash_price_brand[1];
			//SET MIN AND MAX VALUE OF SLIDER
			if((parseFloat(final_set_price) >= parseFloat(temp_maximum_price)) || temp_maximum_price == 0)
			{
				temp_maximum_price = parseFloat(final_set_price);
			}
			if((parseFloat(final_set_price) <= parseFloat(temp_minimum_price)) || temp_minimum_price == 0)
			{
				temp_minimum_price = parseFloat(final_set_price);
			}
			$('final_min_price').innerHTML = temp_minimum_price;
			$('final_max_price').innerHTML = temp_maximum_price;
			$('demo_from').value = temp_minimum_price;
			$('demo_to').value = temp_maximum_price;
			$('temp_demo_from').value = temp_minimum_price;
			$('temp_demo_to').value = temp_maximum_price;
		}
		// SET SLIDER AS PER OPTION CHANGES END
	}
	$("WAIT").toggle();
	$("COVER").toggle();
	//take_all_row_for_sort(all_product_rows.length,sort_by);
	//do_sorting();
}
function add_to_cart_options(qty,name){
	$(name).value = qty;
	calculateCart();
}
function add_to_cart_options_apply(qty,name,order_nums,price){
	new ajax('ajax.php', {postBody: 'method=remaining_options_apply&name='+name+'&order_nums='+order_nums+'&price='+price, onComplete: add_to_cart_options_apply_callback});
}
function add_to_cart_options_apply_callback(request){//alert("End");
	//$("WAIT").toggle();
	//$("COVER").toggle();
	//alert(request.responseText);
	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			//alert(request.responseText);
			if(response.RESULT=="OK"){//alert("H");
				shopping_cart('');
			}
		}
	}//alert("es");
}
function add_to_cart_joplin_fund(){
	if($('joplin_fund1').checked == true){
		$('joplin_fund').value = $('joplin_fund1').value;
		$('joplin_fund').readOnly = true;
	}else if($('joplin_fund2').checked == true){
		$('joplin_fund').value = $('joplin_fund2').value;
		$('joplin_fund').readOnly = true;
	}else if($('joplin_fund3').checked == true){
		$('joplin_fund').value = $('joplin_fund3').value;
		$('joplin_fund').readOnly = true;
	}else if($('joplin_fund4').checked == true){
		$('joplin_fund').value = $('joplin_fund4').value;
		$('joplin_fund').readOnly = false;
	}
	calculateCart();
	//$(name).value = val;
	//calculateCart();
}
function select_by_popular_option_add_to_cart(chkbox){
	var val = chkbox.value;
	var flag = false;
	if(chkbox.checked == true)
		flag = true;
	else
		flag = false;
	for(j=0;j<document.forms.length;j++){
		for(i=0;i<document.forms[j].length;i++){
			var opt_id = document.forms[j].chk[i].value;
			var myopt_id = opt_id.split("_");
			if(myopt_id[1] == val){
				document.forms[j].chk[i].checked = flag;
			}
		}
	}
}
function calculate_cart_after_pickup(pickup_cost,qty){
		$('pickup_confirm').checked = true;
		$('span_pickup_confirm').style.display = "block";
		$('lift_gate_service').checked = false;
		$('lift_gate_service').disabled = true;
		$('save_quote').disabled = true;
		
		var fp = $('final_price').value;
		//var sc = $('shipping_charge').value;
		var sc = 0;
		// For Extra Calculation of Tube of Caulking and etc...
		var toce = $('tube_of_caulking_extra').value;
		var wike = $('window_installation_kit_extra').value;
		var mcte = $('matching_coil_stock_extra').value;
		var la = $('lowe_argon_extra').value;
		var cg = $('colonial_grids_extra').value;
		var toce_price = $('tube_of_caulking_extra_price').value;
		var wike_price = $('window_installation_kit_extra_price').value;
		var mcte_price = $('matching_coil_stock_extra_price').value;
		var la_price = $('lowe_argon_extra_price').value;
		var cg_price = $('colonial_grids_extra_price').value;
		/// JOPLIN FUND ///
		var joplin_fund_temp = $('joplin_fund').value;
		
		if(toce == "" || isNaN(toce) || parseFloat(toce) < 0){
			$('tube_of_caulking_extra').value = 0;
			toce = 0;
		}
		if(wike == "" || isNaN(wike) || parseFloat(wike) < 0){
			$('window_installation_kit_extra').value = 0;
			wike = 0;
		}
		if(mcte == "" || isNaN(mcte) || parseFloat(mcte) < 0){
			$('matching_coil_stock_extra').value = 0;
			mcte = 0;
		}
		if(la == "" || isNaN(la) || parseFloat(la) < 0){
			$('lowe_argon_extra').value = 0;
			la = 0;
		}
		if(cg == "" || isNaN(cg) || parseFloat(cg) < 0){
			$('colonial_grids_extra').value = 0;
			cg = 0;
		}
		if(joplin_fund_temp == "" || isNaN(joplin_fund_temp) || parseFloat(joplin_fund_temp) < 0){
			$('joplin_fund').value = 0;
			joplin_fund_temp = 0;
		}
		var tot_toce = parseFloat(toce)*parseFloat(toce_price);
		$('tube_of_caulking_extra_fnl').innerHTML = tot_toce.toFixed(2);
		$('tot_tub_total_consum').innerHTML = parseInt(toce) + parseInt($('tub_total_consum').value);	
		var tot_wike = parseFloat(wike)*parseFloat(wike_price);
		$('window_installation_kit_extra_fnl').innerHTML = tot_wike.toFixed(2);	
		$('tot_win_total_consum').innerHTML = parseInt(wike) + parseInt($('win_total_consum').value);	
		var tot_mcte = parseFloat(mcte)*parseFloat(mcte_price);
		$('matching_coil_stock_extra_fnl').innerHTML = tot_mcte.toFixed(2);	
		$('tot_mat_total_consum').innerHTML = parseInt(mcte) + parseInt($('mat_total_consum').value);	
		var tot_la = parseFloat(la)*parseFloat(la_price);
		var tot_cg = parseFloat(cg)*parseFloat(cg_price);
		$('options_qty_val').innerHTML = parseInt(la) + parseInt(cg);	
		var total_extra_consumables = parseFloat(tot_toce) + parseFloat(tot_wike) + parseFloat(tot_mcte) + parseFloat(tot_la) + parseFloat(tot_cg);
		// Above total_extra_consumbles variable added below
		// For Extra Calculation of Tube of Caulking and etc...
		if($('lift_gate_service').checked == true){
			var lgs = "48.00";	
		}else{
			var lgs = "0.00";			
		}
		if($('inside_delivery_service').checked == true){
			var ids = "98.00";	
		}else{
			var ids = "0.00";			
		}
		var pickup_discount = parseFloat(pickup_cost*qty);
		var ot = parseFloat(fp)+parseFloat(sc)+parseFloat(lgs)+parseFloat(ids)+parseFloat(total_extra_consumables)+parseFloat(joplin_fund_temp)-parseFloat(pickup_discount);
		$('shipping_charge').value = sc;
		$('shipping_charge_val').innerHTML = "<b>$ "+sc.toFixed(2)+"</b>";
		$('lift_service').value = lgs;
		$('lift_service_val').innerHTML = "<b>$ "+lgs+"</b>";
		$('inside_service').value = ids;
		$('inside_service_val').innerHTML = "<b>$ "+ids+"</b>";
		// EXTRA CONSUMABLES:	
		$('total_extra_consumables').value = total_extra_consumables;
		$('total_extra_consumables_val').innerHTML = "<b>$ "+total_extra_consumables.toFixed(2)+"</b>";
		$('lowe_argon_extra_fnl').innerHTML = tot_la.toFixed(2);	
		$('colonial_grids_extra_fnl').innerHTML = tot_cg.toFixed(2);
		$('joplin_fund_val').innerHTML = "<b>$ "+parseFloat(joplin_fund_temp).toFixed(2)+"</b>";
		$('pickup_discount').value = pickup_discount;
		$('pickup_discount_val').innerHTML = "<b>$ "+pickup_discount.toFixed(2)+"</b>";	
		// EXTRA CONSUMABLES:	
		$('order_total').value = ot;
		$('order_total_val').innerHTML = "<b>$ "+ot.toFixed(2)+"</b>";
}

function remove_pickup(pickup_cost,qty){
		$('span_pickup_confirm').style.display = "none";
		$('pickup_confirm').checked = false;
		$('save_quote').disabled = false;
		
		var el_collection=eval("document.forms.cart_form.pickup_address_id");
		if(el_collection.length > 0){
			for (c=0;c<el_collection.length;c++){
				el_collection[c].checked=false;
			}
		}else{
			$('pickup_address_id').checked = false; //this done using above
		}
		var temp_val = $('temp_shipping_charge_for_pickup').value;
		$('shipping_charge').value = temp_val; 
		$('shipping_charge_val').innerHTML = "<b>$ "+temp_val+"</b>";
		$('pickup_discount').value = "0.00";
		$('pickup_discount_val').innerHTML = "<b>$ 0.00</b>";
		
		$('lift_gate_service').checked = true;
		$('lift_gate_service').disabled = false;
		
		calculateCart();
}
function convertToFraction_exact_1by2(val){
	val = parseFloat(val) - parseFloat(0.5);
	if ((val % 1)!=0) { 
		var val1 = val.toString();
		newval = val1.split(".");
		if(parseInt(newval[1]) == parseInt("125"))
			return newval[0]+' 1/8';
		if(parseInt(newval[1]) == parseInt("25"))
			return newval[0]+' 1/4';
		if(parseInt(newval[1]) == parseInt("375"))
			return newval[0]+' 3/8';
		if(parseInt(newval[1]) == parseInt("5"))
			return newval[0]+' 1/2';
		if(parseInt(newval[1]) == parseInt("625"))
			return newval[0]+' 5/8';
		if(parseInt(newval[1]) == parseInt("75"))
			return newval[0]+' 3/4';
		if(parseInt(newval[1]) == parseInt("875"))
			return newval[0]+' 7/8';
	}else{
		return val;
	}
}
function convertToFraction_exact_3by4(val){
	val = parseFloat(val) - parseFloat(0.75);
	if ((val % 1)!=0) { 
		var val1 = val.toString();
		newval = val1.split(".");
		if(parseInt(newval[1]) == parseInt("125"))
			return newval[0]+' 1/8';
		if(parseInt(newval[1]) == parseInt("25"))
			return newval[0]+' 1/4';
		if(parseInt(newval[1]) == parseInt("375"))
			return newval[0]+' 3/8';
		if(parseInt(newval[1]) == parseInt("5"))
			return newval[0]+' 1/2';
		if(parseInt(newval[1]) == parseInt("625"))
			return newval[0]+' 5/8';
		if(parseInt(newval[1]) == parseInt("75"))
			return newval[0]+' 3/4';
		if(parseInt(newval[1]) == parseInt("875"))
			return newval[0]+' 7/8';
	}else{
		return val;
	}
}
