// JavaScript Document
function category_edit(id,level)
{
	
	document.frm_category_mgmt.category_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_category_mgmt.action = "category_add.php?category_id="+id+"&level="+level;
	document.frm_category_mgmt.submit();
}
function categorysub_edit(id,level)
{
	
	document.frm_category_mgmt.category_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_category_mgmt.action = "categorysub_add.php?category_id="+id+"&level="+level;
	document.frm_category_mgmt.submit();
}
function category_delete(id,level)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_category_mgmt.action = "category_delete.php?category_id="+id+"&level="+level;
	document.frm_category_mgmt.submit();
}
function user_edit(id)
{
	document.frm_user_mgmt.user_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_user_mgmt.action = "user_add.php?user_id="+id;
	document.frm_user_mgmt.submit();
}
function product_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_product_mgmt.action = "product_delete.php?product_id="+id;
	document.frm_product_mgmt.submit();
}
function photo_edit(id,id1)
{
	
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_photo_mgmt.action = "photo_add.php?photo_id="+id+"&product_id="+id1;
	document.frm_photo_mgmt.submit();
}
function photo_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_photo_mgmt.action = "photo_delete.php?photo_id="+id;
	document.frm_photo_mgmt.submit();
}
function product_edit(id)
{
	document.frm_product_mgmt.product_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_product_mgmt.action = "product_edit.php?product_id="+id;
	document.frm_product_mgmt.submit();
}
function special_edit(id)
{
	document.frm_special_mgmt.special_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_special_mgmt.action = "special_edit.php?special_id="+id;
	document.frm_special_mgmt.submit();
}
function customer_edit(id)
{
	document.frm_customer_mgmt.c_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_customer_mgmt.action = "customer_add.php?c_id="+id;
	document.frm_customer_mgmt.submit();
}

function special_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_special_mgmt.action = "special_delete.php?special_id="+id;
	document.frm_special_mgmt.submit();
}
function user_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_user_mgmt.action = "user_delete.php?user_id="+id;
	document.frm_user_mgmt.submit();
}
function editPhoto(type,FrmPara)
{
	document.frmPhotoAdd.action =FrmPara;
	document.frmPhotoAdd.submit();
}

function edit_link(id)
{
	document.frm_homepage_link_mgmt.action ="edit_homepage_link.php?link_id="+id;
	document.frm_homepage_link_mgmt.submit();
}


function deletePhoto(id)
{
	
	var ans = confirm("Are you sure want to Delete Photo?");
	if(ans==true)
	{
		document.frmShowPhoto.action = "photo_mgmt.php?do=delete&id="+id;
		document.frmShowPhoto.submit();
	}
}
function deleteProductOption(FrmPara)
{
	//alert("hi");
	var ans = confirm(" Would you like to Delete Product Attribute Value?");
	if(ans==true)
	{
		document.frmAttributeValue.hidFrmVal.value = "Delete";
		document.frmAttributeValue.action = FrmPara;
		document.frmAttributeValue.submit();
	}
	else
	{
		document.frmAttributeValue.action = FrmPara;
	}
}




function add_to_cart(id,cid)
{
	
	document.frm_product_detail.action="add_quote2.php?product_id="+id+"&category_id="+cid;
	document.frm_product_detail.submit();
}

function email_check(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return false;
		 }

 		 return true;					
	}
function IsNumericforReg(sText)
{   
   var ValidChars = "+0123456789 -()";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
      {
	  		IsNumber = false;
	  }
   }
   return IsNumber;   
 }
function sendContact()
{
		if(document.frmContact.txt_fname.value == ""){
		alert('Please enter first name!!');
		document.frmContact.txt_fname.focus();
		return false;
		
		}
		if(document.frmContact.txt_lname.value == ""){
		alert('Please last name !!');
		document.frmContact.txt_lname.focus();
		return false;
		
		} 
		if(document.frmContact.txt_email.value == ""){
		alert('Please enter email address!!');
		document.frmContact.txt_email.focus();
		return false;
		
		} 
		if (email_check(document.frmContact.txt_email.value)==false){
		alert("Please enter valid email address");
		document.frmContact.txt_email.value.focus();
		return false
		}
		if(document.frmContact.txt_phone.value == ""){
		alert('Please enter phone number!!');
		document.frmContact.txt_phone.focus();
		return false;
		
		}
		if(!IsNumericforReg(document.frmContact.txt_phone.value))
		{
		alert("Please enter valid phone number");
		document.frmContact.txt_phone.focus();
		return false;
		}
		
		if(document.frmContact.txt_comment.value == ""){
		alert('Please enter comment!!');
		document.frmContact.txt_comment.focus();
		return false;
		
		}
		document.frmContact.action = "contact_us.php";
		document.frmContact.submit();
	
	
	}
function addproduct()
{	
		if(document.product_add.txt_product_name.value == "")
		{
			alert('Please Enter Product Name!!');
			document.product_add.txt_product_name.focus();
			return false;
		}
		if(document.product_add.txt_product_price.value == "")
		{
			alert('Please Enter Product Price!!');
			document.product_add.txt_product_price.focus();
			return false;
		}
		if(document.product_add.txt_product_price.value != "" && isNaN(document.product_add.txt_product_price.value))
		{
			alert('Please Enter Only Numeric Value In Product Price!!');
			document.product_add.txt_product_price.focus();
			return false;
		}
		if(document.product_add.product_url.value == "")
		{
			alert('Please Select Product Image!!');
			document.product_add.product_url.focus();
			return false;
		}
		//dev by raj
		if(!Validate_image(document.product_add.product_url))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.product_url.focus();
			return false;
		}
		if(!Validate_image(document.product_add.gallery_image1))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.gallery_image1.focus();
			return false;
		}
		if(!Validate_image(document.product_add.gallery_image2))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.gallery_image2.focus();
			return false;
		}
		if(!Validate_image(document.product_add.gallery_image3))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.gallery_image3.focus();
			return false;
		}
		if(!Validate_image(document.product_add.gallery_image4))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.gallery_image4.focus();
			return false;
		}
		if(!Validate_image(document.product_add.gallery_image5))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.gallery_image5.focus();
			return false;
		}
		
		/*if(document.product_add.txt_product_desc.value == ""){
		alert('Please Enter Product Description!!');
		document.product_add.txt_product_desc.focus();
		return false;
		} */
	document.product_add.action = "product_add_save.php";
	document.product_add.submit();
}
//dev by raj
function Validate_image(obj)
 {
    var objUpload=eval(obj);
    var sUpload=objUpload.value;
	 if(sUpload=="")
	  return true;
     else
        {
        		var iExt=0;//sUpload.indexOf("\\");
        		var iDot=sUpload.indexOf(".");

        if((iExt < 0 ) || (iDot < 0))
            {
            objUpload.focus();
            return false;
       		 }
        if(iDot > 0)
           {
           var vv=sUpload.toLowerCase();
		    var aUpload=vv.split(".");
			if(aUpload[aUpload.length-1]=="jpg" || aUpload[aUpload.length-1]=="jpeg" || aUpload[aUpload.length-1]=="gif" || aUpload[aUpload.length-1]=="png"){
                return true;
			}else{
                objUpload.focus();
                return false;
            }

        }

    }

}
//end by raj
function addservice()
{	
		if(document.service_add.txt_service_name.value == "")
		{
			alert('Please Enter Service Name!!');
			document.service_add.txt_service_name.focus();
			return false;
		}
		/*if(document.service_add.word_desc.value == "")
		{
			alert('Please Enter Service Description!!');
			document.service_add.word_desc.focus();
			return false;
		}*/
	document.service_add.action = "service_add_save.php";
	document.service_add.submit();
}
function service_edit(id)
{
	document.frm_special_mgmt.special_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_special_mgmt.action = "special_edit.php?special_id="+id;
	document.frm_special_mgmt.submit();
}

function service_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_special_mgmt.action = "special_delete.php?special_id="+id;
	document.frm_special_mgmt.submit();
}
function editproduct()
{	
	//dev by raj
		if(!Validate_image(document.product_add.product_url))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.product_url.focus();
			return false;
		}
		if(!Validate_image(document.product_add.gallery_image1))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.gallery_image1.focus();
			return false;
		}
		if(!Validate_image(document.product_add.gallery_image2))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.gallery_image2.focus();
			return false;
		}
		if(!Validate_image(document.product_add.gallery_image3))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.gallery_image3.focus();
			return false;
		}
		if(!Validate_image(document.product_add.gallery_image4))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.gallery_image4.focus();
			return false;
		}
		if(!Validate_image(document.product_add.gallery_image5))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.product_add.gallery_image5.focus();
			return false;
		}
		

	document.product_add.action = "product_add_save.php";
	document.product_add.submit();
}
function addspecial()
{
		if(document.special_add.sel_category_name.value == "")
		{
			alert('Please Select Main Category !!');
			document.special_add.sel_category_name.focus();
			return false;
		} 
		if(document.special_add.sel_sub_category_name.value == "")
		{
			alert('Please Select Sub Category !!');
			document.special_add.sel_sub_category_name.focus();
			return false;
		} 
		if(document.special_add.sel_product.value == "")
		{
			alert('Please Select Products !!');
			document.special_add.sel_product.focus();
			return false;
		} 
		if(document.special_add.txt_start_date.value == "")
		{
			alert('Please Select Start Date !!');
			document.special_add.txt_start_date.focus();
			return false;
		} 
		if(document.special_add.txt_end_date.value == "")
		{
			alert('Please Enter End Date!!');
			document.special_add.txt_end_date.focus();
			return false;
		}
		/*if(document.special_add.txt_start_date.value > document.special_add.txt_end_date.value)
		{
			alert('End Date must be greater than start date!!');
			document.special_add.txt_end_date.focus();
			return false;
		}*/
		
	document.special_add.action = "special_add_save.php";
	document.special_add.submit();
}
function addcar()
{

		
		if(document.frm_customer_add.txt_heading.value == "")
		{
			alert('Please Enter Customer Car Title !!');
			document.frm_customer_add.txt_heading.focus();
			return false;
		} 
		/*if(document.frm_customer_add.word_desc.value == "")
		{
			alert('Please enter description!!');
			document.frm_customer_add.word_desc.focus();
			return false;
		} */
		
		
	document.frm_customer_add.action = "customer_add_save.php";
	document.frm_customer_add.submit();
}

function addCategory()
{
	
	if(document.category_add.txt_maincat_name.value == ""){
		alert('Please Enter Main Category!!');
		document.category_add.txt_maincat_name.focus();
		return false;
	}
	
	document.category_add.action = "category_add_save.php";
	document.category_add.submit();
}
function addSubCategory()
{
	if(document.category_add.sel_category_name.value == ""){
		alert('Please Select Main Category!!');
		document.category_add.sel_category_name.focus();
		return false;
	}
	if(document.category_add.txt_subcat_name.value == ""){
		alert('Please Enter Sub Category!!');
		document.category_add.txt_subcat_name.focus();
		return false;
	}
	
	document.category_add.action = "categorysub_add_save.php";
	document.category_add.submit();
}
function editSubCategory()
{
	document.category_add.action = "categorysub_add_save.php";
	document.category_add.submit();
}
function editCategory()
{
	document.category_add.action = "category_add_save.php";
	document.category_add.submit();
}
function adduser()
{
		
		if(document.user_add.txt_user_name.value == ""){
		alert('Please Enter User Name!!');
		document.user_add.txt_user_name.focus();
		return false;
		
		}
		if(document.user_add.txt_user_pass.value == ""){
		alert('Please Enter Password!!');
		document.user_add.txt_user_pass.focus();
		return false;
		
		} 
		if(document.user_add.txt_user_fname.value == ""){
		alert('Please Enter User First Name!!');
		document.user_add.txt_user_fname.focus();
		return false;
		
		} 
		if(document.user_add.txt_user_lname.value == ""){
		alert('Please Enter User Last Name!!');
		document.user_add.txt_user_lname.focus();
		return false;
		
		} 
		if(document.user_add.txt_user_email_id.value == ""){
		alert('Please Enter Email Id!!');
		document.user_add.txt_user_email_id.focus();
		return false;
		
		} 
		if(document.user_add.txt_user_address.value == ""){
		alert('Please Enter Address!!');
		document.user_add.txt_user_address.focus();
		return false;
		
		} 
		if(document.user_add.txt_user_city.value == ""){
		alert('Please Enter City Name!!');
		document.user_add.txt_user_city.focus();
		return false;
		
		}
		if(document.user_add.txt_user_state.value == ""){
		alert('Please Enter State Name!!');
		document.user_add.txt_user_state.focus();
		return false;
		
		}
		if(document.user_add.txt_user_country.value == ""){
		alert('Please Enter Country Name!!');
		document.user_add.txt_user_country.focus();
		return false;
		
		}
		if(document.user_add.txt_user_zip_code.value == ""){
		alert('Please Enter Zipcode!!');
		document.user_add.txt_user_zip_code.focus();
		return false;
		
		}
		if(document.user_add.txt_user_phone.value == ""){
		alert('Please Enter Phone Number!!');
		document.user_add.txt_user_phone.focus();
		return false;
		
		}
		
	
	document.user_add.action ="user_add_save.php";
	document.user_add.submit();
}
function order_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_order_mgmt.action = "order_delete.php?order_id="+id;
	document.frm_order_mgmt.submit();
}
function order_edit(id)
{
	document.frm_order_mgmt.order_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_order_mgmt.action = "order_add.php?order_id="+id;
	document.frm_order_mgmt.submit();
}
// JavaScript Document
function page_edit(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_page_mgmt.action = "page.php?page_id="+id;
	document.frm_page_mgmt.submit();
}
function page_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_page_mgmt.action = "page.php?user_id="+id;
	document.frm_page_mgmt.submit();
}
function InsertProductOptionvalue(FrmPara)
{
	document.frmProductAttribute.action = FrmPara;
	document.frmProductAttribute.submit();
}
function InsertProductOption(FrmPara)
{
	document.frmAttributeValue.action = FrmPara;
	document.frmAttributeValue.submit();
}

function chkProductAttributeValidation(FrmPara)
{	
	
	
	if(document.frmAddAttributeValue.txtOptionName.value == ""){
		alert('Please Enter Product Attributes Name!!');
		document.frmAddAttributeValue.txtOptionName.focus();
		return false;
	}
	if(document.frmAddAttributeValue.txtProductValue.value == ""){
		alert('Please Enter Product Attributes Value!!');
		document.frmAddAttributeValue.txtProductValue.focus();
		return false;
	}
	document.frmAddAttributeValue.action =FrmPara;
	document.frmAddAttributeValue.submit();	
}

function updateQuote()
{
	document.frm_view_quote.action="update_quote.php";
	document.frm_view_quote.submit();
}

function emptyQuote()
{
	document.frm_view_quote.action="empty_quote.php";
	document.frm_view_quote.submit();
}

function checkoutQuote()
{
	document.frm_view_quote.action="checkout.php";
	document.frm_view_quote.submit();
}

	
function requestQuote()
{
	
	if(document.frm_checkout.txt_ship_user_fname.value == ""){
		alert('Please enter first name!!');
		document.frm_checkout.txt_ship_user_fname.focus();
		return false;
	}
	if(document.frm_checkout.txt_ship_user_lname.value == ""){
		alert('Please enter last name!!');
		document.frm_checkout.txt_ship_user_lname.focus();
		return false;
	}
	if(document.frm_checkout.txt_ship_user_address.value == ""){
		alert('Please enter address!!');
		document.frm_checkout.txt_ship_user_address.focus();
		return false;
	}
	if(document.frm_checkout.txt_ship_user_city.value == ""){
		alert('Please enter city name!!');
		document.frm_checkout.txt_ship_user_city.focus();
		return false;
	}if(document.frm_checkout.txt_ship_user_state.value == ""){
		alert('Please enter state name!!');
		document.frm_checkout.txt_ship_user_state.focus();
		return false;
	}
	
	if(document.frm_checkout.txt_ship_user_zip_code.value == ""){
		alert('Please enter zipcode!!');
		document.frm_checkout.txt_ship_user_zip_code.focus();
		return false;
	}
	if(!IsNumericforReg(document.frm_checkout.txt_ship_user_zip_code.value))
		{
		alert("Please enter valid zipcode");
		document.frm_checkout.txt_ship_user_zip_code.focus();
		return false;
		}
	if(document.frm_checkout.txt_ship_user_email.value == ""){
		alert('Please enter email address!!');
		document.frm_checkout.txt_ship_user_email.focus();
		return false;
	}
	if (email_check(document.frm_checkout.txt_ship_user_email.value)==false){
		alert("Please enter valid email address");
		document.frm_checkout.txt_ship_user_email.value.focus();
		return false
	}
	if(document.frm_checkout.txt_ship_user_fax.value == ""){
		alert('Please enter fax number!!');
		document.frm_checkout.txt_ship_user_fax.focus();
		return false;
	}
	if(!IsNumericforReg(document.frm_checkout.txt_ship_user_fax.value))
		{
		alert("Please enter valid fax number");
		document.frm_checkout.txt_ship_user_fax.focus();
		return false;
		}
	if(document.frm_checkout.txt_ship_user_phone.value == ""){
		alert('Please enter phone number!!');
		document.frm_checkout.txt_ship_user_phone.focus();
		return false;
	}
	if(!IsNumericforReg(document.frm_checkout.txt_ship_user_phone.value))
		{
		alert("Please enter valid phone number");
		document.frm_checkout.txt_ship_user_phone.focus();
		return false;
		}
	document.frm_checkout.action="order_add.php";
	document.frm_checkout.submit();
}
function checkSearch()
{
	
	
	if(document.frmSearchProd.txtSearch.value == ""){
		alert('Please Enter Search Text!!');
		document.frmSearchProd.txtSearch.focus();
		return false;
	}
	if(String(document.frmSearchProd.txtSearch.value).length < 3){
		alert('Please Enter Minimum Three Characters!!');
		document.frmSearchProd.txtSearch.focus();
		return false;
	}
	
	document.frmSearchProd.action = "product.php";
	document.frmSearchProd.submit();
	
}

function checkEmailPass()
{
	
	
	if(document.frmPassword.username.value == ""){
		alert('Please Enter User Name!');
		document.frmPassword.username.focus();
		return false;
	}
	if(document.frmPassword.useremail.value == ""){
		alert('Please Enter Email Id!');
		document.frmPassword.useremail.focus();
		return false;
	}
	
	
	return true;
	
}

function pageNext(cpage,cid)
{
 
 if(document.frm_product_detail.totalpage.value<cpage)
 	{
	 alert("Current page is last page!!");
	 return false;
	}
	
document.frm_product_detail.action = "product.php?page="+cpage+"&category_id="+cid;
document.frm_product_detail.submit();
}

function pageBack(cpage,cid)
{
 
 if(cpage<=0)
 	{
	 alert("Current page is first page!!");
	 return false;
	}
	
document.frm_product_detail.action = "product.php?page="+cpage+"&category_id="+cid;
document.frm_product_detail.submit();
}

function nextNews(cpage)
{
 
 if(document.frmNews.totalpage.value<cpage)
 	{
	 alert("Current news is last news!!");
	 return false;
	}
	
document.frmNews.action = "index.php?page="+cpage;
document.frmNews.submit();
}
function previousNews(cpage)
{
 
 if(cpage<=0)
 	{
	 alert("Current news is first news!!");
	 return false;
	}
	
document.frmNews.action = "index.php?page="+cpage;
document.frmNews.submit();
}
function goPage()
{
 
 if(document.frmSearchproduct.total_pages.value<document.frmSearchproduct.txtPage.value )
 	{
	 alert("Please Enter Valid Page Number!!");
	 return false;
	}
	if(document.frmSearchproduct.txtPage.value == "")
 	{
	 alert("Please Enter Page Number!!");
	 return false;
	}
document.frmSearchproduct.action = "product.php?page="+document.frmSearchproduct.txtPage.value;
document.frmSearchproduct.submit();
}
function goPage2()
{

if(document.frmSearchproduct.total_pages.value<document.frmSearchproduct.txtPage2.value)
 	{
	 alert("Please Enter Valid Page Number!!");
	 return false;
	}
	if(document.frmSearchproduct.txtPage2.value == "")
 	{
	 alert("Please Enter Page Number!!");
	 return false;
	}
document.frmSearchproduct.action = "product.php?page="+document.frmSearchproduct.txtPage2.value;
document.frmSearchproduct.submit();
}
function searchResultProduct()
{
	//document.frm_user_mgmt.user_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	var search1=document.frmSearchProduct.txtSearch.value;
	var field1=docoment.frmSearchProduct.selField.value;
	document.frmSearchProduct.action = "product.php?search="+search1+"&field="+field1;
	document.frmSearchProduct.submit();
}


function back()
{

	document.frmSearchProduct.submit();
}

function dopost(id)
{

document.frmSearchproduct.action = "product_detail.php";
document.frmSearchproduct.submit();	

}


function checkout_user()
{
	if(document.frm_checkout.txt_ship_user_fname.value == ""){
		alert('Please Enter Shipping First name');
		document.frm_checkout.txt_ship_user_fname.focus();
		return false;
	}
	if(document.frm_checkout.txt_ship_user_lname.value == ""){
		alert('Please Enter Shipping Last name');
		document.frm_checkout.txt_ship_user_lname.focus();
		return false;
	}
	if(document.frm_checkout.txt_ship_user_phone.value == ""){
		alert('Please Enter Shipping Phone Number');
		document.frm_checkout.txt_ship_user_phone.focus();
		return false;
	}
	if(document.frm_checkout.txt_ship_user_address.value == ""){
		alert('Please Enter Shipping Address');
		document.frm_checkout.txt_ship_user_address.focus();
		return false;
	}
	if(document.frm_checkout.txt_ship_user_city.value == ""){
		alert('Please Enter Shipping City');
		document.frm_checkout.txt_ship_user_city.focus();
		return false;
	}
	if(document.frm_checkout.txt_ship_user_state.value == ""){
		alert('Please Enter Shipping State');
		document.frm_checkout.txt_ship_user_state.focus();
		return false;
	}
	if(document.frm_checkout.txt_ship_user_country.value == ""){
		alert('Please Enter Shipping Country');
		document.frm_checkout.txt_ship_bill_user_country.focus();
		return false;
	}
	if(document.frm_checkout.txt_ship_user_zip_code.value == ""){
		alert('Please Enter Shipping Zip Code');
		document.frm_checkout.txt_ship_user_zip_code.focus();
		return false;
	}
	
	if(document.frm_checkout.txt_bill_user_fname.value == ""){
		alert('Please Enter Billing First name');
		document.frm_checkout.txt_bill_user_fname.focus();
		return false;
	}
	if(document.frm_checkout.txt_bill_user_lname.value == ""){
		alert('Please Enter Billing Last name');
		document.frm_checkout.txt_bill_user_lname.focus();
		return false;
	}
	if(document.frm_checkout.txt_bill_user_phone.value == ""){
		alert('Please Enter Billing Phone Number');
		document.frm_checkout.txt_bill_user_phone.focus();
		return false;
	}
	if(document.frm_checkout.txt_bill_user_address.value == ""){
		alert('Please Enter Billing Address');
		document.frm_checkout.txt_bill_user_address.focus();
		return false;
	}
	if(document.frm_checkout.txt_bill_user_city.value == ""){
		alert('Please Enter Billing City');
		document.frm_checkout.txt_bill_user_city.focus();
		return false;
	}
	if(document.frm_checkout.txt_bill_user_state.value == ""){
		alert('Please Enter Billing State');
		document.frm_checkout.txt_bill_user_state.focus();
		return false;
	}
	if(document.frm_checkout.txt_bill_user_country.value == ""){
		alert('Please Enter Billing Country');
		document.frm_checkout.txt_bill_user_country.focus();
		return false;
	}
	if(document.frm_checkout.txt_bill_user_zip_code.value == ""){
		alert('Please Enter Billing Zip Code');
		document.frm_checkout.txt_user_zip_code.focus();
		return false;
	}
	return true;
}


function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}
function getAttributesValue()
{ 	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="getattributevalue.php";
	
	var len = document.product_add.selAttributes.length;
	
	var i = 0;
	var attribute_value = new Array(len-1);
	for (i = 0; i < len-1; i++)
			{
				if (document.product_add.selAttributes[i+1].value != "other")
					{
				 		if (document.product_add.selAttributes[i+1].selected) 
				 			{
								attribute_value[i]=document.product_add.selAttributes[i+1].value;
				 			} 
							document.getElementById("getOtherAttribute").innerHTML="";
							document.getElementById("getAttributeNodeText").innerHTML="";
					}else{
						if (document.product_add.selAttributes[i+1].selected){ 
						document.getElementById("getOtherAttribute").innerHTML="&nbsp;&nbsp;Other Attribute:&nbsp;&nbsp;<input type=\"text\" name=\"txtAttribute\">";
						document.getElementById("getAttributeNodeText").innerHTML="&nbsp;&nbsp;Attribute value:&nbsp;&nbsp;<input type=\"text\" name=\"txtAttributeValue\">";
						
						}
						}
			}
	url=url+"?attribute_value="+attribute_value;
	url=url+"&length="+(len-1);
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=function() 
							{ 
								if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
								{ 
								//alert(xmlHttp.responseText);
								document.getElementById("getAttributeNode").innerHTML=xmlHttp.responseText;
								}
							};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function getAttributes()
{ 	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="getattribute.php";
	
	var len = document.product_attribute.selProdAttributes.length;
	
	var i = 0;
	var attribute_value = new Array(len-1);
	var count=0;
	for (i = 0; i < len-1; i++)
			{
				if (document.product_attribute.selProdAttributes[i+1].value != "other"){
					if (document.product_attribute.selProdAttributes[i+1].selected) 
				 		{
							attribute_value[count]=document.product_attribute.selProdAttributes[i+1].value;
							count++;
							document.getElementById("getOtherAttribute2").innerHTML="";
							document.getElementById("getAttributeNodeText2").innerHTML="";
							
				 		} 
				}else{
						if (document.product_attribute.selProdAttributes[i+1].selected){ 
						document.getElementById("getOtherAttribute2").innerHTML="&nbsp;&nbsp;Other Attribute:&nbsp;&nbsp;<input type=\"text\" name=\"txtAttribute\">";
						document.getElementById("getAttributeNodeText2").innerHTML="&nbsp;&nbsp;Attribute value:&nbsp;&nbsp;<input type=\"text\" name=\"txtAttributeValue\">";
						
						}
					
					}
			}
	url=url+"?attribute_value="+attribute_value;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=function() 
							{ 
								if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
								{ 
								//alert(xmlHttp.responseText);
								document.getElementById("getAttributeHint").innerHTML=xmlHttp.responseText;
								}
							};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function checkPhoto(picField,frmname) {
 var picFile = picField;
 var imagePath = document.frmname.picFile.value;
 var pathLength = imagePath.length;
 var lastDot = imagePath.lastIndexOf(".");
 var fileType = imagePath.substring(lastDot,pathLength);
 if((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG")) {
  return true;
 } else {
  alert("We supports .JPG, .PNG, and .GIF image formats. Your file-type is " + fileType + ". If you are having difficulties with this step, please send an e-mail to trevor@trevor.net.");
 }
}

//inquiry
function valid()
	{
		if(document.frm_inquiry.ta_message.value == "")
		{
			alert("Please enter your message");
			document.frm_inquiry.ta_message.focus();
			return false;
		}
		if(document.frm_inquiry.txt_name.value == "")
		{
			alert("Please enter first name");
			document.frm_inquiry.txt_name.focus();
			return false;
		}
		var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		if(document.frm_inquiry.txt_name.value != "")
		{
		  for (var i = 0; i < document.frm_inquiry.txt_name.value.length; i++)
		   {
			if (iChars.indexOf(document.frm_inquiry.txt_name.value.charAt(i)) != -1) 
			{
				alert ("Please enter valid first name.Special characters are not allowed.");
				document.frm_inquiry.txt_name.value = "";
				document.frm_inquiry.txt_name.focus();
				return false;
			}
		  }
		 }
		if(document.frm_inquiry.txt_mobile.value == "")
		{
			alert("Please enter mobile number");
			document.frm_inquiry.txt_mobile.focus();
			return false;
		}
		if(document.frm_inquiry.txt_suburb.value == "")
		{
			alert("Please enter suburb");
			document.frm_inquiry.txt_suburb.focus();
			return false;
		}
		if(document.frm_inquiry.txt_mobile.value != "" && isNaN(document.frm_inquiry.txt_mobile.value))
		{
			alert("Please enter onlu numeric value in mobile number");
			document.frm_inquiry.txt_mobile.focus();
			return false;
		}
		if(document.frm_inquiry.txt_email.value == "")
		{
			alert("Please enter email");
			document.frm_inquiry.txt_email.focus();
			return false;
		}
		
		if(document.frm_inquiry.txt_email.value != "")
		{
			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		   var address = document.frm_inquiry.txt_email.value;
		   if(reg.test(address) == false)
			{
			  alert('Please enter valid email');
			  document.frm_inquiry.txt_email.value ="";
			  document.frm_inquiry.txt_email.focus();
			  return false;
			  }
  		 }
		if(document.frm_inquiry.sel_state.value == "")
		{
			alert("Please select state");
			document.frm_inquiry.sel_state.focus();
			return false;
		}
		
		document.frm_inquiry.action = "mail.php";
		document.frm_inquiry.submit();	
	}
function addimage()
{
	
	//dev by raj
		if(!Validate_image(document.frm_gallery_mgmt.product_url))
		{
			alert('Please Upload Only jpeg, jpg, gif and png type Image!!');
			document.frm_gallery_mgmt.product_url.focus();
			return false;
		}
document.frm_gallery_mgmt.action = "gallery.php";
document.frm_gallery_mgmt.method="post";
document.frm_gallery_mgmt.submit();		
}
//inquiry
function validation(frm)
	{
	//  alert(document.form[0].first_name);

		if(document.getElementById('first_name').value == "")
		{
			alert("Please enter first name");
			document.getElementById('first_name').focus();
			return false;
		}
		var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		if(document.getElementById('first_name').value!= "")
		{
		  for (var i = 0; i < document.getElementById('first_name').value.length; i++)
		   {
			if (iChars.indexOf(document.getElementById('first_name').value.charAt(i)) != -1) 
			{
				alert ("Please enter valid first name.Special characters are not allowed.");
				document.getElementById('first_name').value = "";
				document.getElementById('first_name').focus();
				return false;
			}
		  }
		 }
		 if(document.getElementById('last_name').value == "")
		{
			alert("Please enter last name");
			document.getElementById('last_name').focus();
			return false;
		}
		var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		if(document.getElementById('last_name').value != "")
		{
		  for (var i = 0; i < document.getElementById('last_name').value.length; i++)
		   {
			if (iChars.indexOf(document.getElementById('last_name').value.charAt(i)) != -1) 
			{
				alert ("Please enter valid first name.Special characters are not allowed.");
				document.getElementById('last_name').value= "";
				document.getElementById('last_name').focus();
				return false;
			}
		  }
		 }
		if(document.getElementById('phone_no').value== "")
		{
			alert("Please enter phone number");
			document.getElementById('phone_no').focus();
			return false;
		}
		if(document.getElementById('phone_no').value != "" && isNaN(document.getElementById('phone_no').value))
		{
			alert("Please enter only numeric value in phone number");
			document.getElementById('phone_no').focus();
			return false;
		}
		if(document.getElementById('state').value == "")
		{
			alert("Please enter state");
			document.getElementById('state').focus();
			return false;
		}
		
		document.forms[0].action = "mail1.php";
		document.forms[0].submit();	
	}
	function chkValidation()
{
		 if(document.form1.txtbname.value==""){

                alert("Please enter business name.");
                document.form1.txtbname.focus();
                return false;

        }
        if(document.form1.txtcontect.value==""){
                alert("Please enter contact person");
                document.form1.txtcontect.focus();
                return false;

        }
		
		if(document.form1.txtaddress.value==""){
                alert("Please enter your address.");
                document.form1.txtaddress.focus();
                return false;

        }
		if(document.form1.txtphone.value != '')
		{
			if(isNaN(parseInt(document.form1.txtphone.value)))
			{
				alert("Please enter valid phone/mobile");
				document.form1.txtphone.value="";
				document.form1.txtphone.focus();
				return false;
			}
		}
        if(document.form1.txtemail.value==""){
                alert("Please enter your e-mail address.");
                document.form1.txtemail.focus();
                return false;

        }
		if(document.form1.txtemail.value != "")
		{
			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		   var address = document.form1.txtemail.value;
		   if(reg.test(address) == false)
			{
			  alert('Please enter valid email');
			  document.form1.txtemail.value ="";
			  document.form1.txtemail.focus();
			  return false;
			  }
  		 }
		
		
		
		
		
		document.form1.action = "contact_db.php";
		document.form1.method="post";
		document.form1.submit();					
	}				
	
	
	function chkValidatContactUs()
{
        if(document.form1.txtcontect.value==""){
                alert("Please enter contact person");
                document.form1.txtcontect.focus();
                return false;

        }
		
		if(document.form1.txtphone.value == '')
		{
			alert("Please enter phone/mobile");
			document.form1.txtphone.focus();
			return false;
		}
		else if(document.form1.txtphone.value != '')
		{
			if(isNaN(parseInt(document.form1.txtphone.value)))
			{
				alert("Please enter valid phone/mobile");
				document.form1.txtphone.value="";
				document.form1.txtphone.focus();
				return false;
			}
		}
        if(document.form1.txtemail.value==""){
                alert("Please enter your e-mail address.");
                document.form1.txtemail.focus();
                return false;

        }
		else if(document.form1.txtemail.value != "")
		{
			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		   var address = document.form1.txtemail.value;
		   if(reg.test(address) == false)
			{
			  alert('Please enter valid email');
			  document.form1.txtemail.value ="";
			  document.form1.txtemail.focus();
			  return false;
			  }
  		 }
				
		document.form1.action = "contact_db.php";
		document.form1.method="post";
		document.form1.submit();					
	}		
