// JavaScript Document

function openURL(anchor, options) {
 
	var args = '';
 
	if (typeof(options) == 'undefined') { var options = new Object(); }
	
	if (typeof(options.name) == 'undefined') { options.name = 'win' + Math.round(Math.random()*100000); }
	
	if (typeof(options.height) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		args += "height=" + options.height + ",";
	}
	
	if (typeof(options.width) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		args += "width=" + options.width + ",";
	}
	
	if(options.position==0){
		//position == 0 means Fullscreen position
		options.x = 0;
		options.y = 0;
		args += "screenx=" + options.x + ",";
		args += "screeny=" + options.y + ",";
		args += "left=" + options.x + ",";
		args += "top=" + options.y + ",";
		args += "width=" + screen.availWidth + ",";
		args += "height=" + screen.availHeight + ",";
	}else if(options.position==1){
		//postion == 1 means center
		options.y=Math.floor((screen.availHeight-(options.height || screen.height))/2)-(screen.height-screen.availHeight);
		options.x=Math.floor((screen.availWidth-(options.width || screen.width))/2)-(screen.width-screen.availWidth);
		args += "screenx=" + options.x + ",";
		args += "screeny=" + options.y + ",";
		args += "left=" + options.x + ",";
		args += "top=" + options.y + ",";
	}else{
		//if postion == any other value or undefined, then the window pops a l:25 t:25
		options.x = 25;
		options.y = 25;
		args += "screenx=" + options.x + ",";
		args += "screeny=" + options.y + ",";
		args += "left=" + options.x + ",";
		args += "top=" + options.y + ",";
	}
 
	if (options.toolbar || typeof(options.toolbar)=='undefined') { args += "toolbar=1,"; } else if (!options.toolbar){args+="toolbar=0,";}
	if (options.location || typeof(options.location)=='undefined') { args += "location=1,"; } else if (!options.location){args+="location=0,";}
	if (options.directories || typeof(options.directories)=='undefined') { args += "directories=1,"; } else if (!options.directories){args+="directories=0,";}
	if (options.menubar || typeof(options.menubar)=='undefined') { args += "menubar=1,"; } else if (!options.menubar){args+="menubar=0,";}
	if (options.status || typeof(options.status)=='undefined') { args += "status=1,"; } else if (!options.status){args+="status=0,";}
	if (options.scrollbars || typeof(options.scrollbars)=='undefined') { args += "scrollbars=1,"; } else if (!options.scrollbars){args+="scrollbars=0,";}
	if (options.resizable || typeof(options.resizable)=='undefined') { args += "resizable=1,"; } else if (!options.resizable){args+="resizable=0,";}
	
	var newwin = window.open(anchor, options.name, args);
	return false;
 
}
