/* popup */
function imgzoom(imgorig){
	var w=500;
	var h=500;
	var settings='location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,fullscreen=no';
	
	var x=(screen.width-w)/2;
	var y=(screen.height-h)/2-20;
	if(x<0)x=0;
	if(y<0)y=0;
	if(w>screen.width)w=screen.width;
	if(h>screen.height)h=screen.height;
	var set='top='+y+',left='+x+',width='+w+',height='+h+','+settings;
	var popup=window.open(imgorig,'zoom',set);
	popup.focus();
}

	
function openVideo(idvideo){
	var winw=400;
	var winh=350;
	var winl=(screen.width-winw)/2;
	var wint=(screen.height-winh)/2;
	var videopopup = window.open("/video/video.shtml?"+idvideo,"StrisciaLaNotizia_VideoPopoup","top="+wint+",left="+winl+",width="+winw+",height="+winh+",toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no");
	videopopup.focus();
}

function openVideoLl(pathvideo){
	if(pathvideo.indexOf(".flv")>-1){
		var winw=450;
		var winh=350;
		var winl=(screen.width-winw)/2;
		var wint=(screen.height-winh)/2;
		var videopopup = window.open("/video/videoflv.shtml?"+pathvideo,"StrisciaLaNotizia_VideoPopoup","top="+wint+",left="+winl+",width="+winw+",height="+winh+",toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no");
		videopopup.focus();
	}else{
		var winw=400;
		var winh=350;
		var winl=(screen.width-winw)/2;
		var wint=(screen.height-winh)/2;
		var videopopup = window.open("/video/videoll.shtml?"+pathvideo,"StrisciaLaNotizia_VideoPopoup","top="+wint+",left="+winl+",width="+winw+",height="+winh+",toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no");
		//var videopopup = window.open("/video/video.shtml?"+idvideo,"StrisciaLaNotizia_VideoPopoup","top="+wint+",left="+winl+",width="+winw+",height="+winh+",toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no");
		videopopup.focus();
	}
}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}	
}



/* search google */

function initFieldSearch(objform){
	var url;
	if(readUrl('q') !='' || readUrl('q') !='inserire il testo da cercare'){
		for(i=0; i<objform.length; i++){
					if(objform.elements[i].id =='q'){
					url = readUrl('q');
					url = unescape(url);
					url = url.replace("+"," ");
					objform.elements[i].value = url;
					}
		}
	}
}

function readUrl(param){
	var theurl=window.location.toString()+"&";
	var posparam=theurl.indexOf(param+"=");
	if(posparam==-1)return"";
	var sottostringa=theurl.substring(posparam);
	var start=sottostringa.indexOf("=");
	var end=sottostringa.indexOf("&");
	var val=sottostringa.substring(start+1,end);
	return val;
}

function goSearch(obj) {
	if (obj.q.value.length > 0 ) {
		if (tok(obj.q) == true) return true;       
	} else
		alert("Inserire la parola da cercare!");     
	return false; 
}

var ALPHANUMERICS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890אטילעש"
function tok(theObj){
	var text=theObj.value+" ";
	var pos,pos1=0;
	var finale,word,ch=" ";
	var find=true;
	var fword=false;
	for(var i=0;i<text.length;i++){
		ch=text.charAt(i);
		if(ch==" "){
			if(find!=true){
				find=true;
				pos1=i;
				word=text.substring(pos,pos1);
				if(word.substring(0,1)==" ")word=word.substring(1,word.length);
				var wU=word.toUpperCase();
				if(wU=="AND"||wU=="OR"||wU=="NOT"){
						alert("La parola ' "+wU+" ' non ט ammessa");
					theObj.focus();
					return false;
				}
				pos=pos1;
				if(fword==false){
					finale=word;
					fword=true;
				}else
					finale=finale+" "+word;
			}else
				pos=i+1;
			}else{
				if(ALPHANUMERICS.indexOf(ch)==-1){
					alert("Il carattere ' "+ch+" ' non ט ammesso");
				theObj.focus();
				return false;
			}
			find=false;
			}//end if
	}//end for
	if(fword==false){
		if(lang=='it')
			alert("Inserisci la/e parola/e che vuoi ricercare!");
		else
			alert("Insert the word that you want to search!");
		theObj.value="";
		theObj.focus();
		return false;
	}
	theObj.value=finale;
	return true;
}

/*end google*/
