// JavaScript Document
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function popupopen(pagina,titolo,l,h,scroll,pos,ext,name,menusi) {
	menu = "no";
	win_name = "mywindow";
	if(ext != null) {
		if(ext == true) {
			prep = "";
			post = "";
		}
	}
	if(name != null) {
		win_name = name;
	}
	
	if(menusi != null) {
		if(menusi == true) {
			menu = "yes";
		}
	}


	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-l)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-l)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	if(pos=="right"){LeftPosition=screen.width-l-20;TopPosition=20;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+l+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar='+menu+',toolbar=no,resizable=no';
	eval(win_name+"=window.open(pagina + post,titolo,settings)");
}


function pagepopup(url,l,h,position,name,scrollbars,menubar,location,directories,status,toolbar,resizable) {

	if(url == null) {
		return false;
	}

	var argv = pagepopup.arguments;
	var argc = argv.length;

	var arrSettings = new Array();
	arrSettings[0]= new Array('pagina', null, 'string'); // url
	arrSettings[1]= new Array('width', 500, 'number'); // larghezza
	arrSettings[2]= new Array('height', 300, 'number'); // altezza
	arrSettings[3]= new Array('position', 'center', 'string', new Array('left', 'center', 'right', 'random')); // Position
	arrSettings[4]= new Array('name', 'win_' + Math.floor(Math.random()*1000000).toString(), 'string'); // nome
	arrSettings[5]= new Array('scrollbars', 'no', 'string', new Array('yes', 'no'));
	arrSettings[6]= new Array('menubar', 'no', 'string', new Array('yes', 'no'));
	arrSettings[7]= new Array('location', 'no', 'string', new Array('yes', 'no'));
	arrSettings[8]= new Array('directories', 'no', 'string', new Array('yes', 'no'));
	arrSettings[9]= new Array('status', 'no', 'string', new Array('yes', 'no'));
	arrSettings[10]= new Array('toolbar', 'no', 'string', new Array('yes', 'no'));
	arrSettings[11]= new Array('resizable', 'no', 'string', new Array('yes', 'no'));
	arrSettings[12]= new Array('top', 20, 'number');
	arrSettings[13]= new Array('left', 20, 'number');

	for (i=0;i<argc;i++) {
		if(typeof(argv[i]) == arrSettings[i][2]) {
			if((arrSettings[i].length > 3) && (typeof(arrSettings[i][4]) == 'object')) {
				for(a=0;a<arrSettings[i][4].length;a++) {
					if(argv[i] == arrSettings[i][4][a]) {
						arrSettings[i][1] = argv[i];
						continue;
					}
				}
			} else {
				arrSettings[i][1] = argv[i];
			}
		}
	}
	

	if(arrSettings[3][1] == "random") {
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-arrSettings[1][1])):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-arrSettings[2][1])-75)):100;
	} else if(arrSettings[3][1] == "center") {
		LeftPosition=(screen.width)?(screen.width-arrSettings[1][1])/2:100;
		TopPosition=(screen.height)?(screen.height-arrSettings[2][1])/2:100;
	} else if(arrSettings[3][1] == "right") {
		LeftPosition=screen.width-arrSettings[2][1]-20;
		TopPosition=20;
	} else {
		LeftPosition=0;
		TopPosition=20;
	}

	arrSettings[12][1] = TopPosition;
	arrSettings[13][1] = LeftPosition;

	var settings = '';
	settings += arrSettings[1][0] + '=' + arrSettings[1][1];
	settings += ', ' + arrSettings[2][0] + '=' + arrSettings[2][1];
	for(i=5;i<arrSettings.length;i++) {
		settings += ', ' +  arrSettings[i][0] + '=' + arrSettings[i][1];
	}
	
//	alert(settings);

	eval(arrSettings[4][1]+"=window.open(arrSettings[0][1], arrSettings[4][1] ,settings)");
}

//javascript: pagepopup('http://www.sito.it/page.php', 600, 321, 'center', 'cegos01', 'no', 'no');

function slideshow_DoFSCommand(command, args) {
	var slideshowObj = isInternetExplorer ? document.all.slideshow : document.slideshow;

	if(command == 'openWindow'){
		window.location = args;
	}
	
	if(command == 'popupWindow'){
		var qs = args.split('&');			// split the arguments
		var w = qs[1].split('=')[1];			// width
		var h = (1 * qs[2].split('=')[1]) + 19;		// height, I add 19 pixels to the height for the menu bar

		// modify this line if you have another template displaying your big view

		// qs[0]: big image src
		// qs[1]: big image width
		// qs[2]: big image height

		cmswin=window.open("big.cfm?lan=1&" + args,"cmswin","width="+w+",height="+h+",scrollbars=no,top=200,left=300,resizable=no");

		window.cmswin.focus();
	}
}
