// JavaScript Document
<!--

/*
  Instrucciones de uso:
  En el script para mostrar flotante escribir:
  
  tiempo_show = segundos para mostrar
  tiempo_cookie = dias
  
  document.write(showFloat('nombre', 'url', 'clickurl', posx, posy, width, height, tiempo_show, tiempo_cookie=7, trans=true));
  
  document.write(showFlash(nombre, flashurl, gifurl, clickurl, w, h, trans=false, targ=_blank, scale=default));

  document.write(showSide(nombre, url, clickurl, w, h, isFlash=false, trans=false, targ=_blank));
    
*/

	var MM_contentVersion = 5;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i) {
			if (isNaN(parseInt(words[i]))) continue;
			var MM_PluginVersion = words[i]; 
	    }
		var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
	} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
		document.write('on error resume next \n');
		document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
		document.write('</SCR' + 'IPT\> \n');
	} 
	
	//clavo en el explorer....  averiguar que pasa
	MM_FlashCanPlay = true;
	
	var hay_float = false;
	var hay_side = false;
	
	function setFloat() {
		hay_float = true;
	}
	
	function hayFloat() {
		return hay_float;
	}

	function setSide() {
		hay_side = true;
	}
	
	function haySide() {
		return hay_side;
	}

    function fixMyDate(date) {
      var base = new Date(0);
      var skew = base.getTime();
      if (skew > 0)
        date.setTime(date.getTime() - skew);
    }
	
  function setMyCookie(name, value, dias, path, domain, secure) {
    // dias = numero de dias

    var now = new Date();
	fixMyDate(now);

	now.setTime(now.getTime() + dias * 24 * 60 * 60 * 1000);
	expires = now;

    var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
    document.cookie = curCookie;
  }
  
  function getMyCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function 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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
	
function MyHide(n) {
  b = findObj(n);
  if (b != null) {
    b.style.visibility = 'hidden';
  }
}

var IE4 = (document.all) ? true : false;
var NS4 = (document.layers) ? true : false;

window.onerror = null;
var windowWidth    = 0;
var imageWidth     = 200;
var leftSpacer     = 750;
var topMargin = 5;
var slideTime = 1200;
var layerID = 'marca';

var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);

function layerObject(id,left) {
	if (ns6) {
		this.obj = document.getElementById(id).style;
		this.obj.left = left;
		return this.obj;
	} else if(ie4) {
		this.obj = document.all[id].style;
		this.obj.left = left;
		return this.obj;
	} else if(ns4) {
		this.obj = document.layers[id];
		this.obj.left = left;
		return this.obj;
   }
}

function layerSetup() {
	floatLyr = new layerObject(layerID, 750);
	window.setInterval("main()", 10)
}

function floatObject() {
	if (ns4 || ns6) {
		findHt = window.innerHeight;
	} else if(ie4) {
		findHt = document.body.clientHeight;
	}
} 

function main() {
	if (ns4) {
		this.currentY = document.layers[layerID].top;
		this.scrollTop = window.pageYOffset;
		mainTrigger();
	} else if(ns6) {
		this.currentY = parseInt(document.getElementById(layerID).style.top);
		this.scrollTop = scrollY;
		mainTrigger();
	} else if(ie4) {
		this.currentY = eval(layerID).style.pixelTop;
		this.scrollTop = document.body.scrollTop;
		mainTrigger();
   }
}

function mainTrigger() {
	var newTargetY = this.scrollTop + this.topMargin;
	if ( this.currentY != newTargetY ) {
		if ( newTargetY != this.targetY ) {
			this.targetY = newTargetY;
			floatStart();
		}
		animator();
	}
}

function floatStart() {
	var now = new Date();
	this.A = this.targetY - this.currentY;
	this.B = Math.PI / ( 2 * this.slideTime );
	this.C = now.getTime();
	if (Math.abs(this.A) > this.findHt) {
		this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
		this.A = this.A > 0 ? this.findHt : -this.findHt;
	} else {
		this.D = this.currentY;
	}
}

function animator() {
	var now = new Date();
	var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
	newY = Math.round(newY);
	if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
		if ( ie4 )eval('document.all.' + layerID).style.pixelTop = newY;
		if ( ns4 )document.layers[layerID].top = newY;
		if ( ns6 )document.getElementById(layerID).style.top = newY + "px";
	}
}

function start() {
	if(ns6||ns4) {
		pageWidth = innerWidth;
		pageHeight = innerHeight;
		layerSetup();
		floatObject();
	} else if(ie4) {
		pageWidth = document.body.clientWidth;
		pageHeight = document.body.clientHeight;
		layerSetup();
		floatObject();
	}
	Fijar_intervalo('showit()', 100);
}

function Fijar_visibilidad(id, flag) {
  if (ns6) {
    var str = (flag) ? 'visible' : 'hidden';
	document.getElementById(id).style.visibility = str;
  } else  if (NS4) {
    var str = (flag) ? 'show' : 'hide';
    eval("document." + id).visibility = str;
  } else if (IE4) {
    var str = (flag) ? 'visible' : 'hidden';
    eval("document.all." + id).style.visibility = str;
  }
}

function GetWindowWidth() {
  if (NS4) {return window.innerWidth}
  else {return document.body.clientWidth}
}

function Fijar_posizquierda(id, xCoord) {
  if (ns6) {
	document.getElementById(id).style.left = xCoord;
  } else  if (NS4) {eval("document." + id).left = xCoord}
  else {eval("document.all." + id).style.left = xCoord}
}

function Fijar_intervalo(command, interval) {
  setInterval(eval('"' + command + '"'), interval);
}

function showit(){
  if (navigator.appVersion.indexOf('Mac') == -1){
    windowWidth = GetWindowWidth();
	if (windowWidth >= imageWidth + leftSpacer ) {
		Fijar_visibilidad(layerID, true);
        Fijar_posizquierda(layerID, leftSpacer);
	} else {
		Fijar_visibilidad(layerID, false);
        Fijar_posizquierda(layerID, 0);
	}
  }
}

	
	function sideBegin(w,h) {
		var ret = '';
		if (haySide()) return ret;
		ret += '<div id="marca" style="position:absolute; left:775; top:5; width:' + w + '; height:' + h + '; z-index:1; visibility: hidden;">';
		ret += '<SCR' + 'IPT LANGUAGE=JavaScript type=text/javascript \n SRC=http://s0b.bluestreak.com/ix.e?jss&amp;wmode=Window&amp;s=1568506&amp;u=&amp;n=Insert_Time_Stamp_Here&amp;cltk=Insert_Click_Track_URL_Here> \n</sc' + 'ript> <noscript> <a href=http://s0b.bluestreak.com/ix.e?hr&amp;s=1568506 target=_top><img src=http://s0b.bluestreak.com/ix.e?ir&amp;s=1568506 border=0> </a></nos' + 'cript>';
       	ret += '</div>';
		setSide();
        ret += '<scr' + 'ipt>\n<!--\n';
		ret += 'start();\n';
		ret += '//-->\n</scr' + 'ipt>\n';
		return ret;
	}
	
    function startSide() {
	    setSide();
		var ret='';
        ret += '<scr' + 'ipt>\n<!--\n';
		ret += 'start();\n';
		ret += '//-->\n</scr' + 'ipt>\n';
		return ret;
	}
	

	function showSide(nombre, url, clickurl, w, h, isFl, transp, targ) {
		var ret = '';
		var isFlash = (isFl != null)? isFl : false;
		var trans = (transp != null)? transp : true;
		var tt = (targ != null)? targ : "_blank";
		if (haySide()) return ret;
        if ( MM_FlashCanPlay ) {
			ret += '<div id="marca" style="position:absolute; left:750; top:5; width:' + w + '; height:' + h + '; z-index:1; visibility: hidden;">';
			if (isFlash) {
            	ret += ('  <object ID="' + nombre + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' + w + '" height="' + h + '">');
            	ret += ('    <param name="movie" value="' + url + '">');
            	ret += ('    <param name=quality value=high>');
            	if (trans) ret += ('    <param name="wmode" value="transparent">');
            	ret += ('    <embed src="' + url + '" width="' + w + '" height="' + h + ' quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" NAME="' + nombre + '" ');
            	if (trans) ret += (' wmode="transparent" ');
            	ret += ('></embed>');
                ret += ('  </object>');
		    } else { // es GIF
	        	ret += ('<a href="' + clickurl + '" target="' + tt + '"><IMG id="' + nombre + '" name="' + nombre);
	        	ret += ('" SRC="' + url + '" WIDTH="' + w + '" HEIGHT="' + h + '" BORDER="0"></a>');
	        } // end-if isFlash
        	ret += '</div>';
			setSide();
        } // end-if flashcanplay
        ret += '<scr' + 'ipt>\n<!--\n';
		ret += 'start();\n';
		ret += '//-->\n</scr' + 'ipt>\n';
		return ret;
	} // end  showSide
	
	function showFlash(nombre, flashurl, gifurl, clickurl, w, h, transp, targ, scale) {
		var trans = (transp != null)? transp : false;
		var tt = (targ != null)? targ : "_blank";
		var ret = '';
        if ( MM_FlashCanPlay ) {
        	ret += ('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" id="' + nombre + '" name="' + nombre + '" WIDTH="' + w + '" HEIGHT="' + h + '" ALIGN="">');
        	ret += (' <PARAM NAME=movie VALUE="' + flashurl + '?clickTAG=' + clickurl + '"> <PARAM NAME=quality VALUE=high>'); 
           	if (trans) ret += ('    <param name="wmode" value="transparent">');
           	if (scale != null) ret += ('    <param name="scale" value="' + scale + '">');
        	ret += (' <EMBED src="' + flashurl + '?clickTAG=' + clickurl + '" quality=high ');
           	if (trans) ret += (' wmode="transparent" ');
           	if (scale != null) ret += (' scale="' + scale + '" ');
        	ret += (' swLiveConnect=FALSE WIDTH="' + w + '" HEIGHT="' + h + '" NAME="' + nombre + '" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
        	ret += (' </EMBED>');
        	ret += (' </OBJECT>');
        } else{
        	ret += ('<a href="' + clickurl + '" target="' + tt + '"><IMG id="' + nombre);
        	ret += ('" name="' + nombre + '" SRC="' + gifurl + '" WIDTH="' + w + '" HEIGHT="' + h + '" BORDER=0></a>');
        }
        return ret;
	} // end  showFlash


	function setsky() {
	    var sky = Math.random()*2;
	    sky = Math.round(sky);
		if(sky<3) {
		  p1="sky1.swf";
		  document.write(showSide('145254', p1, '', 120, 600, true, false, '_blank'));
		} 
	}
	
	function setbanner() {
	    var elbanner = Math.random()*2;
	    elbanner = Math.round(elbanner);
		if(elbanner<3) {
		  p1="banner0.swf";
		  document.write(showFlash('144256', p1, '', '', 468, 60, false, '_blank'));
		} 
	}	


//-->
