function check_old_password(str) { 
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    } 
	
		var act="checkusername";
    var url="../auser/ajax.php";
    url=url+"?old_pwd="+str;
		url=url+"&action="+act;
		url=url+"&jsid"+Math.random();
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 )
				 {
           
						if(xmlhttp.responseText==0)
						{
							alert('Sorry Wrong Old Password!');
							document.getElementById('old_pwd').value="";
						}
						else
						{
						document.getElementById('old_pwd').innerHTML="Wait...";
						}
    			}
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}


function change_status_category(cat_val)
 { 
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    } 
		//alert(cat_val);
    var url="../admin/ajax_change_stat.php";
		url=url+"?action=category_status";
		url=url+"&cat_id="+cat_val;
		url=url+"&jsid"+Math.random();
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 )
				 {
						 if(xmlhttp.responseText==0)
						 {
							//alert(cat_val);
						 //document.getElementById("test").innerHTML=xmlhttp.responseText;
						 document.getElementById(cat_val).src="../images/unlock.gif";
						 }
						 else
						 {
							// alert(cat_val);
							//document.getElementById("test").innerHTML=xmlhttp.responseText;
							document.getElementById(cat_val).src="../images/lock.gif";
						 }
				 }
				 else
				 {
					 document.getElementById(cat_val).src="../images/loading.gif";
				 }

}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}


function change_status_subcat(subcat_val,cat_val)
{ 
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    } 
		//alert(cat_val);

	
    var url="../admin/ajax_change_stat.php";
		url=url+"?action=change_suncat_status";
		url=url+"&sub_cat_id="+subcat_val;
		url=url+"&jsid"+Math.random();
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 )
				 {
						 if(xmlhttp.responseText==0)
						 {
							//alert(subcat_val);
							// alert(cat_val);
						 //document.getElementById("test").innerHTML=xmlhttp.responseText;
						 document.getElementById(cat_val+"-"+subcat_val).src="../images/unlock.gif";
						 }
						 else
						 {
							  //alert(subcat_val);
								//alert(cat_val);
							//document.getElementById("test").innerHTML=xmlhttp.responseText;
							document.getElementById(cat_val+"-"+subcat_val).src="../images/lock.gif";
						 }
				 }
				 else
				 {
					  document.getElementById(cat_val+"-"+subcat_val).src="../images/loading.gif";
				 }

}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}



function chech_if_subcat_has_off_cat(subcat_val,cat_val)
{ 
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    } 
		//alert(cat_val);

	
    var url="../admin/ajax_change_stat.php";
		url=url+"?action=check_is_subcat_has_off_cat";
		url=url+"&sub_cat_id="+subcat_val;
		url=url+"&cat_id="+cat_val;
		url=url+"&jsid"+Math.random();
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 )
				 {
						 if(xmlhttp.responseText==0)
						 {
							// alert(cat_val);
						 //document.getElementById("test").innerHTML=xmlhttp.responseText;
						document.getElementById(cat_val+"-"+subcat_val).src="../images/unlock.gif";
						}
						else if(xmlhttp.responseText==2)
						{
							alert('Please Unlock The Category First.');							
						}
					 else
					{
							//alert(cat_val);
							//document.getElementById("test").innerHTML=xmlhttp.responseText;
						document.getElementById(cat_val+"-"+subcat_val).src="../images/lock.gif";
					 }
				 }
				 else
				 {
					  //document.getElementById(cat_val+"-"+subcat_val).src="../images/loading.gif";
				 }

}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}



function check_if_cat_has_open_subcat(cat_val)
{ 
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    } 
		//alert(cat_val);

	
    var url="../admin/ajax_change_stat.php";
		url=url+"?action=check_if_cat_has_open_subcat";
		url=url+"&cat_id="+cat_val;
		url=url+"&jsid"+Math.random();
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 )
				 {
						 if(xmlhttp.responseText==0)
						 {
							// alert(cat_val);
						 //document.getElementById("test").innerHTML=xmlhttp.responseText;
						document.getElementById(cat_val).src="../images/unlock.gif";
						}
						else if(xmlhttp.responseText==2)
						{
							alert('Please Lock All The Sub Categories Under This Category.');
						}
					 else
					{
							//alert(cat_val);
							//document.getElementById("test").innerHTML=xmlhttp.responseText;
						document.getElementById(cat_val).src="../images/lock.gif";
					 }
				 }
				 else
				 {
					 // document.getElementById(cat_val).src="../images/loading.gif";
				 }

}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}






function change_template_home_status(template_id)
{
	//alert(template_id);
	xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    } 
		//alert(cat_val);
    var url="../admin/ajax_change_stat.php";
		url=url+"?action=change_template_status";
		url=url+"&template_id="+template_id;
		url=url+"&jsid"+Math.random();
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 )
				 {
						 if(xmlhttp.responseText==0)
						 {
							//alert('UnLocked');
						 //document.getElementById("test").innerHTML=xmlhttp.responseText;
						 document.getElementById(template_id).src="../images/unlock.gif";
						 }
						 else
						 {
							 // alert('Locked');
							//document.getElementById("test").innerHTML=xmlhttp.responseText;
							document.getElementById(template_id).src="../images/lock.gif";
						 }
				 }
				 else
				 {
					  document.getElementById(template_id).src="../images/loading.gif";
				 }

}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}



/*function SubcatDropDown(id,str)
{
				
	if(document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block'
			document.getElementById(str).src="images_new/nagative.jpg";
		}
		else
		{
				document.getElementById(id).style.display='none'
				document.getElementById(str).src="images_new/plus.jpg";
		}
}*/


// New vertion test for SubcatDropDown() //
function SubcatDropDown(cnt_id,str,tot)
{
	
	//alert(str);
	/*var img_src = document.getElementById(str).src.split('/');
	var cnt = img_src.length;
	var img_is = img_src[cnt-1];*/
	//var image_split = str.split('_');
	//var image_id = image_split[0];
	
	//alert(image_id);
	
	
		if(document.getElementById(cnt_id).style.display == 'none')
		{
			//alert(cnt_id);
				for( var i=1;i<=tot;i++)
				{	
						if(document.getElementById(i).style.display == 'block')
						{
							document.getElementById(i).style.display = 'none'
							document.getElementById(i+"_5").src="images_new/plus.jpg";
						}
				}
				document.getElementById(cnt_id).style.display = 'block'
				document.getElementById(str).src="images_new/nagative.jpg";
			
		}
		else
		{
				//alert(cnt_id);
				document.getElementById(cnt_id).style.display='none'
				document.getElementById(str).src="images_new/plus.jpg";
		}

	

					

}


function UpdateSuperCat(str,id)
{
	//alert(id);
	//alert(document.getElementById(str).src);
	xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    } 
		//alert(cat_val);
    var url="ajax_change_stat.php";
		url=url+"?action=Change_super_cat";
		url=url+"&super_cat="+str;
		url=url+"&cat_id="+id;
		url=url+"&jsid"+Math.random();
		
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 )
				 {
					 
					 //document.getElementById("test").innerHTML=xmlhttp.responseText;
						alert('Super Category Updated!');
						//alert(xmlhttp.responseText);
				
							
				 }
		}

xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}



function UpdateSuperCatName(id)
{
	//alert(document.getElementById("super_cat_name").value);
	//alert(id);
	//alert(document.getElementById(str).src);
	xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    } 
		//alert(cat_val);
		var name=document.getElementById(id).value;
    var url="ajax_change_stat.php";
		url=url+"?action=Update_super_cat_name";
		url=url+"&name="+name;
		url=url+"&p_cat_id="+id;
		url=url+"&jsid"+Math.random();
		
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 )
				 {
					 
					 //document.getElementById("test").innerHTML=xmlhttp.responseText;
						alert('Super Category Updated!');
						//alert(xmlhttp.responseText);
				
							
				 }
		}

xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}




function DeleteSuperCat(id)
{
	xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    } 
		//alert(cat_val);
		if(!confirm('R U Sure To Delete?'))
		{
        return;
		}
    var url="ajax_change_stat.php";
		url=url+"?action=Delete_super_cat";
		url=url+"&p_cat_id="+id;
		url=url+"&jsid"+Math.random();
		
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 )
				 {
					 
					 //document.getElementById("test").innerHTML=xmlhttp.responseText;
						alert('Super Category Deleted!');
						window.location.href="edit_s_category.php";

						//alert(xmlhttp.responseText);
				
							
				 }
		}

xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function GetXmlHttpObject() {
    var xmlhttp=null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlhttp=new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlhttp;
} 
