//transfer
var scrNum=0;
var boxaf=0;

function checkLogged()
{
        return ReadCookie('USERLOGGED');
}

nn=(document.layers)?true:false;
ie=(document.all)?true:false;

function keyDown(e) {
        var evt=(e)?e:(window.event)?window.event:null;
        if(evt){
                if (evt.altKey && evt.keyCode == 79)
                {
			jsrpc('/inc/editor/editonoff.php', '', '', '');
                }
                if (evt.altKey && evt.keyCode == 81)
                {
			jsrpc('/inc/editor/editqueryonoff.php', '', '', '');
                }
        }
}

document.onkeydown=keyDown;
if(nn) document.captureEvents(Event.KEYDOWN);

function RemoteLogin(user,pass)
{
	//document.write ('/inc/indexremote.html?mnpreview=0&accedi=accedi_ADM&adminuserid='+user+'&adminpassword='+pass);
        jsrpc('/inc/editor/indexremote.html?mnpreview=1&accedi=accedi_ADM&adminuserid='+user+'&adminpassword='+pass, '', '', '');
	
	alert('Login');
	return false;
}

function jsrpc(url, action, add, waitdiv){
 var scripturl='';
 head=document.getElementsByTagName('head').item(0);
 script=document.createElement('script');
 script.id='scr'+scrNum


 if (url=='this')
 {
	var url=window.location.href;
 }

url = url.replace(/#.*$/,'');

if (url.indexOf('.html?') >= 0 || url.indexOf('.php?') >= 0)
{
	scripturl=url+'&jsrpcactive=1&rpcaction='+action+'&'+add+'&rpcjssrc='+script.id;
}
else
{
	scripturl=url+'?jsrpcactive=1&rpcaction='+action+'&'+add+'&rpcjssrc='+script.id;
}

if (waitdiv)
{
	mainDivElement = document.getElementById(waitdiv);
	//mainDivElement.innerHTML = '<div align=center vertical-align=middle style="width: 100%; height:100% vertical-align:middle">Caricamento in corso, attendere..<br><br><img src="img/loading-bar.gif"></div>';
	mainDivElement.innerHTML = '<div align=center vertical-align=middle style="width: 100%; height:100% vertical-align:middle">Caricamento in corso, attendere..<br><br><img src="img/loading-bar.gif">'+scripturl+'</div>';

}

 script.src=scripturl;
 script.type='text/javascript';
 script.defer=true;
 scrNum++;

 void(head.appendChild(script));

}

function removeScript(scriptid){
 old=document.getElementById(scriptid);
 if(old)head.removeChild(old);
}



function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 //return theCookie.substring(ind+cookieName.length+1,ind1);
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

//load
function preload()
{
        var arImages = new Array();
        var temp     = preload.arguments;

        for(x=0; x < temp.length; x++) {
                arImages[x]     = new Image();
                arImages[x].src = preload.arguments[x];
        }
}
//-->
