// JavaScript Document
function check_ajax(ids)
{
	document.getElementById("lod").innerHTML = '<img src="images/elements/loaders/loader.gif" />'
	//var ids = document.getElementById("cat_name").value;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var res = xmlhttp.responseText;
			if(res.trim()=="yes")
			{
				alert("This category is already Exist");	
				document.getElementById("lod").innerHTML =' ';
				document.getElementById("lod_val").value ='1';
				document.getElementById("cat_name").focus();
				return false
			}
			else
			{
				document.getElementById("lod").innerHTML =' ';
				document.getElementById("lod_val").value ='2';
			}			
		}
	}	
	var qurl ="?vals="+ids+"&pg_id=1";
	//alert(qurl);
	xmlhttp.open("GET","ajax/master_cat_AJAX.php"+qurl,true);
	xmlhttp.send();
}
function check_ajax_from(ids)
{
	document.getElementById("lod_frm").innerHTML = '<img src="images/elements/loaders/loader.gif" />'
	//var ids = document.getElementById("cat_name").value;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var res = xmlhttp.responseText;
			if(res.trim()=="yes")
			{
				alert("This short form is already Exist");	
				document.getElementById("lod_frm").innerHTML =' ';
				document.getElementById("lod_frm_val").value ='1';
				document.getElementById("short_frm").focus();
				return false
			}
			else
			{
				document.getElementById("lod_frm").innerHTML =' ';
				document.getElementById("lod_frm_val").value ='2';
			}			
		}
	}	
	var qurl ="?vals="+ids+"&pg_id=2";
	//alert(qurl);
	xmlhttp.open("GET","ajax/master_cat_AJAX.php"+qurl,true);
	xmlhttp.send();	
	
}
function conf_sub()
{	
	if(document.getElementById('category_type').value=='')
	{
		alert('Please select the Gender');  
		document.getElementById('category_type').focus();  
		return false;
	}
	if(document.getElementById('category').value=='')
	{
		alert('Please Select Plain / Stone');  
		document.getElementById('category').focus();  
		return false;
	}
	if(document.getElementById('cat_name').value.trim()=='')
	{
		alert('Please Enter Category Name');  
		document.getElementById('cat_name').focus();  
		return false;
	}
	if(document.getElementById('lod_val').value.trim()=='')
	{
		alert("This short form is already Exist"); 
		document.getElementById('cat_name').focus();  
		return false;
	}
	if(document.getElementById('short_frm').value.trim()=='')
	{
		alert('Please Enter Short Form');  
		document.getElementById('short_frm').focus();  
		return false;
	}
	if(document.getElementById('lod_frm_val').value.trim()=='')
	{
		alert("This category is already Exist"); 
		document.getElementById('short_frm').focus();  
		return false;
	}
	var letters=/^[A-Za-z\d\s]+$/;
	if(document.getElementById('cat_exp').value=='')
	{
		alert('Please Enter Category Expansion');  
		document.getElementById('cat_exp').focus();  
		return false;
	}
	else if(letters.test(document.getElementById('cat_exp').value)==false)  
	{
		alert('Expansion Should have only Digits ');  
		document.getElementById('cat_exp').focus();  
		return false;  
	}
	
	var letters=/^\d+(?:\.\d+)?$/;
	if(document.getElementById('cat_cst').value=='')
	{
		alert('Please Enter Category Cost');  
		document.getElementById('cat_cst').focus();  
		return false;
	}
	else if(letters.test(document.getElementById('cat_cst').value)==false)  
	{
		alert('Cost Should have only Digits ');  
		document.getElementById('cat_cst').focus();  
		return false;  
	}
	document.getElementById("lod").innerHTML =' ';	
	document.getElementById("lod_frm").innerHTML =' ';
	var where_to= confirm("Do you really want to Submit the Data?");
	if (where_to== true)
	{
		document.fm.submit();
	}
	else
	{
		return false;	
	}	
}

function foc(ids)
{
	document.getElementById(ids).style.border="2px solid #0099FF";	
}

function stnon(ids)
{
	document.getElementById(ids).style.border="thin solid #CCCCCC";
}