var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else {  // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}
}


function getCategories(type){
window.location='viewcat.php?id='+document.myForm.myCat.value+'&type='+type;
}

function submitMe(val){
document.myForm.action.value=val;
document.myForm.submit();	
}

function openNewWin(url,w,h){
window.open(url,'mywin','status=1,scrollbars=1,width='+w+',height='+h);
}

function enlargeMe(obj){
document.getElementById("enlarge").style.left=tempX+'px';	
document.getElementById("enlarge").style.top=tempY-150+'px';
document.getElementById("enlarge").innerHTML="<img src='"+obj.src+"' onclick='delargeMe()' alt='Click to close' title='Click to close'>";	
}
function delargeMe(){
document.getElementById("enlarge").innerHTML="";	
}
function loadHome(){
	window.opener.location="index.php"
	window.close();
}

function loadObj(url,obj)
  {  
  document.getElementById(obj).innerHTML="<img src='images/11-1.gif' align='center'>";
  var xmlHttp;
  try
    {    
	// Firefox, Opera 8.0+, Safari    	
	xmlHttp=new XMLHttpRequest();    
	}
  catch (e)
    {    
	// Internet Explorer    
	try
      {   
	   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	   }
    catch (e)
      {      try
        {        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
		
		}
      catch (e)
        {        alert("Your browser does not support AJAX!");        
		return false;        
		}      
		}    
		}
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {	
        document.getElementById(obj).innerHTML=xmlHttp.responseText;	
        }
      }
    xmlHttp.open("GET",url,true);

    xmlHttp.send(null);  	
}

function cancelMe(obj){
document.getElementById(obj).innerHTML="";;	
}


var myText='';

function newFormValidator(obj,arr){
	for(i=0;i<arr.length;i++){
		temp=arr[i].split('=');	
		field=temp[0];
		val=temp[1];
		if(val=='blank'){

			blankValidator(obj,field);
		}
		if(val=='email'){
			emailValidator(obj,field);
		}		
	}
if(myText!=''){	
	alert('Following details are invalid '+myText);
	myText='';
	return false;
}else{
	return true;
}
}

function blankValidator(obj,field){
var obj='document.'+obj.name+'.'+field;
var data=eval(obj+'.value');
	if(data==''){
		myText=myText+field+', ';
	}
}
function emailValidator(obj,field){
var obj='document.'+obj.name+'.'+field;
var data=eval(obj+'.value');
	if(data.indexOf('@')=='-1' || data.indexOf('.')=='-1'){
		myText=myText+field+', ';
	}
}

function addtobaseket(pid){
if(window.opener){
window.opener.location="basket.php?pid="+pid;
}else{
window.location="basket.php?pid="+pid;
}
alert('Product successfully added');
}

function clearCom(){
	document.comForm.comment.value='';
}

function delConfirm(url,layer){
var sure=confirm('Are you sure to delete this record !');	
	if(sure){
	loadObj(url,layer);
	}
}

circle='';
function loadImages(merid,userid) {	
loadObj('imagepreloader.php?merid='+merid+"&userid="+userid,'myImages');
circle=setTimeout("loadImages('"+merid+"','"+userid+"')",2000);	
}
function stopCircle(){
clearTimeout(circle);	
}

function cancelNews(obj){
document.getElementById(obj).innerHTML='';
document.getElementById("closenews").innerHTML="<img src='images/up.gif' onclick=loadObj('mer_news_frame.php','scroll')>";
}
	