//  search validation script

  var w=0;

  var d=0;
  
  var p=0;


function check_search()

{

   var frm =document.search;

    if(frm.bid.value=="")

   {

        alert("Please choose blind");

        frm.bid.focus();

        return false;	

    }

  

    if((frm.width.value=="")||(isNaN(frm.width.value)))

   {

        alert("Please enter width of a blind");

        frm.width.value='width';

        frm.width.focus();

        return false;	

    }	

    

     if((frm.height.value=="")||(isNaN(frm.height.value)))

   {

        alert("Please enter height of a blind");

        frm.height.value='height';

        frm.height.focus();

        return false;	

    }	

    	

}





// validation converter



function convert_inch_to_cm(obj)

	{

	if(document.getElementById('id_inch_'+obj).value == '')

	{

		alert("Please enter value for inch to convert.");

		document.getElementById('id_inch_'+obj).focus();

		return false;																										

	}

	val1 = (document.getElementById('id_inch_'+obj).value)*(2.54);

	val1 = val1.toFixed(1);

	document.getElementById('id_cm_'+obj).value = val1;

}






function checkValueWidth(){
	checkValueWidthWithResetFunc(true);
}

function radioChanged()
{

	for (counter = 0; counter < radio_form.id[15].length; counter++)
	{
		if(radio_form.radio_button[counter].checked)
		{
	    	resetPrice();
		}
	}

}
function checkValueWidthWithResetFunc(doCallReset){

curWidth=document.getElementById('id_cm_w').value;
w=1;



  if(curWidth==''){

     alert('Please enter Width');

	 w=0;

     resetPrice();

  }

  else if(Min_Width>curWidth || Max_Width<curWidth){

     alert('Please enter width between '+Min_Width+' and '+Max_Width);

	 w=0;

     resetPrice();

  }
  
  if(doCallReset)
	{resetPrice();}

}




function checkValueDrop()
{
	checkValueDropWithResetFunc(true);
}

function checkValueDropWithResetFunc(doCallReset){



   curDrop=document.getElementById('id_cm_d').value;

   curWidth=document.getElementById('id_cm_w').value;

  d=1;
  
  
  if(curDrop==''){

      alert('Please enter Drop');

	  d=0;

      resetPrice();

  }

 

  else if(curDrop<Min_Drop || curDrop>Max_Drop){ 

      alert('Please enter drop between '+Min_Drop+' and '+Max_Drop);

	  d=0;

      resetPrice();

  }
  

  if(doCallReset)
  {resetPrice();}

}



 


function ceckPrice(){

  p=1;

  

   curPrice=document.forms['cart_quantity'].blindPrice.value;

 	

  if(parseInt(curPrice)==0 ||  curPrice==''  ){

     alert('Please get prices');

	 p=0;

  }

}



function getPrice(tipo){

  w=0;

  d=0;


	checkValueWidthWithResetFunc(false);

	checkValueDropWithResetFunc(false);
	

  //reset the value to =0

  if(tipo=='add'){

   ceckPrice();

    if(d==1 && w==1 && p==1){

	

	    formAction=document.forms['cart_quantity'].action+'&action=add_product'

	    document.forms['cart_quantity'].action=formAction;

		document.forms['cart_quantity'].submit();

		return true;

		  	}

	else return false;

  }

  else {
  	if(d==1 && w==1)
  	{
     		document.forms['cart_quantity'].submit();
  	}

  }

}



function resetPrice(shapeName)
{
	document.getElementById('curItemPrice').innerHTML='<font color=red> Click to get <br/> new price please</font>' ;

	document.forms['cart_quantity'].blindPrice.value='';
	
	
	if(shapeName!=null && shapeName!='')
	{
		switch(shapeName)
		{
			case 'Standard':
			
				//document.getElementById('linkMe').innerHTML = '';
			
				document.getElementById('braid_div').style.display = "none";
				document.getElementById('pole_div').style.display = "none";
				document.getElementById('eyelet_div').style.display = "none";
			break;


			case 'Shape 2':
			case 'Shape 4':
			case 'Shape 7':
			case 'Shape 9':
				//document.getElementById('linkMe').innerHTML = 'Hmmm Please choose Braid...';
				//alert (document.getElementById('braid_div').innerHTML);
				document.getElementById('braid_div').style.display = "block";
				document.getElementById('pole_div').style.display = "none";
				document.getElementById('eyelet_div').style.display = "none";


				
			break;

			case 'Shape 6':
			case 'Shape 5':
				//document.getElementById('linkMe').innerHTML = 'Please choose Braid and Pole ...';
				document.getElementById('braid_div').style.display= "block";
				document.getElementById('pole_div').style.display = "block";	
				document.getElementById('eyelet_div').style.display = "none";

			break;
			
			case 'Eyelets':
				//document.getElementById('linkMe').innerHTML = 'Please choose Eyelet ...';
				document.getElementById('braid_div').style.display= "none";
				document.getElementById('pole_div').style.display = "none";	
				document.getElementById('eyelet_div').style.display = "block";
			
			break;

			default:
				document.getElementById('braid_div').style.display= "none";
				document.getElementById('pole_div').style.display = "none";	
				document.getElementById('eyelet_div').style.display = "none";


				//document.getElementById('linkMe').innerHTML = '';
			
		}
		
	}
		
}







