// JavaScript Document

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 redirect(url,target) {
	if(target == null || target=="")
		window.location = url;
	else
		eval(target).window.location = url;
}

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function goToFrameFlashMovie(f)
{
	var flashMovie=getFlashMovieObject("main_clip");
	/*
	flashMovie.SetVariable("/:curr_scene", f); 
	flashMovie.TGotoFrame('/foos',2);	
	*/
	flashMovie.GotoFrame(f*25);
}

function display(f,flag) {
	if (document.getElementById) {
		if(document.getElementById(f).style.visibility == "hidden" || flag)
			document.getElementById(f).style.visibility = "visible";
		else
			document.getElementById(f).style.visibility = "hidden";
	}
	
	return document.getElementById(f);
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function showDetail(id,where,flag) {
	display(id.toLowerCase(),flag);
	ret = getObj(id.toLowerCase());
	
	target = findPos(where);
	curr_offset = findPos(ret);
		
	ret.style.top = target[1]-curr_offset[1]+"px";
	ret.style.left = target[0]-curr_offset[0]+15+"px";
}

function addToCart(pid,cod) {
	//alert('aggiungi al carrello il codice '+cod+' del prodotto padre '+pid);
	redirect('main.php?page=cart&add='+pid+"&cod="+cod);
}

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

function openPrivacyPopUp() {
	return openURL('privacy.php','','top=0,left=0,width=750,height=550,scrollbars=no,resizable=no');	
}

function openDXFPopUp(id) {
	windowWidth = 600;
	windowHeight = 300;
	
	myleft=(screen.width)?(screen.width-windowWidth)/2:100;	
	mytop=(screen.height)?(screen.height-windowHeight)/2:100;
	
	return openURL('dxf.php?id='+id,'','top='+mytop+',left='+myleft+',width='+windowWidth+',height='+windowHeight+',scrollbars=yes,resizable=no');	
	
	/*
	f = 'dxf_list';
	
	if(document.getElementById(f).style.display == "none")
		document.getElementById(f).style.display = "block";
	else
		document.getElementById(f).style.display = "none";
	*/
}
