﻿function popup_mappa(){
    var width = screen.width-100;
    var height = screen.height-100;
    var left = 10;
    var top = 10;        	
    var locWindow = window.open("Mappa.aspx", "mappa", "directories = no,width = " + width + "px,height = " + height + "px,top = " + top + "px,left = " + left + "px,location = no, menubar = no,status = no,toolbar = no,resizable = yes");
    locWindow.focus();
}


function OpenFullscreen(url,w,h,name) {
	var Args = OpenFullscreen.arguments;
	w=(Args[1]!= null) ? Args[1] : 950;
	h=(Args[2]!= null) ? Args[2] : 610;
	name=(Args[3]!= null) ? Args[3] : 'MAPPAINTERATTIVA';
	
	var scrW = screen.availWidth; var scrH = screen.availHeight;
	var left = Math.floor(Math.max(20, (scrW - w)/2)); bw = Math.min(scrW - 20, left + w) - left;
	var top = Math.floor(Math.max(20, (scrH - h)/2)); h = Math.min(scrH - 20, top + h) - top;
	
	var m = window.open(url,name,'width='+w+',height='+h+',top='+top+',left='+left+', status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
	GoFullscreen(m);
}

function GoFullscreen(win) {
 win = win ? win : top.window;
	win.moveTo(0,0);
	win.resizeTo(screen.availWidth,screen.availHeight);
	win.focus();
}

function SetSize(size) {
 setStyleByClass('','corpo-testo','fontSize',size);
}

function setStyleByClass(t, c, p ,v) {
//  t - element type
//  c - class identifier
//  p - CSS property
//  v - property value	
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules || sheets[x].rules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// use the native selectorText and style stuff
					if ((rules[y].selectorText == c) || (rules[y].selectorText == (t + "." + c))) {
						z[p] = v;
						createCookie(p,v);
	}}}}}
	return null;
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
