// JavaScript Document

function conf_sub()
{
	if(document.getElementById('cat_name').value=='')
	{
		alert('Please Select the Stone Shape');  
		document.getElementById('cat_name').focus();  
		return false;
	}
				
	if(document.getElementById('stn_nam').value=='')
	{
		alert('Please enter the Stone Size');  
		document.getElementById('stn_nam').focus();  
		return false;
	}
	else if(document.getElementById('stn_nam').value!='')
	{
		document.getElementById("lod").innerHTML = '<img src="images/elements/loaders/loader.gif" />'
		var ids = document.getElementById("cat_name").value;
		var stn = document.getElementById('stn_nam').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")
				{
					document.getElementById("lod").innerHTML =' ';
					alert("This Stone Size is already Exist");	
					document.getElementById("lod").innerHTML =' ';
					document.getElementById("stn_nam").focus();
					return false;					
				}
				else
				{	
					document.getElementById("lod").innerHTML =' ';
					var letters=/^\d+(?:\.\d+)?$/;
					if(document.getElementById('stn_wght').value=='')
					{
						alert('Please Enter the Stone Weight');  
						document.getElementById('stn_wght').focus();  
						return false;
					}
					else if(letters.test(document.getElementById('stn_wght').value)==false)  
					{
						alert('Stone Weight Should have only Digits ');  
						document.getElementById('stn_wght').focus();  
						return false;  
					}
					var where_to= confirm("Do you really want to Submit the Data?");
					if (where_to== true)
					{
						document.fm.submit();
					}
					else
					{
						return false;	
					}
				}					
			}
		}
		
		var qurl ="?cat_id="+ids+"&stn_vl="+stn;
		xmlhttp.open("GET","ajax/master_stone_AJAX.php"+qurl,true);
		xmlhttp.send();	
	}
}

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

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