/* Funzioni generali x rto */

function selImgSys(){
	document.getElementById('imsystab').style.border = '2px dashed red';
}

function goHere(url){
	location.href = url;
}

function surer(txt_conf, url, donot){
	if (confirm(txt_conf)){
		location.href = url;
	}else{
		if (donot){
			location.reload();
		}
	}
}

function onlyNumber(obj){
	if (obj.value!=''){
		if (isNaN(obj.value)){
			obj.value = '';
		}
	}
}

function setImgPres(path, to){
	to.value = path;
}

function fromPCtoImg(frm1,frm2,pre){
	frm1.submit();
	comp = frm1.file.value; // percorso locale del file
	comp = comp.replace(/\\/g, "/"); //--------------->
	ini = comp.lastIndexOf("/"); //------------------>
	nome = comp.substr(ini+1,comp.length); // ultima parte --> nome file
	pre = "";
	switch(frm2.name){ // SWITCH al posto di un semplice IF per eventuali sviluppi futuri
		case "aaa":
			pre = "aaa/";
		break;
	}
	frm2.img.value = pre+nome;
	//prevImg('../'+pr2+frm2.img.value, 0, 0);
}

function prevImg(path, dim, ke){
		if (ke==1){ //gallery in sito
			if(parseInt(dim)>300){
				document.images['imma'].style.width = '300';
			}else{
				document.images['imma'].style.width = dim;
			}
		}else if(ke==2){// gallery esterna
			document.images['imma'].style.width = null;
			document.images['imma'].style.height = null;
			ard = dim.split("x");
			if (parseInt(ard[0])>parseInt(ard[1])){
				if(parseInt(ard[0])>450){
					document.images['imma'].style.width = '450';
				}else{
					document.images['imma'].style.width = ard[0];
				}
			}else{
				if(parseInt(ard[1])>450){
					document.images['imma'].style.height = '450';
				}else{
					document.images['imma'].style.height = ard[1];
				}
			}
		}
		document.images['imma'].style.visibility = 'visible';
		document.images['imma'].src = path;
		if(document.getElementById('immaref'))
			document.getElementById('immaref').href = (location.href.substring(0,location.href.lastIndexOf("/"))) + "/" + path;
}

function addSong(divobj, num){
	var str = '';
	for (j=0; j<num; j++){
		var i = cSng;
		str += "\n"+'<table border="0" cellpadding="1" cellspacing="0"><tr>';
		str += '<td style="width:80px; text-align:center"><INPUT type="text" name=npo['+i+'] size="2" value="'+(i+1)+'"></td>';
		str += '<td style="width:300px"><input type="text" name=stit['+i+'] style="width:300px;"></td>';
		str += '<td style="width:50px; text-align:center"><INPUT type="checkbox" value="1" name=inew['+i+'] checked="checked"></td><td style="width:50px; text-align:center">&nbsp;</td></tr></table>';
		cSng++;
	}
	divobj.innerHTML += str;
}
function adduser() {
theUrl="addUser.php";
reWin = window.open(theUrl,'adduser','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=450,top=100,left=100');
}

function verita() {
theUrl="serv.ins.asp";
reWin = window.open(theUrl,'verita','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=100,top=100,left=100');
}

function miss() {
theUrl="iscrivimiss.php";
reWin = window.open(theUrl,'miss','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=400,top=100,left=100');
}

function movie() {
theUrl="vid.php";
reWin = window.open(theUrl,'miss','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=400,top=100,left=100');
}

function svalentino() {
theUrl="s.valentino.php";
reWin = window.open(theUrl,'svalentino','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=450,top=100,left=200');
}

function vota() {
theUrl="vota.php";
reWin = window.open(theUrl,'vota','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=250,height=550,top=100,left=100');
}
function ibiza() {
theUrl="ibiza";
reWin = window.open(theUrl,'sendamail','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=850,height=650,top=0,left=0');
}

function sendamail() {
theUrl="modulo invia/modulo.php";
reWin = window.open(theUrl,'sendamail','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=400,height=300,top=100,left=100');
}

function sendasong() {
theUrl="robertobagazzoli/modulo.php";
reWin = window.open(theUrl,'sendamail','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=534,height=715,top=50,left=50');
}

function stream() {
theUrl="streaming.php";
reWin = window.open(theUrl,'onstream','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=350,top=100,left=100');
}

function concorsoibiza() {
theUrl="ibiza/gallery.php";
reWin = window.open(theUrl,'onstream','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=590,height=500,top=100,left=100');
}

function chat() {
theUrl="chat.php";
reWin = window.open(theUrl,'onchat','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=250,top=100,left=100');
}

function aggiornacam(){
	var now=new Date();
	now=Date.parse(now)/1000;
	var x=parseInt(counts-(now-start),15);
	if(document.form1){document.form1.clock.value = x;}
	if(x>0){
		timerID=setTimeout("aggiornacam()", 100)
	}else{
		location.href="webcam.php"
	}
}
