var postLocation="pgbar.php";
var re = /^(\.php)|(\.sh)/;  // disallow shell scripts and php
var dofilter=true;
 
function check_types() {
	if(dofilter==false)
		return true;
	with(document.upload)
	{
		if(elements[2].value == '')
		{
			return false;
		}
		for(i=0 ; i < elements.length ; i++)
		{
			if(elements[i].value.match(re))
			{
				alert('Sorry ' + elements[i].value + ' is not allowed');
				return false;
			}
		}
	}
	return true;
}

function popUP(mypage, myname, w, h, scroll, titlebar)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops);
}

function postIt()
{
	if(check_types() == false)
	{
		return false;
	}
	baseUrl = postLocation;
	sid = document.upload.sessionid.value;
	iTotal = escape("-1");
	baseUrl += "?iTotal=" + iTotal;
	baseUrl += "&iRead=0";
	baseUrl += "&iStatus=1";
	baseUrl += "&sessionid=" + sid;

	popUP(baseUrl,"Uploader",400,100,false,false);
	document.upload.submit();
}

function seleziona(x)
{
	document.form1.box.value= "[IMG]http://www.inworg.com/look/hotlink/"+x+"[/IMG]";
	document.form2.box.value= "[IMG]http://www.inworg.com/look/hotlink/"+x+"[/IMG]";
}

function highlight(field) {
        field.focus();
        field.select();
}

function gotopage(s){       
	var d = s.options[s.selectedIndex].value

	if(d == '')
	{
		return false;
	}


	if(d){
		self.location.href = d
	}
	s.selectedIndex=0
}

function doMenu(item) {
	obj=document.getElementById(item);
	col=document.getElementById("x" + item);
	if (obj.style.display=="none") {
		obj.style.display="block";
		col.innerHTML="[-]";
	} else {
		obj.style.display="none";
		col.innerHTML="[+]";
	}
}

function setCookie(name, value, reindirizza)
{
	var expires = new Date(new Date().getTime()  + (30*24*60*60*1000)); /*30 giorni alla scadenza*/

    /*document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");*/

	window.location.href = reindirizza


}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }

}
