// JavaScript Document
function check_login()
{
	var check = validateLogin();
	if(check!=false)
	{
		document.form1.submit();
	}
}
function validateLogin()
{
	if(document.form1.username.value=="")
	{
		alert("Enter Username.");
		document.form1.username.focus();
		return false;
	}
	if(document.form1.password.value=="")
	{
		alert("Enter password.");
		document.form1.password.focus();
		return false;
	}
}

function get_company(){
if(document.form1.company.options[document.form1.company.selectedIndex].value!=0)
{
	comp_id = document.form1.company.options[document.form1.company.selectedIndex].value;

	document.form1.comp_id.value = comp_id;
	document.form1.submit();
}
}

function get_company_new(){
if(document.upload.company.options[document.upload.company.selectedIndex].value!=0)
{
	comp_id = document.upload.company.options[document.upload.company.selectedIndex].value;

	document.upload.comp_id.value = comp_id;
	document.upload.submit();
}
}

function get_product()
{
	if(document.form1.company.options[document.form1.company.selectedIndex].value!=0)
	{
		comp_id = document.form1.company.options[document.form1.company.selectedIndex].value;
	
		document.form1.comp_id.value = comp_id;
		
	}
	if(document.form1.ptype.options[document.form1.ptype.selectedIndex].value!=0)
		{
			
			
			ptype_id = document.form1.ptype.options[document.form1.ptype.selectedIndex].value;
		
			document.form1.ptype_id.value = ptype_id;
			
	}
	/*if(document.form1.product.options[document.form1.product.selectedIndex].value!=0)
		{
			
			
			p_id = document.form1.product.options[document.form1.product.selectedIndex].value;
		
			document.form1.p_id.value = p_id;
			
	}*/
document.form1.submit();
}

function add_to_cart(act,pId,prc)
{
	
	var qty = document.getElementById("txtqty" + pId).value;
	
	location.href = "addtocart.php?action=" + act + "&p=" + pId + "&qty=" + qty + "&price=" + prc;
	
		
}
function check_pwd()
{
	if(document.form1.email.value=="")
	{
		alert("Enter Email Address.");
		document.form1.email.focus();
	}
	else
	{
		document.form1.submit();
	}
}

function submit_search()
{
	var check = validateSearch();
	if(check!=false)
	{
	
	if(document.getElementById('search_text').value!="")
	{
		var a=document.getElementById('search_text').value;
		window.location.href ='product_search_list.php?s=' + a;
		
	}
	}
}
function validateSearch()
{
	if(document.getElementById('search_text').value=="")
	
	{
		alert("Enter search text.");
		return false;
	}
}
