/*
.........................
::   JavaScript Lib v0.1   ::
:: www.httpcomunicacio.com ::
.........................
*/


/*
.........................
:: Window Popper ::
.........................
*/

function pop(u,n,f, w, h, c) {
  if(window.screen)if(c)if(c=="1"){
    var l = (screen.width-w)/2;
    var t = (screen.height-h)/2;
    f+=(f!='')?',':'';
    f+='left='+l+',top='+t;
  }
  flop=window.open(u,n,f+((f!='')?',':'')+'width='+w+',height='+h);
  flop.focus();
}

function popo(u,n,f, w, h, c) {
  if(window.screen)if(c)if(c=="1"){
    var l = (screen.width-w)/2;
    var t = (screen.height-h)/2;
    f+=(f!='')?',':'';
    f+='left='+l+',top='+t;
  }
  flop=window.open(u,n,f+((f!='')?',':'')+'width='+w+',height='+h);
  flop.focus();
}


function ventanaSecundaria (URL){
window.open(URL,"ventana1","width=320, height=450, scrollbars=no, menubar=no, location=no, resizable=yes")
}

var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}


/*
.........................
:: Switch Div ::
.........................
*/

function switchDiv(divNum){
	x=document.getElementById("s" + divNum);
	y=document.getElementById("i" + divNum);
	if(x.style.display != "block"){
		x.style.display="block";
		y.src="img/menuOpen.gif";
	}else{
		x.style.display="none";
		y.src="img/menuClosed.gif";
    }
}


/*
.........................
:: The xRollovers ::
.........................
*/

function xOn(theId) {
	xfile=document.getElementById(theId)
	xname=xfile.getAttribute('src')
	x=xname.length
	xext=xname.substring(x-4,xname.length)
	xname=xname.substring(0,x-4)
	xfile.src=xname+".on"+xext
}

function xOff(theId) {
	xfile=document.getElementById(theId)
	xname=xfile.getAttribute('src')
	x=xname.length
	xext=xname.substring(x-4,xname.length)
	xname=xname.substring(0,x-7)
	xfile.src=xname+xext
}


/*
.........................
:: Cookie Recipes ::
.........................
*/

function saveCookie(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000))
                var expires = "; expires="+date.toGMTString()
        }
        else expires = ""
        document.cookie = name+"="+value+expires+"; path=/"
}

function readCookie(name) {
        var nameEQ = name + "="
        var ca = document.cookie.split(';')
        for(var i=0;i<ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length)
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
        }
        return null
}

function deleteCookie(name) {
        saveCookie(name,"",-1)
}


/*
.........................
:: Event Listener Interface ::
.........................
*/

function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    //alert("Handler could not be attached");
  }
}

function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    //alert("Handler could not be removed");
  }
}


function abreSec(num){		
	for(i=1;i<=2;i++) {
		obj=document.getElementById('tec'+i);
						
		if(i==num)	obj.style.display="block";			
		else obj.style.display="none";					
	}		
}

function getIniScroll(){
    return (window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop);
}


function scrolea(end){
	ini=getIniScroll();
	steps=20;
	for(i=1;i<=steps;i++){
		paso=Math.sin(i/steps * Math.PI/2);
		setTimeout('window.scrollTo(0,'+(Math.round(ini+(end-ini)*paso ))+')',i*40);
	}
}

function slideshow_automatic2(i,j){ 
	
	   if (i==1)  $('#slideshow2 #ban'+(j)).fadeOut('slow');
	   else $('#slideshow2 #ban'+(i-1)).fadeOut('slow');	
	   
	   $('#slideshow2 #ban'+i).fadeIn('slow');
	   
	   i++;	   
	   if (i==(j+1)) i=1; 
	   
	   temporizador=setTimeout("slideshow_automatic2("+i+","+j+")",5000);

}


	
	
	
	
	
