// JavaScript Document
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	function checkname(name) {	
		var strURL="findID.php?name="+name;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('checkDiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}	
	}
	function getArts(artId) {		
		
		var strURL="findsubcat.php?art="+artId;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('areadiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("ItemDetails" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=680,height=320,left = 177,top = 230');");
}
function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("ItemDetails" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=250,left = 177,top = 230');");
}
function popstart(URL){
day = new Date();
id = day.getTime();
eval("admincomment" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=250,left = 177,top = 230');");
	
}
function popview(URL){
day = new Date();
id = day.getTime();
eval("commentview" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=250,left = 177,top = 230');");
	
}
function conf(i,j)
{
	var c = confirm('Do you want to delete it ?');	
	if(c == true)
	{
		window.location.href="../apps?approve=no&c=1&cat="+i+"&id="+j;
	}
}

function conf2(i,j)
{
	var c = confirm('Do you want to delete it ?');	
	if(c == true)
	{
		window.location.href="../apps?approve=no&s=1&subcat="+i+"&id="+j;
	}
}

function conf3(i,j)
{
	var c = confirm('Do you want to delete it ?');	
	if(c == true)
	{
		window.location.href="../apps?approve=no&i=1&item="+i+"&id="+j;
	}
}

function adv(i,j)
{
	var c = confirm('Do you want to delete it ?');	
	if(c == true)
	{
		window.location.href="../admin/?action=adcp&delete=1&id="+i+"&pt="+j;
	}
}
function goto(i)
{
	var searchkey = document.getElementById('inputtext').value;
	if(i == 0)
	{
		window.location.href="?search="+searchkey;
	}
	else
	{
		window.location.href="?search="+searchkey+"&country="+i;
	}
}

function ShowHide(elementId)
{
	var element = document.getElementById(elementId);
	if(element.style.display != "block")
	{
		element.style.display = "block";
	}
	else
	{
		element.style.display = "none";
	}
}
function opennext(i,j)
{
	if(i == 'seller')
	{
		document.getElementById(j).style.display='block';
	}
	else
	{
		document.getElementById(j).style.display='none';
	}
}
function searching()
{
	var key = document.getElementById('inputtext').value;
	var myNewString = key.replace(/ /g, "+");
	var country = document.getElementById('country').value;
	if(country == 0)
	{
		window.location.href="?search="+myNewString;
	}
	else
	{
		window.location.href="?search="+myNewString+"&country="+country;
	}
}

