/* ############# TEMPLATE A #######################*/
function openwin(url)
 {	//alert(url);
	  window.open (url,'',"width=550,height=600,left=350,top=250");

 } 
 
function combos_popup(url)
 {	//alert(url);
	  window.open (url,'',"width=720,height=680,left=350,top=250,scrollbars=1");

 } 
 
function size_popup(url)
 {	//alert(url);
	  window.open (url,'',"width=230,height=250,left=650,top=420");

 } 
 
function checkA()
{	
	var  size_price= document.getElementById('size_price').value;
	var  main_color= document.getElementById('main_color').value;
	var  main_fabric= document.getElementById('main_fabric').value;
	 if(main_fabric=="")
	 {
	 	alert("Please select Fabric");
		return false;
	 }
	 if(main_color=="")
	 {
	 	alert("Please select Color");
		return false;
	 }
	 if(size_price=="")
	 {
	 	alert("Please select size");
		return false;
	 }
	 
}
function checkB()
{	
	var  size_price= document.getElementById('size_price').value;
	var  main_color= document.getElementById('main_color').value;
	var  main_fabric= document.getElementById('main_fabric').value;
	var  second_fabric= document.getElementById('second_fabric').value;
	var  second_color= document.getElementById('second_color').value;
	 if(main_fabric=="")
	 {
	 	alert("Please select Fabric");
		return false;
	 }
	 if(main_color=="")
	 {
	 	alert("Please select Color");
		return false;
	 }
	
	 if(second_fabric=="")
	 {
	 	alert("Please select Second Fabric");
		return false;
	 }
	 if(second_color=="")
	 {
	 	alert("Please select Second Color");
		return false;
	 }
	 if(size_price=="")
	 {
	 	alert("Please select size");
		return false;
	 }
	
	 
}

function checkD()
{	
	
	var  main_color= document.getElementById('main_color').value;
	var  main_fabric= document.getElementById('main_fabric').value;
	var  second_fabric= document.getElementById('second_fabric').value;
	var  second_color= document.getElementById('second_color').value;
	var  main_style= document.getElementById('main_style').value;
	var  option1= document.getElementById('option1').value;
	var  size_price= document.getElementById('size_price').value;
	 if(main_fabric=="")
	 {
	 	alert("Please select First Fabric");
		return false;
	 }
	 if(main_color=="")
	 {
	 	alert("Please select Color");
		return false;
	 }
	
	 if(second_fabric=="")
	 {
	 	alert("Please select Second Fabric");
		return false;
	 }
	 if(second_color=="")
	 {
	 	alert("Please select Second Color");
		return false;
	 }
	 if(main_style=="")
	 {
	 	alert("Please select Style");
		return false;
	 }
	 if(option1=="")
	 {
	 	alert("Please select Style Color");
		return false;
	 }
	 
	 if(size_price=="")
	 {
	 	alert("Please select size");
		return false;
	 }
}
function checkE()
{	
	var  size_price= document.getElementById('size_price').value;
	var  main_color= document.getElementById('main_color').value;
	var  main_fabric= document.getElementById('main_fabric').value;
	var  second_fabric= document.getElementById('second_fabric').value;
	var  second_color= document.getElementById('second_color').value;
	var  main_style= document.getElementById('main_style').value;
	var  option1= document.getElementById('option1').value;
	var  option2= document.getElementById('option2').value;
	
	 if(main_fabric=="")
	 {
	 	alert("Please select First Fabric");
		return false;
	 }
	 if(main_color=="")
	 {
	 	alert("Please select Color");
		return false;
	 }
	
	 if(second_fabric=="")
	 {
	 	alert("Please select Second Fabric");
		return false;
	 }
	 if(second_color=="")
	 {
	 	alert("Please select Second Color");
		return false;
	 }
	 if(main_style=="")
	 {
	 	alert("Please select Style");
		return false;
	 }
	 if(option1=="")
	 {
	 	alert("Please select Satin");
		return false;
	 }
	 if(option2=="")
	 {
	 	alert("Please select Style Color");
		return false;
	 }
	 
	 
	 if(size_price=="")
	 {
	 	alert("Please select size");
		return false;
	 }
	
	
	 
}




/*   ALL THE SERVER SIDE PROCESS DONE IN THIS FILE */

	   var url = "template_process.php"; 
	   function showResponse(originalRequest)
		{

			 var results = originalRequest.responseText;
			// alert(results);
			 var id = new Array();
			 var catid = new Array(); 
			 var addnewproduct = new Array();
			 productattributes=results.split("!~!");
			
			 id=results.split("&");

			 //alert(id[0]);

			 addnewproduct=results.split("&");
			 updateproduct=results.split("&");
			 searchproduct=results.split("~#~||");	
			 
			 
		     if(id[0]==10000)
		     {
			    //document.getElementById("txtProductId").value="";
				if(id[1]==0)
				{
					document.getElementById('fabric_color').innerHTML = id[2];
				}
				if(id[1]==1)
				{	document.getElementById('fabric_color1').innerHTML = id[2];
					document.getElementById('main_color').value = "";
				}
				if(id[1]==2)
				{
					 document.getElementById('fabric_color2').innerHTML = id[2];
				}
				if(id[1]==22)
				{
					 document.getElementById('fabric_color2').innerHTML = id[2];
				}
				if(id[1]==3)
				{
					 document.getElementById('fabric_color3').innerHTML = id[2];
				}
				if(id[1]==333)
				{
					 document.getElementById('option333').innerHTML = id[2];
				}
				
				if(id[1]==4)
				{
					 document.getElementById('fabric_color4').innerHTML = id[2];
				}
				if(id[1]==2222)
				{
					 document.getElementById('fabric_color3').innerHTML = id[2];
				}
			   }

			 if(id[0]==10001)
		     {
				 document.getElementById('fabric_style').innerHTML = id[1];
			 }
			  if(id[0]==10002)
		     {
				 document.getElementById('style_fabric_color').innerHTML = id[1];
			 }
			 
			  if(id[0]==10003)
		     {
				 //alert('hi');
				 document.getElementById('fabric_color1').innerHTML = id[1];
				 document.getElementById('size_price_div').innerHTML = id[2];
			 }


		}


		function funFabric(val) 
		{    
			//alert(val+"---"+type)
			var fabric = val.split("!~!");
			if(val=="")
			{
				alert(" Select Fabric");
				return false;
			}
			else
			{

				var params ='task=loadfabcolor&fabricId='+fabric[0];
				//alert(params);
				var myAjax = new Ajax.Request(
				url, 
				{
					method: 'post', 
					parameters: params, 
					onComplete: showResponse
				});
			}
        }


		

		function fuFabricTemp1(val,type) 
		{    
			//alert(val+"---"+type)
			var fabric = val.split("!~!");
			if(val=="")
			{
				//alert("Enter Select Fabric");
				return false;
			}
			else
			{

				var params ='task=changeFabricColor&fabricId='+fabric[0]+'&fabricName='+fabric[1]+'&type='+type;
				//alert(params);
				var myAjax = new Ajax.Request(
				url, 
				{
					method: 'post', 
					parameters: params, 
					onComplete: showResponse
				});
			}
        }

		function fuStyleTempE(val,type) 
		{   
			
			
			var satin = val.split("!~!");
			if(val=="")
			{
				alert("Enter Select Satin");
				return false;
			}
			else
			{

				var params ='task=fuStyleTempE&satinId='+satin[0]+'&satinName='+satin[1]+'&type='+type+'&product_id='+satin[2];
				var myAjax = new Ajax.Request(
				url, 
				{
					method: 'post', 
					parameters: params, 
					onComplete: showResponse
				});
			}
        }

		function funSelectColor(val) 
		{    
			
			var satin = val.split("!~!");
			if(val=="")
			{
				alert("Enter Select satin");
				return false;
			}
			else
			{	document.getElementById('option1').value =val;
				var params ='task=funSelectColor&satinId='+satin[0]+'&satinName='+satin[1]+'&product_id='+satin[2];
				//var params ='task=funSelectColor&satinId='+satin[0]+'&satinName='+satin[1]+'&type='+type+'&product_id='+satin[2];
				var myAjax = new Ajax.Request(
				url, 
				{
					method: 'post', 
					parameters: params, 
					onComplete: showResponse
				});
			}
        }


		function funCustomProduct(val)
		{
		
			window.location.href=""+val+"";
		}
		function funSizeChartDiv(val)
		{
			document.getElementById(''+val+'').style.display ='none' ;
			document.getElementById('gallerycontainer').style.display ='block' ;
		}
		function funHideSizeChart(val)
		{
			document.getElementById(''+val+'').style.display ='block' ;
			document.getElementById('gallerycontainer').style.display ='none' ;
		}

		
		
function hiddenColor(str)
{
	document.getElementById('main_color').value =str;
	return true;
}
function hiddenOption2C(str)
{
	document.getElementById('option2').value =str;
	return true;
}

function hiddenColor2B(str)
{
	document.getElementById('second_color').value =str;
	return true;
}

function hiddenColor2D(str)
{
	document.getElementById('second_color').value =str;
	return true;
}

function hiddenOption1D(str)
{
	document.getElementById('option1').value =str;
	return true;
}

function hiddenColor2E(str)
{
	document.getElementById('second_color').value =str;
	return true;
}


function hiddenSatinColor2E(str)
{ 
	document.getElementById('option2').value =str;
	return true;
}