function checkall(objForm){
	len = objForm.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) {
		if (objForm.elements[i].type=='checkbox') {
			objForm.elements[i].checked=objForm.check_all.checked;
		}
	}
}
/*
function confirm_submit(objForm) {
		
	if(document.getElementById("product_name_id").value=='')
	{alert("Please Enter Product Name");
	 return false;
	}else{
		return true;
	}
}

*/


function login_quote(){
  alert('please must be login to make your quotation !!')
  window.location.href="login.php";
}


function validcheck(name){
var chObj = document.getElementsByName(name);
var result	=	false;
for(var i=0;i<chObj.length;i++){
	if(chObj[i].checked){
	  result=true;
	  break;
	}
}
  if(!result){
    return false;
  }else{
	 return true;
  }
}

function ConfirmQuote(name,id) {
	
	if(document.getElementById("quote_name_id").value=='')
	{
	  alert("Please enter list name.");	
	  return false;
	}
	
	if(document.getElementById("quote_name_id").value!='' && validcheck(name)==true) {
		if(confirm("Are you sure to save the list?")) {
			return true;  
		} else  {
			return false;  
		}
	}else if(document.getElementById("quote_name_id").value!='' && validcheck(name)==false) {
		alert("Add individual products or all products to list.");		
		return false;
	}
	
  }



function delete_quote(quote)
{
  	if(validcheck(quote)==true) {
		if(confirm("Are you sure to delete this list?")) {
			return true;  
		} else  {
			return false;  
		}
	}else if(validcheck(quote)==false) {
		alert("Please make a selection to delete.");		
		return false;
	}
}

function delete_quote_view(quote1)
{
  	if(validcheck(quote1)==true) {
		if(confirm("Are you sure to delete this list?")) {
			return true;  
		} else  {
			return false;  
		}
	}else if(validcheck(quote1)==false) {
		alert("Please select at least one to delete.");		
		return false;
	}
}



function submit_form(name,all_product,uid){
	//alert('hi');
	if(uid==''){
		alert("Please log in to save list or see prices.  You will be returned to this selection.");
		window.location.href="login.php";
	}else{
	
	if(document.getElementById('quote_name_id').value==''){
		 alert("Please enter list name");	
	 	 return false;    		 
	 }
	 if(validcheck(name)==true && validcheck(all_product)==true){
	  alert("Please either select one of all products list OR select one or many of product to list.");		
		return false;	
	 }
	 
	 if(document.getElementById("quote_name_id").value!='' && validcheck(name)==true || validcheck(all_product)==true) {
			document.searchfrm.submit();
			return true;  
		
	}else if(document.getElementById("quote_name_id").value!='' && validcheck(name)==false || validcheck(all_product)==false) {
		alert("Add individual products or all products to list.");		
		return false;
	}	
 }
}	

function submit_form(name,uid){
	//alert('hsi');
	if(uid==''){
		alert("Please log in to save list or see prices.  You will be returned to this selection.");
		window.location.href="login.php";
	}else{
	
	if(document.getElementById('quote_name_id').value==''){
		 alert("Please enter list name");	
	 	 return false;    		 
	 }
	 	 
	 if(document.getElementById("quote_name_id").value!='' && validcheck(name)==true) {
			document.searchfrm.submit();
			return true;  
		
	}else if(document.getElementById("quote_name_id").value!='' && validcheck(name)==false) {
		alert("Add individual products or all products to list.");		
		return false;
	}	
 }
}

 
function search_see_list(name){
	if(validcheck(name)==false){
	  alert("Add individual products or all products to list.");		
		return false;	
	 }else{
		document.searchdetail.submit();
		return true;
 	 }
}
function new_search_see_list(){
	var alreadyadded = 0;
	var res = 0;
	var url ='ajax_functions.php?id=count_selected_products';	
		 new Ajax.Request(url, {
				method: 'get',
				onSuccess: function(transport) {
					res = transport.responseText;
					eval(res);
					//$('test_div').innerHTML = res;
					if(res>=1){
						document.searchdetail.submit();
												
					}else{
						alert("Add individual products or all products to list.");	
					}
				},
				onLoading: function(transport) {
					//$('product_name_div').innerHTML = 'Loading...';
				}
			}
			);
		
}

function manf_see_list(name){
	 if(validcheck(name)==false){
	  alert("Add individual products or all products to list.");		
		return false;	
	 }else{
		document.manf_frm.submit();
		return true;
 }
}


function openwin1(file,Iwidth,Iheight) {
      var newWin1=window.open(file,'nWin2','x=150,y=150,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes, copyhistory=no,width='+Iwidth+',height='+Iheight+',screenX=0,screenY=0,left=20,top=20');
}
