// SCRIPTS DE DREAMWEAVER -------------------------------------------------------

// Obrir finestra
	function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
	}

// Recarregar pàgina per actualitzar posicionaments de capes amb Netscape
	function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	  	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
		  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
	}
	MM_reloadPage(true);

// Funció de recerca d'objecte
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

// Precàrrega d'imatges
	function MM_preloadImages() { //v3.0
	  	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	  	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

// Restaurar imatge rollOver
	function MM_swapImgRestore() { //v3.0
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

// rollOver
	function MM_swapImage() { //v3.0
	  	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

// Amagar-mostrar capes
	function MM_showHideLayers() { //v6.0
	  var i,p,v,obj,args=MM_showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	    obj.visibility=v; }
	}
	
// Menú <SELECT> per canviar URL - v1
	function MM_jumpMenuGo(selName,targ,restore){ //v3.0
		var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
	}

// Menú <SELECT> per canviar URL - v2
	function MM_jumpMenu(targ,selObj,restore){ //v3.0
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		if (restore) selObj.selectedIndex=0;
	}

// Mostrar text a la barra d'estat	
	function MM_displayStatusMsg(msgStr) { //v1.0
		status=msgStr;
		document.MM_returnValue = true;
	}


// SCRIPTS DE SVT, s.a. ---------------------------------------------------------

// Obrir finestra amb dades de pàgina definides des d'aplicacions o manualment
function MM_openBrWindowDinamic(theURL,winName,width,height) 
{
	var scrollbars;
	var top, left;
	
	if (width>screen.availWidth)
	{
		width = screen.availWidth - 50;
		left = 10;
		scrollbars = ', scrollbars=yes';
	}
	else
	{
		left = screen.availWidth/2 - width/2;
	}
	if (height>screen.availHeight)
	{
		height = screen.availHeight - 50;
		top = 10;
		scrollbars = ', scrollbars=yes';
	}
	else
	{
		top = screen.availHeight/2 - height/2;
	}
	window.open(theURL, winName, 'status=no, resizable=no, menubar=no, left=' + left + ', top=' + top + scrollbars + ', width=' + width + ', height=' + height);
}	

// Obrir finestra amb dades de pàgina definides des d'aplicacions o manualment amb barra d'estat
	function MM_openBrWindowDinamicStatus(theURL,winName,width,height) { //v2.0
			var scrollbars;
			var top, left;
	
		  if (width>screen.availWidth) {
			  width = screen.availWidth - 50;
	  		left = 10;
	  		scrollbars = ', scrollbars=yes';
			}
			else {
				left = screen.availWidth/2 - width/2;
	  		scrollbars = ', scrollbars=yes';
			}
		  if (height>screen.availHeight) {
	  		height = screen.availHeight - 50;
	  		top = 10;
	  		scrollbars = ', scrollbars=yes';
			}
			else {
				top = screen.availHeight/2 - height/2;
	  		scrollbars = ', scrollbars=yes';
			}
		  window.open(theURL, winName, 'status=yes, resize=no, menubar=no, left=' + left + ', top=' + top + scrollbars + ', width=' + width + ', height=' + height);
	}

// Obrir finestra amb dades de pàgina definides des d'aplicacions o manualment amb barra d'estat
	function MM_openBrWindowDinamicScroll(theURL,winName,width,height) { //v2.0
			var scrollbars;
			var top, left;
	
		if (width>screen.availWidth) {
			  	width = screen.availWidth - 50;
				left = 10;
			}
			else {
				left = screen.availWidth/2 - width/2;
			}
		if (height>screen.availHeight) {
				height = screen.availHeight - 50;
				top = 10;
			}
			else {
				top = screen.availHeight/2 - height/2;
			}
		scrollbars = ', scrollbars=yes';
		window.open(theURL, winName, 'resize=no, menubar=no, left=' + left + ', top=' + top + scrollbars + ', width=' + width + ', height=' + height);
	}

// Obrir finestra amb dades de pàgina definides utilitzant Cookies
	function MM_openBrWindowDinamicImg(theURL,strImg,winName,width,height) { //v2.0
			var scrollbars;
			var top, left;
	
		  if (width>screen.availWidth) {
			  width = screen.availWidth - 50;
	  		left = 10;
	  		scrollbars = ', scrollbars=yes';
			}
			else {
				left = screen.availWidth/2 - width/2;
			}
		  if (height>screen.availHeight) {
	  		height = screen.availHeight - 50;
	  		top = 10;
	  		scrollbars = ', scrollbars=yes';
			}
			else {
				top = screen.availHeight/2 - height/2;
			}
		  setCookie('Imatge', strImg,'' , '/aplicacions');	
		  window.open(theURL, winName, 'resize=no, menubar=no, left=' + left + ', top=' + top + scrollbars + ', width=' + width + ', height=' + height);
	}
function PreguntarAnarURL(strPregunta, strURL)
{
	if (confirm(strPregunta))
	{
		location.href = strURL;
	}
}

function openBrWindowCataleg(theURL,winName,width,height) {
	  var scrollbars;
	  var top, left;
		
	if (width>screen.availWidth) {
	  	width = screen.availWidth;
	  left = 0;
	  scrollbars = ', scrollbars=yes';
	  }
	  else {
	  	left = screen.availWidth/2 - width/2;
	  }
	if (height>screen.availHeight) {
	  height = screen.availHeight-40;
	  top = 0;
	  scrollbars = ', scrollbars=yes';
	  }
	  else {
	  	top = screen.availHeight/2 - height/2;
	  }
	window.open(theURL, winName, 'resize=no, menubar=no, left=' + left + ', top=' + top + scrollbars + ', width=' + width + ', height=' + height);
	}
	
function openBrWindowFitxa(theURL,winName) {
	  var scrollbars;
	  var top, left;
	  var width = 780;
	  var height = 450;
		
	if (width>screen.availWidth) 
		{
	  	width = screen.availWidth;
		left = 0;
		scrollbars = ', scrollbars=yes';
		}
	else
		{
	  	left = (screen.availWidth - width)/2;
	  	scrollbars = ', scrollbars=yes';
		}
	if (height>screen.availHeight) 
		{
		height = screen.availHeight-40;
		top = 0;
		scrollbars = ', scrollbars=yes';
		}
	else 
		{
	  	top = (screen.availHeight - height)/2;
		}
	
	window.open(theURL, winName, 'resize=no, menubar=no, left=' + left + ', top=' + top + scrollbars + ', width=' + width + ', height=' + height);
}
function openBrWindowVariante(theURL,winName) {
	  var scrollbars;
	  var top, left;
	  var width = screen.availWidth-100;
	  var height = screen.availHeight-100;
		
	if (width>screen.availWidth) 
		{
	  	width = screen.availWidth;
		left = 0;
		scrollbars = ', scrollbars=yes';
		}
	else
		{
	  	left = 0;
	  	scrollbars = ', scrollbars=yes';
		}
	if (height>screen.availHeight) 
		{
		height = screen.availHeight-40;
		top = 0;
		scrollbars = ', scrollbars=yes';
		}
	else 
		{
	  	top = 0;
		}
	
	window.open(theURL, winName, 'resize=no, menubar=no, left=' + left + ', top=' + top + scrollbars + ', width=' + width + ', height=' + height);
}

// Buidar <INPUT> al situar-se a sobre
	var bInputModificat = false;
	function BuidarInput (objInputText) {
		if (! bInputModificat) {
			objInputText.value = '';
			bInputModificat = true;
		}
	}
//Carregar Producte al catáleg
function Carrega (producte)
	{
	switch(producte){
		case "motores":
			top.f1.location.href = "cataleg_f1.asp";
			top.f2.location.href = "catalegbuit_f2.asp";
			break;
		case "culatasn":
			top.f1.location.href = "catalegculatasn_f1.asp";
			top.f2.location.href = "catalegbuit_f2.asp";
			break;
		case "turbos":
			top.f1.location.href = "catalegturbos_f1.asp";
			top.f2.location.href = "catalegbuit_f2.asp";
			break;
		case "bombas":
			top.f1.location.href = "catalegbombas_f1.asp";
			top.f2.location.href = "catalegbuit_f2.asp";
			break;
		case "kit":
			top.f1.location.href = "catalegkit_f1.asp";
			top.f2.location.href = "catalegbuit_f2.asp";
			break;
		case "cajasa":
			top.close();
			novaFin = window.open("/cas/productes/canvis/cataleg_cambioAutomatico.asp");
			break;
		case "cajasm":
			top.f1.location.href = "catalegcajasm_f1.asp";
			top.f2.location.href = "catalegbuit_f2.asp";
			break;
		default:
			top.f1.location.href = "cataleg_f1.asp";
			top.f2.location.href = "catalegbuit_f2.asp";
			break;
	}	
}

