var relPath="";
// get name of the file, where this js script resides
var fileName=this.location.href;

// check for the number of slashes in this string
var arr=new Array();
n=arr.length;
n=n-3;   // this is to take into account the 3 slashes in the address http://xxxxx/

if (fileName.indexOf('localhost')>-1) {
	n=n-1;   // this is to additionally take into account the configuration of RW : "http://localhost/polishfilmla.org/ >> 1-LAPTOP 2-RW
}

// create path relative to the root 
for (var i=1;i<n;i++) { relPath+="../" };

// popup
var mediaWindow;
var isOpen=false;

function openMediaWindow(url,w,h) {
/////////////////////////////////
	if (isOpen==true) {
		mediaWindow.close(mediaWindow);
		isOpen=false;
	}
	var s=0;
	if (w>800) { s=1; w=800; }
	if (h>600) { s=1; h=600; }
	WinAtts='toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+s;
	WinAtts+=',resizable=0,copyhistory=0,width='+w+',height='+h+',alwaysRaised=1';
	WinAtts+=',left=100,top=100';
	winName="mediaWindow";
	mediaWindow=window.open(url,winName,WinAtts);
	isOpen=true;
}

// php based popup function
function popupImage(img,txt,x,y,lng) {
//////////////////////////////////////
	if (y==null) y=70;
	if (x==null) x=70;
	if (lng==null) lng="en";
// 	need relPath calculated above
	str=relPath+'popup.php?imageFile='+img+'&lang='+lng+'&txt='+txt;
	str='openMediaWindow(\''+str+'\','+x+','+y+')';
	eval(str);
}

function openWindow(url,x0,y0) {
///////////////////////////////////
	WinAtts='toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0';
	WinAtts+=',resizable=1,copyhistory=0,width=150,height=150,alwaysRaised=1';
	if (x0!='') WinAtts+=',left='+x0+',top='+y0;
	winName="mediaWindow";
	alert(url+"-"+winName+"--"+WinAtts)
	mediaWindow=window.open(url,winName,WinAtts);
}

function openPopupWindow(url,winname,myWidth,myHeight) {
//////////////////////////////////////////////////////
    var myLeft;
	var myTop;

	myLeft = (screen.availWidth-myWidth)/2;
	myTop = (screen.availHeight-myHeight)/2;

    WinAtts='toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes';
    WinAtts+=',resizable=yes,copyhistory=no,alwaysRaised=yes,width='+myWidth+',height='+myHeight;
    WinAtts+=',screenX='+myLeft+',screenY='+myTop+',left='+myLeft+',top='+myTop;
	
    window.open(url,winname,WinAtts);
}

function wocms_gallery(id) {
//////////////////////////////
	window.open('wocms_gallery.php?ID='+id,'gallery'+id,100,100);
}