status = "© siteAdmin";

function openWin(path,winW,winH) {
	var iMyWidth;
	var iMyHeight;
    	var toolbar=0;
	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - ((winW/2)+ 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	iMyHeight = (window.screen.height/2) - ((winH/2) + 50); //half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(path,'sawin',"status,toolbar="+toolbar+",height="+winH+",width="+winW+",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");
    win2.opener=window;
    win2.focus();
	return false;
}
function fileManager (){
    var path='?cmd=fileManager&pop=1';
    var winW=714 ;
    var winH=400;
    var iMyWidth;
	var iMyHeight;
    var toolbar=0;
   // winH= 400;
    //winW= 700;
	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - ((winW/2)+ 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	iMyHeight = (window.screen.height/2) - ((winH/2) + 50); //half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(path,"filem","status,toolbar="+toolbar+",height="+winH+",width="+winW+",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");
    win2.opener=window;
    win2.focus();
}

function addEvent(obj, evType, fn) {
  /* adds an eventListener for browsers which support it
     Written by Scott Andrew: nice one, Scott */
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, true);
    return true;
  } else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
	return false;
  }
}


function writeLayer(text,id){
    if (document.getElementById){
		x = document.getElementById(id);
		x.innerHTML = "";
		x.innerHTML = text;
	}
	else if (document.all){
		x = document.all[id];
		x.innerHTML = text;
	}
	else if (document.layers){
		x = document.layers[id];
		//text2 = '<P CLASS="testclass">' + text + '</P>';
		x.document.open();
		x.document.write(text);
		x.document.close();
	}
}

function replace_slash(x){
    x = x.replace(/"/g, "\”");  //"
    //alert(x);
    return x; 
}

function changeClass(id, newClass) {
    if(document.getElementById(id)){
        var identity=document.getElementById(id);
        identity.className=newClass;             
        save=id;
    }
}
function diminui (id){
    var x = document.getElementById(id);
    if (!x) return;
    if(x.rows > 2) x.rows-=7;
}
function aumenta (id){
    var x = document.getElementById(id);
    if (!x) return;
    if(x.rows < 18)x.rows+=7;
}

function testTitle(title, rename){
	var ol=document.getElementById('supList');
	var links=ol.getElementsByTagName('a');	
	var overwrite=true;
	for(var i=0;i<links.length;i++){
		if(links[i].firstChild.nodeValue==title){
			overwrite=confirm(title+overwriteTag);
			break;
		}	
	}
	if(title!=null && title!='' && title!=rename && overwrite) return true;
	else return false;
}

function swapEdit(button){
	// cancel others
	cancelAll();
	var actions=button.parentNode;
	var form=actions.parentNode;
	form.className= 'form';
	var ancora = form.previousSibling.previousSibling.name;
	if(ancora)location.href='#'+ancora;
	// widgEditor
	widgInit(form);
	return false;
}
function cancelAll(){
	var cont=document.getElementById('content');	
	var forms= cont.getElementsByTagName('form');
	for(var i=0;i<forms.length;i++){
		if(forms[i].className=='form')forms[i].className='';
	}
	if(ni=document.getElementById('newItem')) ni.style.visibility='visible';
	return false;
}
function showNew(){
	
	var nf=document.getElementById('newForm');
	if(nf.className=='form'){
		nf.className='';
		return false;
	}	
	cancelAll();		
	nf.className='form';
	if(ni=document.getElementById('newItem')) ni.style.visibility='hidden';
	// widgEditor
	widgInit(nf);
	return false;
}
function ispopup(){
	if(window.name=="filem"){
		//var body=document.getElementsByTagName('body')[0];
		var wrap=document.getElementById('wrap');
		wrap.setAttribute('id','popup');
	}
}

addEvent(window,"load",ispopup);



