function chkValidation(){ 
	if($('state').value==0){
		alert('Please select State Value');
		return false;
	}	
}
function enableall_mini_applet(){
	if($("state").value){
		$("vertical").disabled="";
		$("brands").disabled="";
		$("interior_colors").disabled="";
		$("exterior_colors").disabled="";
		$("app").disabled="";
		$("styles").disabled="";
		$("width").disabled="";
		$("width_inch").disabled="";
		$("height").disabled="";
		$("height_inch").disabled="";
		$("callouts").disabled="";
		//set_product_tab();		
	}else{
		$("vertical").disabled="disabled";
		$("brands").disabled="disabled";
		$("interior_colors").disabled="disabled";
		$("exterior_colors").disabled="disabled";
		$("app").disabled="disabled";
		$("styles").disabled="disabled";
		$("width").disabled="disabled";
		$("width_inch").disabled="disabled";
		$("height").disabled="disabled";
		$("height_inch").disabled="disabled";
		$("callouts").disabled="disabled";
	}
	var index = $("state").selectedIndex;
	var label = $("state")[index].text;
	$("state_label").innerHTML = "State :<strong> "+label+"</strong>";
	$("state").style.display = "none";
	$("state_label").style.display="";
	//get_price_list();
	get_data_mini_applet();
}
function get_data_mini_applet(){
		
	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_mini_applet});
	$("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_mini_applet(request){

	$("WAIT").toggle();
	$("COVER").toggle();
//alert(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;
			}

			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;
				}//alert(response.CALLOUT);
				if(response.CALLOUT != ""){
					$('callout').style.display = "block";
					$('nocallout').style.display = "none";
					if(response.CALLOUT.length>0){
						
						for(i=0; i<response.CALLOUT.length; i++){//alert(response.CALLOUT[i]);
							var optn = new Option();
							optn.value = response.CALLOUT[i];
							optn.text = response.CALLOUT[i];
							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_mini_applet(response.CALLOUT[0]);
/*					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_mini_applet();
				}
			}
		}
	}
}

function setWHValueFromCallOut_mini_applet(val){
	var firstCallout = val;alert(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;
	//$('widthTempToShow').innerHTML = w;
	//$('heightTempToShow').innerHTML = h;
	
	get_price_list_mini_applet();
}

function get_price_list_mini_applet(){
	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 = 0;
	max_price_val = 50000;
	// 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="";	
	}	//alert('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);
	
	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_mini_applet , 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_mini_applet(request , variable){

	$("WAIT").toggle();
	$("COVER").toggle();
	//alert(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;*/
	/***********************************************/
	//alert("HP");
	//alert(request.responseText);
	//alert(response);
	$('product_data').update("");

	if(request!=null){
		if(request.responseText.isJSON()){	
			response = request.responseText.evalJSON();
			if(response.RESULT=="OK"){	
				// SET DYNAMIC SIZE FOR THE PRODUCT
				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;
				//alert(num_total_brand_in_table);
				for(q = 1; q < num_total_brand_in_table; q++)
				{
					//alert('TOP1-'+q+$(q+'__1'));alert('TOP2-'+q+$(q+'__2'));
					if(($(q+'__1') != null && $(q+'__2') != null) || ($(q+'__1') == "block" && $(q+'__2') == "block"))
					{	
						$(q+'__1').style.display = "none";
						$(q+'__2').style.display = "none";
					}
				}
	
				//alert(response.ALL_BRAND[0].name);
				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];
						//alert(optionproductrelation[x]);
						//var brand_name = response.ALL_BRAND[i].name;
						//brand_name_exist[brand_name.toLowerCase()] = brand_name.toLowerCase();//alert(brand_name_exist);
						//brand_name_exist[brand_name.toLowerCase()] = false;//alert(brand_name_exist);
					}
				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++;
						//alert(selected_brand[h]+"=="+h);
						//alert(prop);
						for(i=0; i<response.PRODUCT[prop].length; i++){//alert(i);
							id= response.PRODUCT[prop][i].id;
							vsku= response.PRODUCT[prop][i].vsku; 
							image= response.PRODUCT[prop][i].vimage;
							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
							//alert("PRICE: "+price);
							if((parseFloat(price) >= parseFloat(temp_maximum_price)) || temp_maximum_price == 0)
							{//alert("MAX PRICE: "+temp_maximum_price);
								temp_maximum_price = parseFloat(price);
								//alert("NOW MAX PRICE: "+temp_maximum_price);
							}
							if((parseFloat(price) <= parseFloat(temp_minimum_price)) || temp_minimum_price == 0)
							{//alert("MIN PRICE: "+temp_minimum_price);
								temp_minimum_price = parseFloat(price);
								//alert("NOW MIN PRICE: "+temp_minimum_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;//alert(brand_id);
							brand_name = response.PRODUCT[prop][i].brand_name;//alert(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+"'}, ";

							//alert(picture_image_set);
							//alert(z+"=="+prop+"=="+id+"==key="+prop+":"+id);
							//alert(i);
							if(m%2 == 0){
								bg = '';				
							}else{
								bg = '#F3F3FF';						
							}//alert(parseFloat(price));alert(parseFloat(min_price));alert(parseFloat(max_price));
							//alert(brand_id);
							//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.
							//alert('SECOND1-'+brand_id+$(brand_id+'__1'));alert('SECOND2-'+brand_id+$(brand_id+'__2'));
							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="65" align="left" valign="top"  style="padding:5px 0px 5px 0px" class="content_3">&nbsp;</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"><a href="javascript:;" onclick=\'show_add_to_cart_popup("'+id+'","'+prop+'","'+final_width+'","'+final_height+'","'+interior_color+'","'+exterior_color+'","'+iaddinfo+'");\'><strong>Add To Cart</strong></a></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{
									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><td align="right" valign="top">&nbsp;</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><td>&nbsp;</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" colspan="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 colspan="2" 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_showCenter(\'How to measure\', this.href, 600, 700)">How to measure</a> | <a href="documents/'+install+'" onclick="return GB_showCenter(\'How to Install\', this.href, 600, 700)">How to install</a> | <a href="documents/'+testimonial+'"  onclick="return GB_showCenter(\'Testimonials\', this.href, 600, 700)">Testimonials</a> | <a href="documents/'+brochure+'"  onclick="return GB_showCenter(\'Brochure\', this.href, 600, 700)">Brochure</a></td></tr>'+
										  '<tr><td colspan="3"><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">';//alert(formdata);
								/// For removing the popular options run time.
								chkTemp = document.getElementsByName('popular_options');
								for (ilooptwo = 0; ilooptwo < chkTemp.length; ilooptwo++){
									chkTemp[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){//alert(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;
																//alert(tempstr+" == "+prop+" == "+id+" == "+tempstr.replace(" ","-"));
																//optionproductrelation[x] = prop+"="+id+"="+tempstr;
																//x++;
																//alert(tempstr+" == "+prop+" == "+id+" == "+tempstr);
																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>';
										//alert(formdata[bstr]);
											//n = h + 2;	
										//alert(bstr);
										// // //$('yuitabview'+bstr).innerHTML = formdata[bstr];
										//alert($('yuitabview'+bstr).innerHTML);
										//alert("ok");
										    (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);
											  //alert("after var");
									}
								}
							}
							
				m++;
				}
				//selected_brandname = new Array();
				selected_brandname[h] = brand_name;
				//alert(selected_brandname[h]+"="+h);
				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";
					tempHtml += '<tr align="center" class="content_3" style="font-size:20px"><td><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.</td></tr>';
				}
				//START FOR DYNAMIC TAB
				/*splitids = dynamictabid.split("::");
				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 += "];";	//alert(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 += "];"; //alert(performance_data_set);
				warranty_set = warranty_set.substr(0,warranty_set.length-2);
				warranty_set += "];"; //alert(warranty_set);
				how_to_measure_set = how_to_measure_set.substr(0,how_to_measure_set.length-2);
				how_to_measure_set += "];"; //alert(how_to_measure_set);
				how_to_install_set = how_to_install_set.substr(0,how_to_install_set.length-2);
				how_to_install_set += "];"; //alert(how_to_install_set);
				testimonials_set = testimonials_set.substr(0,testimonials_set.length-2);
				testimonials_set += "];"; //alert(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>';
				}
				//alert(tempHtml);
				put_pictures(picture_image_set);
				$('product_data').update(tempHtml);//alert($('product_data').innerHTML);
				// // //$('product_data').show();
				//$('middle_portion_for_replace').style.display = "block";
				var blocknonebrand = new Array();
				for(iloopthree=0; iloopthree<selected_brand.length; iloopthree++){
					//alert(selected_brand[i]);
					blocknonebrand[selected_brand[iloopthree]] = selected_brand[iloopthree];
					//alert(blocknonebrand[selected_brand[i]]);
				}//alert($('product_data').innerHTML);
				//alert(selected_brand.length);
				/**** 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;//alert(i);alert($(brand_name.toLowerCase()+'_tab'));
						if($(brand_name.toLowerCase()+'_tab') != null)
						{//alert(blocknonebrand.length);
							//if(blocknonebrand.length > 0)
							//{
								//alert(response.ALL_BRAND[i].prefix);
								if(response.ALL_BRAND[iloopfive].prefix == blocknonebrand[response.ALL_BRAND[iloopfive].prefix])
								{//alert(response.ALL_BRAND[i].prefix+"--"+blocknonebrand[response.ALL_BRAND[i].prefix]+"=if"+brand_name.toLowerCase());
									$(brand_name.toLowerCase()+'_tab').style.display = "";//alert("block"+brand_name.toLowerCase());
									//alert(response.ALL_BRAND[i].prefix+"--"+blocknonebrand[response.ALL_BRAND[i].prefix]+"=ifend"+brand_name.toLowerCase());
								}
								else 
								{//alert(response.ALL_BRAND[i].prefix+"--"+blocknonebrand[response.ALL_BRAND[i].prefix]+"=else"+brand_name.toLowerCase());
									$(brand_name.toLowerCase()+'_tab').style.display = "none";//alert("none"+brand_name.toLowerCase());
									//alert(response.ALL_BRAND[i].prefix+"--"+blocknonebrand[response.ALL_BRAND[i].prefix]+"=elseend"+brand_name.toLowerCase());
								}
							//}
							/*else if(selected_brand.length != 1)
							{alert(response.ALL_BRAND[i].prefix+"--"+selected_brand[i]+"=elseif"+brand_name.toLowerCase());
								$(brand_name.toLowerCase()+'_tab').style.display = "";
								alert(response.ALL_BRAND[i].prefix+"--"+selected_brand[i]+"=elseifend"+brand_name.toLowerCase());
							}*/
						}
					}
				
				/*************************************************************************************************/
	
				
			}
		}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);
	}
}
/* ============ Get Exterior Colors list from selected interior color ========= */
function get_exterior_colors_mini_applet(){
	
	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_mini_applet });
	$("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_mini_applet(request){
	$("WAIT").toggle();
	$("COVER").toggle();
	combo = $('exterior_colors');
	brand_cmb = $('brands');
	//alert(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_mini_applet();
}
/* ======================================================================== */
/* =================== Get Brand list from interior and exterior colors  =========== */
function get_brand_list_mini_applet(){
	alert('hi');
	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_mini_applet});
	$("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_mini_applet(request){
	
	$("WAIT").toggle();
	$("COVER").toggle();
	
	combo = $('brands');
	alert(request);
	//alert(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;
			}
			alert(response);
			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_mini_applet();
}
/* =============================================================================== */
/* ============ Get Exterior Colors list from selected interior color ========= */
function get_exterior_colors_mini_applet(){
	
	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_mini_applet });
	$("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_mini_applet(request){
	$("WAIT").toggle();
	$("COVER").toggle();
	combo = $('exterior_colors');
	brand_cmb = $('brands');
	//alert(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_mini_applet();
}
/* ======================================================================== */
 
function enableall_mini_applet_for_live(){
	if($("state").value && $("state").value != 0){
		$("vertical").disabled="";
		$("brands").disabled="";
		$("interior_colors").disabled="";
		$("exterior_colors").disabled="";
		$("app").disabled="";
		$("styles").disabled="";
		$("width").disabled="";
		$("width_inch").disabled="";
		$("height").disabled="";
		$("height_inch").disabled="";
		$("callouts").disabled="";
		var index = $("state").selectedIndex;
		var label = $("state")[index].text;
		$("state_label").innerHTML = "State :<strong> "+label+"</strong>";
		$("state").style.display = "none";
		$("state_label").style.display="";
		set_product_tab();		
		//get_price_list();
		get_price_list();
	}else{
		$("vertical").disabled="disabled";
		$("brands").disabled="disabled";
		$("interior_colors").disabled="disabled";
		$("exterior_colors").disabled="disabled";
		$("app").disabled="disabled";
		$("styles").disabled="disabled";
		$("width").disabled="disabled";
		$("width_inch").disabled="disabled";
		$("height").disabled="disabled";
		$("height_inch").disabled="disabled";
		$("callouts").disabled="disabled";
	}
}
