/*
	_library classes:
	$Revision: 1.9 $
*/

function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
		cntfield.value = maxlimit - field.value.length;
}

/*	TRIM SPACES	*/
function trim(str)	{
	return str.replace(/^\s*|\s*$/g,"");
}

function checkEmail(mailToTest)	{	
	var pattern	= /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
	if(pattern.test(mailToTest)) {         
		return true;
	} else {   
		return false;
	}
}

function changeBodyClass(cName)	{
	//alert(cName);
	newImage	= 'url(' + cName + ')';
	document.body.style.backgroundImage	= newImage;
	//document.getElementById(divID).className	= cName;
}

function setHeightCellSWFMain(divID,h)	{
	var el	= document.getElementById(divID);
	el.style.height	= h;
}
function setHeightObjectSWFMain(objID,h)	{
	var el	= document.getElementById(objID);
	el.style.height	= h;
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function theOpener(theUrl,WinName,width,height,scrollbar,resize,msgNoPopUp,goTo) {
//	theUrl 		= The page
//	width		= Width of the window
//	height		= Height of the windows
//	scroll		= Do You want the Scroll??? ][ Value = yes|no
//	resize		= Do You want to resize Window??? ][ Value = yes|no
//	msgNoPopUp	= set a message if popUp is not opened (aka blocked by a PopUp blocker)
//	goTo		= set a page where to go if popUp is not opened
//
//	by kender
//
	var x = screen.availWidth
	var y = screen.availHeight
	var spaceSx = (x - width)/2
	//var spaceUp = 0										// To Point PopUp top
	var spaceUp = (y - height)/2							// To point PopUp in the center

	winparams	= ""										// Start Params for Window
	winparams	= winparams + "scrollbars=" 	+ scrollbar	// Scroll
	winparams 	= winparams + ",resizable=" 	+ resize	// Resizable
	winparams 	= winparams + ",left=" 			+ spaceSx	// Space From Left
	winparams 	= winparams + ",top=" 			+ spaceUp	// Space From Top
	winparams 	= winparams + ",width=" 		+ width		// Windowz Width
	winparams 	= winparams + ",height=" 		+ height	// Windowz Height
	winparams 	= winparams + ",directory=no"				// The Tool Bar Menu
	winparams 	= winparams + ",status=no"					//
	winparams 	= winparams + ",location=no"				//
	winparams 	= winparams + ",toolbar=no"					// -------------------
	// Open window
	//window.open(theUrl,WinName,winparams);

	var ThoR	= window.open(theUrl,WinName,winparams);
	if (ThoR==null || typeof(ThoR)=="undefined")	{
		if (msgNoPopUp != "")	{
			alert(msgNoPopUp);
		}
		if (goTo != "")	{
			location.href	= goTo;
		}
	} else {
		// Active window
		ThoR.focus();
	}

}

function popUpPrinter(divID)	{
	//var oldCSSClass	= 'contactContentTXT withPadding3 blue01';
	//document.getElementById(divID).className	= 'contactContentTXTPrint';
	//alert('stampa e cssClassOld: ' + oldCSSClass);
	print();
	//document.getElementById(divID).className	= oldCSSClass;
}

/**
 *  get a param from query string
 */

	function getParam( name ){
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( window.location.href );
	  if( results == null ){
	    return "1";
	  }else{
	    return results[1];
	  }
	}

/**
 *  get the swf movie into the page
 */
	
	function getFlashMovie(movieName) {
	  var isIE = navigator.appName.indexOf("Microsoft") != -1;
	  return (isIE) ? window[movieName] : document[movieName];
	}
	 
	function vote() {
	  var movie = getFlashMovie("gameDetail");
	  movie.vote();
	}
	 
	function reload() {
	  var sURL = unescape(window.location.href);
	  window.location.href = sURL;
	}
	
	function spotlight(catVal) {
		var spotlighttag;
		var Tag;
		var axel = Math.random() + "";
		var ord = axel * 1000000000000000000;
		var prx = "?";
		
		spotlighttag="http://ad.no.doubleclick.net/activity;src=1390954;type=kungf455;cat="+catVal+";ord="+ord+prx;
		Tag = new Image();
		Tag.src = spotlighttag;
	}
	
	function get_url_param( name )
	{
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( window.location.href );
	  if( results == null )
	    return "";
	  else
	    return results[1];
	}
