/*$(document).ready(function(){
//login_container
$("#login").click(function(){
		var username = $("#username");
		var username = $("#username");
		alert(username);
		if(!isValidEntry(username,"username")) 
			return false;
		if(!isValidEntry(password,"password")) 
			return false;
		else
			return true;
			//$("#frmuser").submit();	
})
})
*/

// Add/Edit Category
$(document).ready(function(){

$("#cat").click(function(){
		var name = $("#name");
		if(!isValidEntry(name,"name")) 
			return false;
		else
			return true;
			//$("#frmuser").submit();	
})
})

$(document).ready(function(){

$("#contact").click(function(){
		var Name = $("#Name");
		var email = $("#email");
		var phone = $("#Phno");
		if(!isValidEntry(Name,"Name")) 
			return false;
		if(!isValidEntry(email,"email")) 
			return false;
		if(!isValidEmail(email)) 
			return false;
		if(!isValidEntry(phone," Phone Number")) 
			return false;
		else
			return true;
			//$("#frmuser").submit();	
})
})



$(document).ready(function(){
//  Add/Edit Product
$("#pro").click(function(){
		var product = $("#product");
		var price = $("#price");

		if(!isValidEntry(product,"product")) 
			return false;
		if(!isValidEntry(price,"price")) 
			return false;
		if(!isValidNum(price,"Please enter the price of the product per 1 K.g")) 
			return false;

		else
			return true;
			//$("#frmuser").submit();	
			
			
})
})


$(document).ready(function(){
//  Add/Edit Product
$("#assign").click(function(){
		var catid = $("#catid");
		if(!isValidSelect(catid,"Category")) 
			return false;

		else
			return true;
			//$("#frmuser").submit();	
			
			
})
})




function delCat(id,cid)
{
	if(confirm("Are you sure ! U want to delete this Category ?"))
	{		
		location.href="delete.php?categoryid="+id+"&cid="+cid;
		
		
 	 }
 }
 
 function delSubCat(id,cid)
{
	if(confirm("Are you sure ! U want to delete this Sub category ?"))
	{		
		location.href="delete.php?subcategoryid="+id+"&cid="+cid;
		
		
 	 }
 }


 function delProduct(id,cid)
{
	if(confirm("Are you sure ! U want to delete this Product ?"))
	{		
		location.href="delete.php?productid="+id;
		
		
 	 }
 }

 
  function delMap(id,cid)
{
	if(confirm("Are you sure ! U want to delete this Map ?"))
	{		
		location.href="delete.php?mapId="+id+"&cid="+cid;
		
		
 	 }
 }



  function delSplProduct(id,cid)
{
	if(confirm("Are you sure ! U want to delete this Product ?"))
	{		
		location.href="delete.php?sPro="+id;
		
		
 	 }
 }


function delContent(id,p)
{
	if(confirm("Are you sure ! U want to delete this Content ?"))
	{		
		location.href="delete.php?content="+id+"&p="+p;
		
		
 	 }
 }


function delGift(id,p)
{
	if(confirm("Are you sure ! U want to delete this Gift ?"))
	{		
		location.href="delete.php?gift="+id;
		
		
 	 }
 }

function delNews(id,p)
{
	if(confirm("Are you sure ! U want to delete this News ?"))
	{		
		location.href="delete.php?news="+id;
		
		
 	 }
 }

 function delLoc(id)
{
	if(confirm("Are you sure ! U want to delete this Location ?"))
	{		
		location.href="delete.php?loc="+id;
		
		
 	 }
 }

 function delBanner(id)
{
	if(confirm("Are you sure ! U want to delete this Banner Image ?"))
	{		
		location.href="delete.php?ban="+id;
		
		
 	 }
 }


 function delHomeImg(id)
{
	if(confirm("Are you sure ! U want to delete this Image ?"))
	{		
		location.href="delete.php?homeImg="+id;
		
		
 	 }
 }


 function delMan(id)
{
	if(confirm("Are you sure ! U want to delete this Manufacturing Data?"))
	{		
		location.href="delete.php?manid="+id;
		
		
 	 }
 }

 // assign product page
  function showSubCategory(id)
	 {
		
	 var xmlhttp=false;//intially xmlhttp variable will be false,just like in 'c' lang that for eg x=0
	 if(window.XMLHttpRequest)
	 {
	 xmlhttp=new XMLHttpRequest();//object creation
	 }
	 else if(window.ActiveXObject)
	 {
	 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	 }
	 if(xmlhttp)
	 {
	// var category=document.getElementById('cat').value;//getting the id value that which we select in the selectbox
		//alert(id);
		 xmlhttp.open("GET","subCategoryInfo.php?id="+id);//passing id value as parameter to the subcategoryinfo.php file  
		 
	 xmlhttp.onreadystatechange=function()
	 {
	 if(xmlhttp.readyState==4)
	 {
	 
	 document.getElementById("subcat").innerHTML=xmlhttp.responseText;//now we will get the response from subcategoryinfo.php file which is at server to
	 }
	}
	xmlhttp.send(null);
	}
}



 //Category Search
 
function searchCat(str,ctype)
{
	//alert(ctype);
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="search.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
url=url+"&ctype="+ctype
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("searchresult").innerHTML=xmlHttp.responseText
}
}
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;
}


 //Product Search
 
function searchPro(str)
{
	//alert(ctype);
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="searchPro.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("searchresult").innerHTML=xmlHttp.responseText
}
}
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;
}




 //Special Product Search
 
function searchsplPro(str)
{
	//alert(ctype);
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="searchSplPro.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("searchresult").innerHTML=xmlHttp.responseText
}
}
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;
}



// Change Password
$(document).ready(function(){
// password change
$("#pwd").click(function(){
		var oldpwd = $("#oldpwd");
		var password = $("#password");
		var renewpwd = $("#renewpwd");
		if(!isValidEntry(oldpwd,"Please enter Old Password")) 
			return false;
		if(!isValidEntry(password,"Please enter New Password")) 
			return false;
		if(!isValidPwdRule(password)) 
			return false;
		if(!isValidEntry(renewpwd,"Please enter retype Password")) 
			return false;
		if(!isPasswordMatch(renewpwd,password)) 
			return false;
				else
			return true;
})
})



 //Giftpack Search
 
function searchGif(str)
{
	//alert(ctype);
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="searchGift.php"
url=url+"?q="+str
url=url+"&gid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("searchresult").innerHTML=xmlHttp.responseText
}
}
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;
}



 //NEws and Events Search
 
function searchNews(str)
{
	//alert(ctype);
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="searchNews.php"
url=url+"?q="+str
url=url+"&nid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("searchresult").innerHTML=xmlHttp.responseText
}
}
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;
}



 //Locations Search
 
function searchLoc(str)
{
	//alert(ctype);
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="searchLoc.php"
url=url+"?q="+str
url=url+"&id="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("searchresult").innerHTML=xmlHttp.responseText
}
}
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;
}





