// JavaScript Document
// JavaScript Document
var catChecked = false;

function check_ajax(ids)
{
	if (catChecked) return; // ❗ prevent repeated checking
	//alert(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;
			//alert(res);
			if(res.trim()=="yes")
			{
				 catChecked = true;  // prevent infinite loop
				alert("This Country is already Exist");	
				document.getElementById("lod").innerHTML ='';
				document.getElementById("cat_name").value ='';
				document.getElementById("cat_name").focus();
				return false;
			}
			else
			{
				document.getElementById("lod").innerHTML ='';
			}
		}
	}
	
	var qurl ="?ajax_id=1&vals=" + ids
	//alert(qurl);
	xmlhttp.open("GET","ajax/master_country_add_AJAX.php"+qurl,true);
	xmlhttp.send();	
}
function conf_sub()
{
	
	var alpha = /^[a-zA-Z\s-, ]+$/;  
    if (document.getElementById('cat_name').value== "") {
        alert('Please enter Name');
        return false;
    }
    else if (!document.getElementById('cat_name').value.match(alpha)) {
        alert('Country Should have only Digits  ');
        document.getElementById('cat_name').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;	
	}
}

function auto_time(ids)
{
	var vls = document.getElementById(ids).value;
	var ln = vls.length;
	var res='';
	if(ln==2 ){ res = vls +":" ; }else{ res = vls;}
	
	document.getElementById(ids).value = res;
}

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(country_id,statu_s,ids)
{
	document.getElementById("ajaxres_"+ids).innerHTML='<img src="images/elements/loaders/loader.gif" />';
	//alert(ids);
		
	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="+country_id+"&statu_s="+statu_s;
	//alert(qurl);
	xmlhttp.open("GET","ajax/master_country_add_AJAX.php"+qurl,true);
	xmlhttp.send();				
}