// JavaScript Document

// Java script Fucntions
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i 
var regexp=/^\s+/;
//value.replace(regexp,"");

function category() {
	if(document.frmCategory.txtCTitle.value.replace(regexp,"")=="") {
		alert("Please enter category name");
		document.frmCategory.txtCTitle.focus();
		return false;
	}
}

function subCategory() {
		 if(document.frmSubCat.ddlSubCat.value==0) {
		alert("Please select category");
		document.frmSubCat.ddlSubCat.focus();
		return false;
		}
	else if(document.frmSubCat.txtCTitle.value.replace(regexp,"")=="") {
		alert("Please enter sub category name");
		document.frmSubCat.txtCTitle.focus();
		return false;
	}
	
}

function addItem() {
	if(document.frmItem.ddlCat.value==0) {
		alert("Please select category");
		document.frmItem.ddlCat.focus();
		return false;
		}
	
	/*else if(document.frmItem.txtCTitle.value.replace(regexp,"")=="") {
		alert("Please enter item name");
		document.frmItem.txtCTitle.focus();
		return false;
	}*/
	
}

function slectSubCateogry() {
	var cid=document.frmItem.ddlCat.options[document.frmItem.ddlCat.selectedIndex].value;
		window.location="additem.php?page=additem&cid="+cid;
}
function delCategory(val) {
	con=confirm("Are you sure to delete category->subcategory->items");
	if(con==true) {
		window.location="edcat.php?page=edcat&cid="+val;
	}
	else {
		return false;
	}
	
}

function delSubCategory(val) {
	con=confirm("Are you sure to delete subcategory->items");
	if(con==true) {
		window.location="edcat.php?page=edcat&sid="+val;
	}
	else {
		return false;
	}
}

 function sendRequest() 
{
		 myOption = -1;
		    var categoryID;
			var cmbProductCat;
			cmbProductCat = document.getElementById("ddlCat");
			categoryID = cmbProductCat.value;
			
			//return false;
			
			if (categoryID==0){
			 return false;
			}
			//alert(categoryID)
			else {
			var page; 
			//page = "additem.php?page=additem&cid="+categoryID;
			
			//-------
                       
			  
      $.ajax({
	  type: "GET",
	  url:  "../include/subcat.php?cid="+categoryID,
	  data: " ",
	  success: function(msg){
		//alert(msg);
		document.getElementById('subCatId').innerHTML=msg;
		/*myTd = document.getElementById("subCatId");
		alert(msg);
		mytd.innerHTML = msg;*/
	  }
	});	
	}
}

function delBlockItems(val,status,cid,sid,cst,feature) {
	
	if(status==1) {
		
		con=confirm("Are you sure to delete item");
	}
	else if(status==2) {
		if(cst==1)
		con=confirm("Are you sure to block item");
		else if(cst==0)
		con=confirm("Are you sure to unblock item");
		else if(feature==1 && cst==2)
		con=confirm("Are you sure to Feature item");
	}
	if(con==true) {
		window.location="editsubitem.php?aid="+val+"&st="+status+"&cid="+cid+"&sid="+sid+"&cst="+cst;
	}
	
	else {
		return false;
	}
}

