function research(admin,lang) {
	document.onkeypress = function (e) {
	var enterpressed = e? e.which == 13: window.event.keyCode == 13;
	if (enterpressed){
				var keyword=document.getElementById('inputsearchtop').value;
				window.location.href=(admin==0?'':'admin_')+'index5.php?lang='+lang+'&keyword='+keyword;
			    return false;
		}
	}
} 
function edittextarea(id,width,height) {
	var id_edit='edittextarea'+id;
	if ( document.getElementById(id_edit) != null )
	{
		document.getElementById(id_edit).innerHTML='<img src="images/edit2.png" alt="edit" border="0" align="right" width="20px">';
	}
	document.getElementById(id).innerHTML='<textarea  name="'+id_edit+'" style="resize:none;overflow:scroll;width:'+width+'px;height:'+height+'px;text-align:justify;">'+document.getElementById(id).innerHTML+'</textarea>';
}

function editinput(id,width) {
	var id_edit='editinput'+id;
	if ( document.getElementById(id_edit) != null )
	{
		document.getElementById(id_edit).innerHTML='<img src="images/edit2.png" alt="edit" border="0" align="right" width="20px">';
	}
	document.getElementById(id).innerHTML='<input class="input" name="'+id_edit+'" value="'+document.getElementById(id).innerHTML+'" style="width:'+width+'px;height:20px;">';
}

function show(id) {
	document.getElementById(id).style.display="";
}
var k=5;
function show1(id) {
	k=k+1;
	document.getElementById(id).style.display="";
	document.getElementById(id).style.zIndex=k+1;
}

function hide(id) {
	document.getElementById(id).style.display="none";
}

function editphoto(id,img,width,height,ishover) {
	if (ishover==1){
		id_edit='categoryphoto'+id;
	} else if (ishover==2){
		id_edit='prodphoto'+id;
	} else {
		id_edit='photo'+id;
	}
	
	document.getElementById(id_edit).innerHTML=	'<div class="img_1" style="position:absolute;margin-top:0px;">'
													+'<input type="file" name="'+id_edit+'" id="'+id_edit+'" style="position:absolute;width:10px;text-align:right;height:'+height+'px;margin-left:-80px;z-index:10000;-moz-opacity:0;filter:alpha(opacity:0);opacity: 0;"/>'
													+'<div style="align:center;position:absolute;top:0px;left:0px;z-index:1;">'
														+'<img src="images/'+img+'" width="'+width+'px" height="'+height+'px" border="0"/>'
													+'</div>'
												+'</div>';
}
//******************************************************
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;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
function refresh(i,url,c,p)
  {
    var xmlHttp;
    var page='page_'+i;
	xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request");
		return;
		}
		xmlHttp.onreadystatechange = function() 
				{  
			
				if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") 
					{
					//alert(xmlHttp.responseText);
					document.getElementById(page).innerHTML=xmlHttp.responseText;  
					show('submenu'+c);
					show('category'+c);
					hide('prod');
					if (p!='') {
						show('prod'+p);
						}
					}
				}
		 xmlHttp.open("GET",url,true);
         xmlHttp.send(null);
		delete xmlHttp;
  }	
//************************************* 
function confirm_delete(action,id,text,lang)
{
var r=confirm(text);
if (r==true)
	{
	if (action==1)
		{
			window.location.href='delete.php?lang='+lang+'&category='+id+'&action='+action;
		}
	else
		{
			window.location.href='delete.php?lang='+lang+'&prod='+id+'&action='+action;
		}
	}
}
//************************************* 
function confirm_add(action,id,text,lang)
{
var r=confirm(text);
if (r==true)
	{
	if (action==1)
		{
			window.location.href='add.php?lang='+lang+'&action=1';
		}
	else
		{
			window.location.href='add.php?lang='+lang+'&category='+id+'&action='+action;
		}
	}
}
