<!--//
//
// The following javascript is included in the main body of the page so that
// the server gzip output will compress this content too - big bandwidth saver!
//

//
// Standard functions - derived from the Dithered 1k JS library: http://www.dithered.com/javascript/
d=document;l=d.layers;op=navigator.userAgent.indexOf('Opera')!=-1;var ie=d.all?1:0;var w3c=d.getElementById?1:0;
//d=document;l=d.layers;op=navigator.userAgent.indexOf('Opera')!=-1;px='px';
//function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);}
//if(ie) w3c = 0;
// Get element
function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}g=(f)?f:d;if(g.all)return g.all[e];return g.getElementById(e);}
// Show element
function sE(e){l?e.visibility='show':e.style.visibility='visible';}
// Hide element
function hE(e){l?e.visibility='hide':e.style.visibility='hidden';}
// Get X position
function gX(e){if(l){return e.left;}else if(ie){return e.style.pixelLeft;}else{return parseInt(e.style.getPropertyValue('left'));}}
function gX2(e){if(l){return e.left;}else if(ie){return e.style.pixelLeft;}else{s=getComputedStyle(e,null);return parseInt(s.getPropertyValue('left'));}}
// Get Y position
function gY(e){if(l){return e.top;}else if(ie){return e.style.pixelTop;}else{return parseInt(e.style.getPropertyValue('top'));}}
function gY2(e){if(l){return e.top;}else if(ie){return e.style.pixelTop;}else{s=getComputedStyle(e,null);return parseInt(s.getPropertyValue('top'));}}
// Get width
function gW(e){if(l) return e.clip.width; else return e.offsetWidth;}
// Get height
function gH(e){if(l) return e.clip.height; else return e.offsetHeight;}
// Set depth
function sZ(e,z){l?e.zIndex=z:e.style.zIndex=z;}
// Set X position
function sX(e,x){l?e.left=x:op?e.style.pixelLeft=x:e.style.left=x;}
// Set Y position
function sY(e,y){l?e.top=y:op?e.style.pixelTop=y:e.style.top=y;}
// Set width
function sW(e,w,m){if(!m)m=0;l?e.clip.width=w:op?e.style.pixelWidth=w:e.style.width=w-m;}
// Set height
function sH(e,h,m){if(!m)m=0;l?e.clip.height=h:op?e.style.pixelHeight=h:e.style.height=h-m;}
// Set layer clipping area
function sC(e,t,r,b,x){l?(X=e.clip,X.top=t,X.right=r,X.bottom=b,X.left=x):e.style.clip='rect('+t+' '+r+' '+b+' '+x+')';}
// Write HTML
function wH(e,h){if(l){Y=e.document;Y.open();Y.write(h);Y.close();}else if(e.innerHTML){e.innerHTML='';e.innerHTML=h;}}
// Copy HTML content from element e1 into e2
function cH(e1,e2){wH(e2,e1.innerHTML);}
// Move layer
function mL(e,x,y){sX(e,x);sY(e,y);}
// Resize layer
function rL(e,w,h,m){if(ie)m=0;sW(e,w,m);sH(e,h,m);}
// Browser width
function bW(){if(!ie) return window.innerWidth;else return document.body.clientWidth;}
// Browser height
function bH(){if(!ie) return window.innerHeight;else return document.body.clientHeight;}
// Roll image over
function rO(n,i,s){e=gE(n);e.src=(s==1)?imgDir+i+"-over.gif":imgDir+i+".gif";}
// Swap image
function sI(n,i){e=gE(n);e.src=i;}
// Preload images
function pI(){d.pli=new Array();var i,j=d.pli.length,a=pI.arguments;for(i=0;i<a.length;i++) if(a[i].indexOf("#")!=0){d.pli[j]=new Image;d.pli[j++].src=a[i];}}
// Change object class
function cC(n,c){e=gE(n);e.className=c;}
// Change object display (more than just hiding)
function dE(e,s){if(typeof e=="string")e=gE(e);if(!s)s=(e.style.display=='')?-1:1;e.style.display=(s==1)?'':'none';}

////
/*
  Easing Equations v1.4
  March 19, 2003
  (c) 2003 Robert Penner - Use freely, giving credit where you can.
  
  http://www.robertpenner.com/
*/

///////////// QUADRATIC EASING: t^2 ///////////////////
// t: current time, b: beginning value, c: change in value, d: duration
// t and d can be in frames or seconds/milliseconds

// quadratic easing in/out - acceleration until halfway, then deceleration
Math.easeInOutQuad = function (t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t + b;
	return -c/2 * ((--t)*(t-2) - 1) + b;
};


///////////// QUINTIC EASING: t^5  ////////////////////
// t: current time, b: beginning value, c: change in value, d: duration
// t and d can be frames or seconds/milliseconds

// quintic easing out - decelerating to zero velocity
Math.easeOutQuint = function (t, b, c, d) {
	return c*((t=t/d-1)*t*t*t*t + 1) + b;
};


/////////// BACK EASING: overshooting cubic easing: (s+1)*t^3 - s*t^2  //////////////
// back easing in - backtracking slightly, then reversing direction and moving to target
// t: current time, b: beginning value, c: change in value, d: duration, s: overshoot amount (optional)
// t and d can be in frames or seconds/milliseconds
// s controls the amount of overshoot: higher s means greater overshoot
// s has a default value of 1.70158, which produces an overshoot of 10 percent
// s==0 produces cubic easing with no overshoot
Math.easeInBack = function (t, b, c, d, s) {
	if (typeof s == "undefined") s = 1.70158;
	return c*(t/=d)*t*((s+1)*t - s) + b;
};

// back easing out - moving towards target, overshooting it slightly, then reversing and coming back to target
Math.easeOutBack = function (t, b, c, d, s) {
	if (typeof s == "undefined") s = 1.70158;
	return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
};

// back easing in/out - backtracking slightly, then reversing direction and moving to target,
// then overshooting target, reversing, and finally coming back to target
Math.easeInOutBack = function (t, b, c, d, s) {
	if (typeof s == "undefined") s = 1.70158; 
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
};

//// Specific functions for the Become Interactive website
// (c) Become Interactive 2003
//
// Updated by Tom 17/5/03
// Now much better code! More stable, versatile and efficient
// Its amazing what a difference a year can make ;-)
//
//

var tween = new Array();
var tween_count = 0;
var tween_url = "";
var tween_feedback1 = '';
var tween_feedback2 = '';


// Tween It - Move & Resize Layer
//
// n = layer id name
// x = xpos, tx = target x, y = ypos, ty = target y
// w = width, tw = target width, h = height, th = target height
// d = duration of animation, q = -1 if not wanting to use tween_count
//
function tweenIt(n){
	var a = tween[n];
	var e = gE(a.id);
	var ease_fn = (!a.f) ? tween_ease_fn : a.f;	// Easing fn to use
	var spd = (!a.v) ? tween_delay : a.v;		// Delay between repeating ani (in ms)
	var mv = false;								// Set true when movement done
	
	if(typeof a.t == "undefined") a.t = 0;
	if(!a.q) a.q = 1;
	if(!a.d) a.d = tween_duration;
	if(typeof a.p == "undefined") a.p = 0;
	if(typeof a.x == "undefined") a.x = gX(e);
	if(typeof a.y == "undefined") a.y = gY(e);
	if(!a.w) a.w = gW(e);
	if(!a.h) a.h = gH(e);
	if(!a.tw) a.tw = a.w;
	if(!a.th) a.th = a.h;
	
	// Set flags to indicate movement in progress
	if(!a.z) {
		a.z = 1;
		if(tween_count == 0) tween_feedback1 = '';
		if(a.q != -1) tween_count++;
		//if( debug > 0 ) wH(gE("js_feedback1"),tween_count);
	}
	
	window.clearTimeout(a.ct);
	
	// Apply movement and resize
	if(typeof a.tx != "undefined") {
		sX(e,Math.floor(Math[ease_fn](a.t,a.x,a.tx-a.x,a.d)));
		mv = true;
	}
	if(typeof a.ty != "undefined") {
		sY(e,Math.floor(Math[ease_fn](a.t,a.y,a.ty-a.y,a.d)));
		mv = true;
	}
	if(a.w != a.tw || a.h != a.th){
		var m = 2+(a.p*2);
		var w = Math.floor(Math[ease_fn](a.t,a.w,a.tw-a.w,a.d));
		var h = Math.floor(Math[ease_fn](a.t,a.h,a.th-a.h,a.d));
		mv = true;
		rL(e,w,h,m);
		sC(e,0,w,h,0);
	}
	a.t++;
	
	if( !mv ) a.t = a.d;
	
	// End conditions
	if( a.t <= a.d ){
		a.ct = window.setTimeout("tweenIt('"+n+"')",spd);
	} else {
		if(a.tx) sX(e,a.tx);
		if(a.ty) sY(e,a.ty);
		if(a.w != a.tw || a.h != a.th){
			rL(e,a.tw,a.th,m);
			sC(e,0,a.tw,a.th,0);
		}
		
		if(a.q != -1) tween_count--;
		delete a.z;
		
		//if( debug > 0 ) wH(gE("js_feedback1"),tween_count+" | "+tween_feedback1);
		//if( debug > 0 ) wH(gE("js_feedback2"),tween_count+" | "+tween_feedback2);
		if( tween_count == 0) {
			tween_feedback2 = '';
			ani_done = true;
		}
		if( a.p || a.b || a.c || a.s || a.u || a.cbf ){
			a.ct = window.setTimeout("tweenCallback('"+n+"')",75);	// Delay req. for quirks
		}
	}
}


// Prepare for tween motion - clears the block
//
function prepTween(n){
	var a = tween[n];
	var e = gE(a.id);
	
	if(a.c) e.style.background = a_colour;	// Set background colour
	if(a.c) wH(e,blank_block);
	tweenIt(n);
}


// Tween callback - what to do when tween finished
//
// c = final colour of block
// u = url of content to load, m = margin size, p = padding
// s = source-code to load into block, b = scrollbars (yes/no)
// cbf = call-back func., cbfd = call-back func delay
// ct = clear timeout
function tweenCallback(n){
	var a = tween[n];
	var e = gE(a.id);
	
	window.clearTimeout(a.ct);
	
	if(a.c) e.style.background = a.c;		// Set background colour
	e.style.padding = (!a.p) ? 0 : a.p;		// Set padding
	e.style.overflow = (!a.b) ? "hidden" : a.b;	// Set scrollbars
	
	if(a.s) {
		wH(e,a.s);						// Write html into bock
		
	} else if(a.u) {
		// Tweak - border of 2px (1px each side) + twice padding of layer
		var w = a.tw-(2+(a.p*2));
		var h = a.th-(2+(a.p*2));
		if(!a.sb) a.sb = "no";	// Scrollbars
		var code = '<iframe src="'+a.u+'" id="ifr_'+n+'" name="ifr_'+n+'" frameborder="0" width="'+w+'" height="'+h+'" scrolling="'+a.sb+'"></iframe>';
		wH(e,code);						// Write iframe into block
	}
	
	// Load page content into 'sub' frame - bit of a tweak for mac IE5.1
	if( tween_count < 3 && tween_url != ""){
		var url = tween_url;
		tween_url = "";
		parent.subFrame.location.href = url;
	}
	
	// If callbackfunc (cbf) defined then evaluate
	if( a.cbf ) {
		if(!a.cbfd) a.cbfd = 10;	// Default call-back func delay
		a.ct = window.setTimeout(a.cbf,a.cbfd);
	}
}

function tweenDebug(n){
	var msg = 'DEBUG for '+n+"\n";
	for(var debug in tween[n]){
		msg += debug+": "+tween[n][debug]+"\n";
	}
	alert(msg);
}


// Contact flasher
function flashContact(cf){
	if( cf == 1 ){
		// Flash it (dirty boy!)
		tween["contactFlash"] = {id:"contactFlash",ty:3,f:"easeOutBack",d:20,q:-1};
		tweenIt("contactFlash");
	} else {
		// Hide flasher after a delay
		tween["contactFlash"] = {id:"contactFlash",ty:33,f:"easeInBack",d:20,q:-1};
		tween["contactFlash"].ct = window.setTimeout("tweenIt('contactFlash')",750);
	}
}

// Scrolling window for the clients list
// n = name of block to scroll, dr = direction (-1 down,1 up), h = distance to move
// o = orientation (-1=y,1=x)
function scroller(n,h,dr,o){
	if(tween_count > 0) return;
	if(!o) o = -1;
	
	var e = gE(n);
	var y = gY(e);
	var x = gX(e);
	var nh = gH(e);
	var hm = gH(gE(n+"Mask"));
	var nw = gW(e);
	var wm = gW(gE(n+"Mask"));
	
	var ty = (o==-1) ? y+(h*dr) : y;
	var tx = (o== 1) ? x+(h*dr) : x;
	
	if( o == -1 ){
		if( ty > 0 || ty+nh-hm < 0 ) return;		// Out of range
	} else {
		if( tx > 0 || tx+nw-wm < 0 ) return;		// Out of range
	}
	
	// Callback function set to continue scrolling until mouseout
	tween[n] = {id:n,tx:tx,ty:ty,f:"easeInOutQuad",d:20,cbf:"scroller('"+n+"',"+h+","+dr+","+o+")"};
	prepTween(n);
}

// Stop callback function for scroller
function scrollerStop(n){
	if(typeof(tween[n]) == "object" ) tween[n].cbf = '';
}

// Load URL in iframe
function load_url(u,f){
	parent[f].location.href = u;
}

// GetContent from subFrame element (es) and copy to element on this page (et)
function getContent(es,et,ef){
	if(!ef) ef = parent.subFrame.document;
	cH(gE(es,ef),gE(et));
}

// Highlight error fields
function show_errors(){
	if( input_error.length > 1 ){
		for(i=1;i<input_error.length;i++){
			// Highlight error elements
			cC(input_error[i],'errorField');
		}
	}
}

// Grab the data from the hidden frame for the debug
// f = frame grabbing from; o = object name to grab from;
function debugConsole(o){
	e = gE(o);
	debug_code = e.innerHTML;
	debugLaunch();
}

function debugLaunch(){
	cw = "debugWindow";
	debugWindow = open(root_path+'debug.php',cw,'toolbar=no,location=no,status=yes,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=450,height=600,left=10,top=10');
}

// Highlight error fields
function show_errors(){
	if( input_error.length > 1 ){
		for(i=1;i<input_error.length;i++){
			// Highlight error elements
			cC(input_error[i],'errorField');
		}
	}
}

// Showcase animation
function showcaseAnim(){
	
	var old_showcase_ani = showcase_ani;
	showcase_ani = (showcase_ani > 2) ? 1 : showcase_ani+1;
	var showcase_ani2 = (showcase_ani+1 > 3) ? 1 : showcase_ani+1;
	
	tween["showcaseSub"+showcase_ani] = {id:"showcaseSub"+showcase_ani,ty:-175,f:"easeInOutBack",d:40,q:-1};
	tween["showcaseSub"+showcase_ani2] = {id:"showcaseSub"+showcase_ani2,ty:0,f:"easeInOutBack",d:40,q:-1,cbf:"showcaseAnim()",cbfd:2000};
	prepTween("showcaseSub"+showcase_ani);
	prepTween("showcaseSub"+showcase_ani2);
	sY(gE("showcaseSub"+old_showcase_ani),175);
}

// Showcase swf loader
function loadShowcase(swf){
	var e = gE("showcase_swf");
	document.getElementById("showcase_swf").SetVariable("_root.loadswf",swf);
}




// Centre to the middle of the page
function centrepage(){
	var bw = bW();
	var bh = bH();
	var e = gE('main');
	var x = gX(e);
	var y = gY(e);
	var nx = Math.floor(bw/2 - 380);
	var ny = Math.floor(bh/2 - 220);
	if(nx<0) nx=0;
	if(ny<0) ny=0;
	if(x != nx || y != ny)	mL(e,nx,ny);
}

// Run JS command from another frame (for Mac compatibility)
function jsCall(cmd){
	window.clearTimeout(jsFnCall);
	jsFnCall = setTimeout(cmd,20);
}

// Ajusta página al 100%
function ajustar() {
	if (ie || op) 
		gE('cuerpo').style.height = document.body.clientHeight - gE('cabeza').offsetHeight - gE('pie').offsetHeight;	
	else
		gE('cuerpo').style.height = self.innerHeight - gE('cabeza').offsetHeight - gE('cabeza').offsetHeight;
}

function ajustar2() {

	gE('cabeza').style.width = gE('cuerpo').style.width;
	gE('pie').style.width = gE('cuerpo').style.width;	
}

// Calcula la altura de una pagina
function altura() {
	if (ie || op)
		return document.body.clientHeight;	
	else
		return self.innerHeight;
}

// Script y conjunto de funciones
// para el cálculo de la velocidad de conexión y plugins

function setCookie(name, value, expire ){
     document.cookie = name + "=" + escape(value) + ((expire==null ? "":(";expires=" + expire.toGMTString())));
     //alert('A browser cookie has been set with value: '+value);

}

function getExpireDate(){
    var expires = new Date();
    expires.setTime((new Date().getTime()) + 1000*60*60*24*365);
    return expires;
}

function setPlayerString(p){
     playerString=p;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

var formularioOK = 1;

function numeric(objeto, valor, texto)
{
	if (formularioOK == 1) {
		if (valor.length > 0) {
			valornum = parseInt(valor,10); 
			if (isNaN(valornum) || valornum != valor)   //el método "isNaN" comprueba si el valor No es un número
			{
				alert (texto);
				objeto.focus();    //nos coloca en el campo edad para escribir
				formularioOK = 0;
				return false;
			}
			else
				return true;
		}
	}
}

function vacio(objeto, texto)
{
	if (formularioOK == 1) {
		if (objeto.value == "") //comprueba si el campo nombre esta vacío
		{
			alert (texto);
			objeto.focus();   //posicionarse en el campo vacío
			formularioOK = 0;
			return false;
		}
		else
			return true;
	}
}

function nacim(objeto, valor, texto) {

	if (formularioOK == 1) {
		dma=valor.split("/");
		if (dma.length != 3) {
			alert(texto);
			objeto.focus();
			formularioOK = 0;
			return false;			
		}
		else {
			dia=parseInt(dma[0],10);
			mes=parseInt(dma[1],10);
			ano=parseInt(dma[2],10);
		}
 		if (isNaN(dia) || dia != dma[0] || isNaN(mes) || mes != dma[1] || isNaN(ano) || ano != dma[2]) {
			alert(texto);
			objeto.focus();
			formularioOK = 0;
			return false; 			
		}
		if (dia > 31 || dia < 1 || mes < 1 || mes > 12 || ano < 1000 || ano > 9999) {
			alert(texto);
			objeto.focus();
			formularioOK = 0;
			return false;			
		}
	}
}

function maxsize(objeto, valor, texto, size) {

	if (formularioOK == 1) {
		if (valor.length > size) {
			alert (texto);
			objeto.focus();
			formularioOK = 0;
			return false;		
		}
	}
}

extArray = new Array(".doc", ".pdf", ".gif", ".jpg",".png",".jpeg");


function limitAttach(objeto, file, texto) {

	if (formularioOK == 1) {
		allowSubmit = false;
		if (!file) return;
		while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")).toLowerCase();
		for (var i = 0; i < extArray.length; i++) {
			if (extArray[i] == ext) { 
				allowSubmit = true; 
				break; 
			}
		}
		if (allowSubmit) {}
		else {
			alert (texto);
			objeto.focus();
			formularioOK = 0;
			return false;
		}
	}
}

function cambiar_color(campo,color){ 
   campo.style.backgroundColor=color;
}

//!-->
