function getObj(obj) {
	
	if (document.all && !document.getElementById) {
		//alert("Internet Explorer 4");
		// Internet Explorer 4
		return document.all(obj);
	}
	if (document.all && document.getElementById) {
		//alert("Internet Explorer 5");
		// Internet Explorer 5
		return document.getElementById(obj);
	}
	if (document.layers) {
		//alert("Netscape 4");
		// Netscape 4
		return document.layers(obj);
	}
	if (!document.all && document.getElementById) {
		//alert("Netscape 6");
		// Netscape 6
		return document.getElementById(obj);
	}
	

}

function sendForm() {
	document.forms[0].submit();
}

function redirect(url,target) {
	if(target == null || target=="")
		window.location = url;
	else
		eval(target).window.location = url;
}

function isEmail(str) {
   return (	str.length > 0 &&
			str.lastIndexOf(".") > str.indexOf("@") && 
			str.indexOf("@") > 0 &&
			str.indexOf(" ") <= 0);
}

function doPrint() {
	window.print();
}

var last_v_img = "img_row_0";

function setImage(path,img_obj,row_obj,txt/*didascalia*/,params/*parametri*/) {
	if(window.last_v_img != "") 
		getObj(last_v_img).className = "image_list";
	

	getObj(row_obj).className = "img_selected";
	
	ext = path.substr(path.lastIndexOf('.') + 1);
	if(ext == 'mp4' || ext == 'flv') {
		//video
		var so = new SWFObject("swf/video_player_r1.swf", "vplayer", "590", "384", "9", "#000000");
		so.addParam("flashvars", params);
		so.addParam("allowFullScreen", "true");
		so.addParam("scale", "exactFit");
		//so.addParam("wmode", "transparent");
		so.write("media");
	} else {
		if(getObj('media').innerHTML.substr(0,4) == '<img')
			document.images[img_obj].src = path;
		else
			getObj('media').innerHTML = '<img src="'+path+'" name="'+img_obj+'" id="'+img_obj+'" />';
	}
	
	last_v_img = row_obj;
	
	//se c'è la didascalia...
	getObj('dida').innerHTML = txt;	
}

function askDelete(link_redirect) {
	if(confirm("Eliminare definitivamente?"))
		redirect(link_redirect);
}

function highlightItem(id,img) {

	if(document.getElementById(id))
		document.getElementById(id).src = 'images/'+img;
}

function openDetail(id,classe) {
	return openURL('product_detail.php?id='+id+'&class='+classe,'','width=627,height=664,scrollbars=yes,resizable=no');	
}

function openURL(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function showPrivacy() {
	ajax.requestFile = 'privacy.php';
	ajax.runAJAX();
}

function goSearch() {
	ajax.requestFile = 'results.php?txt_src='+escape(getObj('txt_src').value);
	ajax.runAJAX();
}

function display(f) {
	if (document.getElementById) {
		if(document.getElementById(f).style.display == "none")
			document.getElementById(f).style.display = "block";
		else
			document.getElementById(f).style.display = "none";
	}
}
