//for new raj
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function getValidatePhone(obj)
{
	if(!isInteger(obj.value))
	{
		alert("Phone must be Number");
		obj.value="";
		obj.focus();
		return false;
	}
	else if(obj.value.length!=10)
	{
		alert("Phone must be 10 digits Number");
		obj.value="";
		obj.focus();
		return false;
	}
		else return true;
}
function IsEmail(obj, msgstr)
{
    if(obj.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)!= -1)
        return true;
    else
	{
		obj.focus();
        return false;
	}
}

function IsBlank(obj)
{
    if(Trim(obj.value)=="")
    {
        obj.focus();
        return false;
    }
    return true;
}
function Trim(str)
{
    return str.replace(/\s/g,"");
}
//end raj


// JavaScript Document
function category_edit(id)
{
	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;
	document.frm_category_mgmt.submit();
}
function category_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_category_mgmt.action = "category_delete.php?category_id="+id;
	document.frm_category_mgmt.submit();
}

function subcategory_edit(id)
{
	document.frm_category_mgmt.subcategory_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_category_mgmt.action = "category_add.php?subcategory_id="+id;
	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_gallery_edit(id)
{ 
	document.frm_gallery_mgmt.eid.value=id;
	//alert(document.frm_gallery_mgmt.eid.value);
	document.frm_gallery_mgmt.action = "photo_gallery_add.php?eid="+id;
	document.frm_gallery_mgmt.submit();
}
function photo_gallery_delete(id)
{
	document.frm_gallery_mgmt.delid.value=id;
	//document.frm_user_mgmt.user_id.value=id;
	//document.frm_gallery_mgmt.action = "product_delete.php?product_id="+id;
	document.frm_gallery_mgmt.action = "photo_gallery_mgmt.php?delid="+id;
	document.frm_gallery_mgmt.submit();
}
function quality_edit(id)
{ 
	document.frm_gallery_mgmt.eid.value=id;
	//alert(document.frm_gallery_mgmt.eid.value);
	document.frm_gallery_mgmt.action = "quality_add.php?eid="+id;
	document.frm_gallery_mgmt.submit();
}
function quality_delete(id)
{
	document.frm_gallery_mgmt.delid.value=id;
	//document.frm_user_mgmt.user_id.value=id;
	//document.frm_gallery_mgmt.action = "product_delete.php?product_id="+id;
	document.frm_gallery_mgmt.action = "quality_mgmt.php?delid="+id;
	document.frm_gallery_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_add.php?product_id="+id;
	document.frm_product_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 product_attribute_delete(id)
{
	document.product_attribute_add.action ="product_attribute_delete.php?product_attribute_id="+id;
	document.product_attribute_add.submit();
}
function product_attribute_edit(id)
{
	//document.product_attribute_add.product_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.product_attribute_add.action = "product_attribute_edit.php?product_attribute_id="+id;
	document.product_attribute_add.submit();
}

function editattributeproduct(id)
{
	document.product_edit_attribute.action = "product_attribute_edit_save.php?product_attribute_id="+id;
	document.product_edit_attribute.submit();
}

function news_edit(id)
{
	document.frm_news_mgmt.action = "news_add.php?news_id="+id;
	document.frm_news_mgmt.submit();
}
function news_delete(id)
{
	document.frm_news_mgmt.action = "news_delete.php?news_id="+id;
	document.frm_news_mgmt.submit();
}
function product_attribute_add()
{
	alert("test");
	//document.product_attribute_add.action = "product_attribute_add.php";
	//document.product_attribute_add.submit();
}
function addattributeproduct()
{
	
	document.product_attribute.action = "product_option_add_save.php";
	document.product_attribute.submit();
}
function add_to_cart(id,cid)
{
/*var q =document.getElementById('textarea2'+id).value;*/

	/*if(q == "")
	{
		alert("Quantity can not be left Blank!");
		return false;
	}
	else
	{
	document.frm_product_detail.action="add_quote2.php?product_id="+id+"&category_id="+cid;
	document.frm_product_detail.submit();
	}
	return true;*/
	
	var d=document.frm_product_detail.elements;
	var f = 0;
	var j = 0;
	for(i=0;i<d.length;i++)
	{
		if(d[i].id==("qty_" + id))
		{ j++;
				//alert(d[i].value)
				if(d[i].value == "")
				{
					f++;
				}
		}
		
	}
	if(j==f)
	{
			alert("Quantity can not be left Blank!");	
			return false;
	}
	else
	{
			document.frm_product_detail.action="add_quote2.php?product_id="+id+"&category_id="+cid;
		    document.frm_product_detail.submit();	
	}

return true;
}

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.selCategory.value == ""){
		alert('Please Select Category !!');
		document.product_add.selCategory.focus();
		return false;
		
		} 
			var arrSize = document.getElementsByName("size[]");
			var arrCode = document.getElementsByName("code[]");
			var flag=true;
			var obj="";;
			if(!IsBlank(document.product_add.txt_product_code))
			{
				for(i=0;i<arrSize.length;i++)
				{
					if(IsBlank(arrSize[i]))
					{					
						flag=false;
						break;
					}			
				}
			}
	
		if(!IsBlank(document.product_add.txt_product_code) && flag == true){
			alert('Please Enter Product Code!!');
			document.product_add.txt_product_code.focus();
			return false;			
		}
		else if(flag == false )
		{
			for(i=0;i<arrSize.length;i++)
			{
				if(IsBlank(arrSize[i]))
				{
					if(!IsBlank(arrCode[i]))
					{
						alert("Please enter code of all size");
						obj.focus();
						return false;
					}		
					
				}
			}
			
		}
		
//		alert(arrSize.length);return false;
		
			 
	
		if(document.product_add.txt_product_qty.value == ""){
		alert('Please Enter Product Quantity!!');
		document.product_add.txt_product_qty.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();
}

function addCategory()
{
	
	
	if(document.category_add.txt_category_name.value == ""){
		alert('Please Enter Category Name!!');
		document.category_add.txt_category_name.focus();
		return false;
	}
	document.category_add.action = "category_add_save.php";
	document.category_add.submit();
}
function addSubCategory()
{
	
	if(document.category_add.parent_cat_id.value == ""){
		alert('Please Select Category Name!!');
		document.category_add.parent_cat_id.focus();
		return false;
	}
	if(document.category_add.txt_subcategory_name.value == ""){
		alert('Please Enter Subcategory Name!!');
		document.category_add.txt_subcategory_name.focus();
		return false;
	}
	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;
		
		}
		if(document.user_add.selType.value == ""){
		alert('Please Select User Type!!');
		document.user_add.selType.focus();
		return false;
		
		} 
		if(document.user_add.selStatus.value == ""){
		alert('Please Select User Status!!');
		document.user_add.selStatus.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";
 if(document.getElementById("terms").checked == true)
 {
	document.frm_view_quote.action="request_quote.php";
	document.frm_view_quote.submit();
 }
 else
 {
 	alert("You must agree with Terms & Conditions");
 }	
}

function checkoutQuote1()
{
	if(document.getElementById("terms").checked == true)
 	{		document.frm_view_quote.action="order_add.php";
		//document.frm_view_quote.action="login.php";
		document.frm_view_quote.submit();
	}
	 else
	 {
		alert("You must agree with Terms & Conditions");
	 }	
}
	
function requestQuote()
{
var d=document.frm_checkout;	
	
	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(!IsBlank(d.txt_ship_user_email))
		{
		alert("Email cannot be left blank");
		return false;
		}
	else if(!IsEmail(d.txt_ship_user_email))
		{
			alert("Please Enter valid Email!");
			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,sid)
{
 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+"&subcat_id="+sid;
document.frm_product_detail.submit();
}
function pageNext1(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,sid)
{
 
 if(cpage<=0)
 	{
	 alert("Current page is first page!!");
	 return false;
	}
	
document.frm_product_detail.action = "product.php?page="+cpage+"&category_id="+cid+"&subcat_id="+sid;
document.frm_product_detail.submit();
}
function pageBack1(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);
}
//dev by raj
function sendEnquiry()
{
	var d=document.frmContact;
	
		if(document.frmContact.txt_fname.value == ""){
		alert('Please enter 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_company.value == ""){
		alert('Please enter Company name !!');
		document.frmContact.txt_company.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_suburb.value == ""){
		alert('Please enter Suburb !!');
		document.frmContact.txt_suburb.focus();
		return false;
		}
		if(document.frmContact.txt_state.value == ""){
		alert('Please select State !!');
		document.frmContact.txt_state.focus();
		return false;
		}*/
		if(!IsBlank(d.txt_email))
		{
		alert("Email cannot be left blank");
		return false;
		}
		else if(!IsEmail(d.txt_email))
		{
			alert("Please Enter valid Email!");
			return false;
		}
	/*	if(document.frmContact.txt_comment.value == ""){
		alert('Please enter comment!!');
		document.frmContact.txt_comment.focus();
		return false;
		
		}*/
		
		if(!IsBlank(d.verificationCode))
		{
			alert("Please Enter verification Code!");
			return false;
		}
		document.frmContact.submit();
	}
	
function getValidatePhone(obj)
{
	if(!isInteger(obj.value))
	{
		alert("Phone must be Number");
		obj.value="";
		obj.focus();
		return false;
	}
	else if(obj.value.length!=10)
	{
		alert("Phone must be 10 digits Number");
		obj.value="";
		obj.focus();
		return false;
	}
		else return true;
}

function validateRegister()
{
		var d=document.frmRegister;
	if(!IsBlank(d.txt_ship_user_fname))
	{
		alert("First Name cannot be left blank");
		d.txt_ship_user_fname.focus();
		return false;
	}
	else if(!IsBlank(d.txt_ship_user_lname))
	{
		alert("Last Name cannot be left blank");
		d.txt_ship_user_lname.focus();
		return false;
	}	
	else if(!IsBlank(d.txt_ship_user_phone))
	{
		alert("Phone cannot be left blank");
		d.txt_ship_user_phone.focus();
		return false;
	}
	if(!isInteger(d.txt_ship_user_phone.value))
	{
		alert("Phone must be Number");
		return false;
	}
	else if(!IsBlank(d.txt_ship_user_address))
	{
		alert("Address cannot be left blank");
		d.txt_ship_user_address.focus();
		return false;
	}
	else if(!IsBlank(d.txt_ship_user_city))
	{
		alert("Suburb cannot be left blank");
		d.txt_ship_user_city.focus();
		return false;
	}
	else if(!IsBlank(d.txt_ship_user_zip_code))
	{
		alert("Postcode cannot be left blank");
		d.txt_ship_user_zip_code.focus();
		return false;
	}
	else if(!isInteger(d.txt_ship_user_zip_code.value))
	{
		alert("Postcode must be Number");
		return false;
	}
	else if(!IsBlank(d.txt_ship_user_state))
	{
		alert("State cannot be left blank");
		d.txt_ship_user_state.focus();
		return false;
	}
	
	else if(!IsBlank(d.txt_ship_user_email))
	{
		alert("Email cannot be left blank");
		d.txt_ship_user_email.focus();
		return false;
	}
	else if(!IsEmail(d.txt_ship_user_email))
	{
		alert("Please Enter valid Email!");
		d.txt_ship_user_email.focus();
		return false;
	}
	else if(!IsBlank(d.password))
	{
		alert("Password cannot be left blank");
		d.password.focus();
		return false;
	}
	else if(d.password.value.length<5)
	{
		alert("Password must be 5 charactes long");
		d.password.focus();
		return false;
	}
	else if(!IsBlank(d.cpassword))
	{
		alert("Confirm Password cannot be left blank");
		d.cpassword.focus();
		return false;
	}
	else if(d.password.value!=d.cpassword.value)
	{
		alert("Passsword and Confirm Password dont match");
		d.cpassword.focus();
		return false;
	}
	
	else return true;
}
function getValidatePostcode(obj)
{
	if(!isInteger(obj.value))
	{
		alert("Postcode must be Number");
		obj.value="";
		obj.focus();
		return false;
	}
	else if(obj.value.length<3)
	{
		alert("Postcode atleast 3 digits Number");
		obj.value="";
		obj.focus();
		return false;
	}
	else return true;
}

function deletePageValidation(id)
{
	var d = document.pageForm;
	if(!confirm("Are You Sure You want to delete?"))
			return true;
	d.del_val.value=id;
	d.submit();
	return true;	
}
function validateRegisterUpdate()
{
	var d=document.frmRegister;
	if(!IsBlank(d.firstname))
	{
		alert("First Name cannot be left blank");
		d.firstname.focus();
		return false;
	}
	else if(!IsBlank(d.lastname))
	{
		alert("Last Name cannot be left blank");
		d.lastname.focus();
		return false;
	}
	else if(!IsBlank(d.email))
	{
		alert("Email cannot be left blank");
		d.email.focus();
		return false;
	}
	else if(!IsEmail(d.email))
	{
		alert("Please Enter valid Email!");
		d.email.focus();
		return false;
	}
	
	else if(!IsBlank(d.phone))
	{
		alert("Phone cannot be left blank");
		d.phone.focus();
		return false;
	}
	else if(!isInteger(d.phone.value))
	{
		alert("Phone must be Number");
		return false;
	}
	
	
	else if(!IsBlank(d.address))
	{
		alert("Address cannot be left blank");
		d.address.focus();
		return false;
	}
	else if(!IsBlank(d.suburb))
	{
		alert("Suburb cannot be left blank");
		d.postal_suburb.focus();
		return false;
	}
	else if(!IsBlank(d.state))
	{
		alert("State cannot be left blank");
		d.state.focus();
		return false;
	}
	else if(!IsBlank(d.postcode))
	{
		alert("Postcode cannot be left blank");
		d.state.focus();
		return false;
	}
	else if(!isInteger(d.postcode.value))
	{
		alert("Postcode must be Number");
		return false;
	}
	
	else return true;
}

		
		tinyMCE.init({
		theme : "advanced",
		language : "en",
		mode : "specific_textareas",
		//document_base_url : "http://6degreesit.com/LOAlliance/",
		relative_urls : false,
		remove_script_host : false,
		save_callback : "TinyMCE_Save",
		invalid_elements : "script,applet,iframe",
		theme_advanced_toolbar_location : "top",
		theme_advanced_source_editor_height : "550",
		theme_advanced_source_editor_width : "120",
		directionality: "ltr",
		force_br_newlines : "false",
		force_p_newlines : "true",
		content_css : "../css/ole_group.css", 
		debug : false,
		cleanup : true,
		cleanup_on_startup : false,
		safari_warning : false,
		plugins : "advlink, advimage, , preview, searchreplace, insertdatetime, emotions, advhr, table, fullscreen, layer, style, visualchars, media, nonbreaking, ibrowser",
		theme_advanced_buttons2_add : ", preview, search,replace, insertdate, inserttime, emotions, insertlayer, moveforward, movebackward, absolute",
		theme_advanced_buttons3_add : ", advhr, tablecontrols, fullscreen, styleprops, visualchars, media, nonbreaking,  ibrowser",
		plugin_insertdate_dateFormat : "%Y-%m-%d",
		plugin_insertdate_timeFormat : "%H:%M:%S",
		plugin_preview_width : "120",
		plugin_preview_height : "550",
		extended_valid_elements : "a[name|href|target|title|onclick], img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name], , hr[class|width|size|noshade]",
		disk_cache : true,
		debug : false,	
		fullscreen_settings : {
			theme_advanced_path_location : "top"
		}
	});
	function TinyMCE_Save(editor_id, content, node)
	{
		base_url = tinyMCE.settings['document_base_url'];
		var vHTML = content;
		if (true == true){
			vHTML = tinyMCE.regexpReplace(vHTML, 'href\s*=\s*"?'+base_url+'', 'href="', 'gi');
			vHTML = tinyMCE.regexpReplace(vHTML, 'src\s*=\s*"?'+base_url+'', 'src="', 'gi');
			vHTML = tinyMCE.regexpReplace(vHTML, 'mce_real_src\s*=\s*"?', '', 'gi');
			vHTML = tinyMCE.regexpReplace(vHTML, 'mce_real_href\s*=\s*"?', '', 'gi');
		}
		return vHTML;
	}	
	
	
function addToCart(id)
{
	var arrElements = document.frm_product_detail.elements;
	var name=id+"_qty[]";
//alert(name);
	var flag = false;
	for(i=0;i<arrElements.length;i++)
	{//alert(arrElements[i].name);
		if(arrElements[i].name == name && arrElements[i].value != "")
		{
			flag=true;
		}
	}
	if(flag == false)
	{
			alert("Quantity can not be left blank");
			return false
	}
	else
	{
		document.frm_product_detail.action="add_quote2.php?product_id="+id;
	    document.frm_product_detail.submit();	
		return true;
	}
	
}

function customer_edit(id)
{
	document.frm_cutomer_mgmt.cust_id.value=id;
	//alert(document.frm_user_mgmt.user_id.value);
	document.frm_cutomer_mgmt.action = "customer_add.php?cust_id="+id;
	document.frm_cutomer_mgmt.submit();
}
function customer_delete(id)
{
	//document.frm_user_mgmt.user_id.value=id;
	document.frm_cutomer_mgmt.action = "customer_mgmt.php?cust_id="+id;
	document.frm_cutomer_mgmt.submit();
}
