// JavaScript Document
function conf_sub()
{
	if(document.getElementById('sub_name').value.trim()=='')
	{
		alert('Please enter the Sub Category Name');  
		document.getElementById('sub_name').focus();  
		document.getElementById('sub_name').value=document.getElementById('sub_name').value.trim();  
		return false;
	}
	else if(document.getElementById('sub_name').value.trim()!='')
	{
		document.getElementById("lod").innerHTML = '<img src="images/elements/loaders/loader.gif" />'
		var stn = document.getElementById('sub_name').value.trim();
		document.getElementById('sub_name').value=stn; 
		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 Sub Category is already Exist");	
					document.getElementById("lod").innerHTML =' ';
					document.getElementById("sub_name").focus();
					return false;					
				}
				else
				{	
					document.getElementById("lod").innerHTML =' ';
					var where_to= confirm("Do you really want to Submit the Data?");
					if (where_to== true)
					{
						document.fm.submit();
					}
					else
					{
						return false;	
					}
				}					
			}
		}		
		var qurl ="?ajax_id=1&cat_id="+stn;
		xmlhttp.open("GET","ajax/master_sub_category_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";
}

//DESIGN LIST PAGE, THIS IS FOR ACTIVE INACTIVE THE PAGES
function des_act_ina(design_id,statu_s,ids)
{
	document.getElementById("ajaxres_"+ids).innerHTML='<img src="images/elements/loaders/loader.gif" />';
	//alert(ids);
	if(statu_s==1)
	{	
		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)
			{
				//alert(xmlhttp.responseText);		
				document.getElementById("ajaxres_"+ids).innerHTML=xmlhttp.responseText;
			}
		}		
		var qurl ="?ajax_id=2&ids="+ids+"&design_id="+design_id+"&statu_s="+statu_s;
		//alert(qurl);
		xmlhttp.open("GET","ajax/master_sub_category_AJAX.php"+qurl,true);
		xmlhttp.send();	
	}
	else if(statu_s==2)
	{
		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;
				var splt = res.split("$*$");
				if(splt[0].trim()=="yes")
				{
					alert("This sub category already used in active stage");
					document.getElementById("ajaxres_"+ids).innerHTML=splt[1].trim();	
					return false;					
				}
				else
				{
					document.getElementById("ajaxres_"+ids).innerHTML=splt[1].trim();						
				}
			}
		}
		var qurl ="?ajax_id=3&ids="+ids+"&vals="+design_id;
		//alert(qurl);
		xmlhttp.open("GET","ajax/master_sub_category_AJAX.php"+qurl,true);
		xmlhttp.send();
	}			
}