
document.write('<script type="text/javascript" src="lib/zplayer.js"></script>');
document.write('<script type="text/javascript" src="lib/zplayerClass.js"></script>');
document.write('<script type="text/javascript" src="lib/zplayerRules.js"></script>');
document.write('<script type="text/javascript" src="lib/zplayerWMUtil.js"></script>');

var ZplayerLib = {
  Version: '1.0.0',
  require: function(libraryName) {
  	// alert(libraryName)
    // inserting via DOM fails in Safari 2.0, so brute force approach
    document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
  },
  load: function() {
    if((typeof Prototype=='undefined') || 
       (typeof Element == 'undefined') || 
       (typeof Element.Methods=='undefined') ||
       parseFloat(Prototype.Version.split(".")[0] + "." +
                  Prototype.Version.split(".")[1]) < 1.5)
       throw("script.aculo.us requires the Prototype JavaScript framework >= 1.5.0");
    
    $A(document.getElementsByTagName("script")).findAll( function(s) {
      return (s.src && s.src.match(/core\.js(\?.*)?$/))
    }).each( function(s) {
      var path = s.src.replace(/core\.js(\?.*)?$/,'');
      var includes = s.src.match(/\?.*load=([A-Z,a-z,\/]*)/);
      (includes ? includes[1] : 'zplayer').split(',').each(
       function(include) { ZplayerLib.require(path+include+'.js') });
    });
  }
}

//ZplayerLib.load();

userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
var data_hoje = new Date();
var dia_semana = data_hoje.getDay();
			
function checkCookie() {
	setCookie("CookieTest", "OK", 1);
	var v = getCookie("CookieTest");
	setCookie("CookieTest", "");
	return (v == "OK");
}	// checkCookie() end
function getCookie(inName) {
	var search = inName + "="
	if (document.cookie.length > 0) {
		var offset = document.cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			var end = document.cookie.indexOf(";", offset);
			if (end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
	}
}	// getCookie(inName) end
function setCookie(inName, inVal, inTime, inPeriodInSecond) {
	if (!inPeriodInSecond) inPeriodInSecond = 86400;
	if (!inTime && (document.location.href.indexOf("localhost") > -1 ||
			document.location.href.indexOf("127.0.0.1") > -1)) {
		inTime = 30;			// on IIS localhost non expiring cookies don't seem to work?
		inPeriodInSecond = 60;	// so lets have 30 mins instead
	}
	var expire = "";
	if (inTime) {
		var today = new Date();
		today.setTime(today.getTime() + (inTime * inPeriodInSecond * 1000)); 
		expire = ";expires=" + today.toGMTString();
	}
	document.cookie = inName + "=" + escape(inVal) + expire + ";path=/;";
}	// setCookie(inName, inVal, inDays) end
function GetSessionCookieName() {
	var oStr = "";
	if (window.location.search.match(/player=([^&]*)/i)) {
		oStr = RegExp.$1;
	} else if (window.location.search.indexOf("list=on") > -1 || debugMode) {
		oStr = "list";
	}
	return "nsp2_PSC_" + oStr;
}
function MakeArray(n) {
	this.length = n
	for (var i = 1; i<=n; i++) {
		this[i] = 0
	}
	return this
}
function Trim(inString) {
	var retVal = "";
	var start = 0;
	while ((start < inString.length) && (inString.charAt(start) == ' ')) {
		++start;
	}
	var end = inString.length;
	while ((end > 0) && (inString.charAt(end - 1) == ' ')) {
		--end;
	}
	retVal = inString.substring(start, end);
	return retVal;
}	// Trim(inString) end
function hex(n) {
	var h=parseInt(n).toString(16);
	return h.toUpperCase();
//	return (h.length%2)?"0"+h:h
}
function Truncate(inString, inMaxLen, inPad) {
	if (!inPad) inPad = "...";
	var oString = "";
	if (inString.length > inMaxLen)
		oString = inString.substr(0, inMaxLen - inPad.length) + inPad;
	else
		oString = inString;
	
	return oString;
}
function encode(str) {
	var result = "";
	for (i = 0; i < str.length; i++) {
		if (str.charAt(i) == " ") result += "+";
		else result += str.charAt(i);
	}
	return escape(result);
}
function decode(str) {
 	var result = str.replace(/\+/g, " ");
	return unescape(result);
}
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;
}
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;
}
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];}}
}
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];}
}
function findElement(n,ly) {
	d = document;
	if (browserVers < 4)		return d[n];
	// jb - Netscape 7.1 appears as version 5.0 - bizarre!
	if ((browserVers >= 5) && (d.getElementById)) {initImgID; return(d.getElementById(n))}; 
	var cd = ly ? ly.document : d;
	var elem = cd[n];
	if (!elem && cd.all) elem=cd.all[n];	// added by JB - odd!
	if (!elem && cd.layers) {
		for (var i=0;i<cd.layers.length;i++) {
			elem = findElement(n,cd.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}
function TrocaImg(a,img) {
	b = document.getElementById(a);
	b.src = img;
}		
function EscreveDados(local, val){
	dDiv = document.getElementById(local);
	dDiv.innerHTML = val;
}
function EscreveDados2(local, val){
	dDiv = document.getElementById(local);
	dDiv.innerHTML = dDiv.innerHTML+"<br />"+val;
}
function EscreveLog(local, val){
	if(debugMode){
		dDiv = document.getElementById(local);
		dDiv.innerHTML = dDiv.innerHTML+"<br />"+val;
	}		
}
function reduzTexto(texto,numero) {
	if (texto.length > numero)
		texto = texto.substring(0,numero-2)+"...";
	return texto;
}
function SecondsToMinutes(val){
	minutes = 0; seconds = 0;
	while(val > 60){
		val = val - 60;
		minutes++;
	}
	seconds = Math.floor(val)+"";
	minutes = minutes+"";
	if(minutes.length < 2) minutes = "0"+minutes;
	if(seconds.length < 2) seconds = "0"+seconds;
	return minutes+":"+seconds;
}
var up;
var cmin1,csec1,cmin2,csec2;
function Minutes(data) {
	for(var i=0;i<data.length;i++) if(data.substring(i,i+1)==":") break;
	return(data.substring(0,i)); 
}
function Seconds(data) {
	for(var i=0;i<data.length;i++) if(data.substring(i,i+1)==":") break;
	return(data.substring(i+1,data.length)); 
}
function Display(min,sec) {
	var disp;
	if(min<=9) disp=" 0";
	else disp=" ";
	disp+=min+":";
	if(sec<=9) disp+="0"+sec;
	else disp+=sec;
	return(disp); 
}
CSAg = window.navigator.userAgent; CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10);
function IsIE() { return CSAg.indexOf("MSIE") > 0;}
function setClientSize(inWidth, inHeight) {
	if (this.self != this.top || (typeof debugMode != "undefined" && debugMode)) return;	// not if i'm in a frame
    if (inWidth < 0 || inHeight < 0) {	// fullscreen
		return;
		//inWidth = window.screen.width;
		//inHeight = window.screen.height;
	}
	if (!IsIE()) {
		window.innerWidth = inWidth;
		window.innerHeight = inHeight;
	
	} else {	// is IE and a right pain!
    
		// it is important to resize the window to the
		// wanted values first, even if we won't get them.
		window.resizeTo(inWidth, inHeight);
		window.scrollTo(0,0);
		// create the checkpoint element
		var cp = document.createElement("div");
		cp.style.position = "absolute";
		cp.style.width = "0px";
		cp.style.height = "0px";
		cp.style.right = "0px";
		cp.style.bottom = "0px";
		
		// we can only read it's position after we
		// insert it into the document
		document.body.appendChild(cp);
		
		// here we get the actual client size
		var current_width = cp.offsetLeft;
		var current_height = cp.offsetTop;
		
		// here we find out how much more we need
		// in order to get to the needed inWidth x inHeight size
		// (or in other words, we compute the size of
		// window decorations: border, scroll bars, title)
		var dw = inWidth - current_width;
		var dh = inHeight - current_height;
		
		// and _finally_ we get what we need
		window.resizeBy(dw, dh);
		
		// we can safely delete the checkpoint now
		document.body.removeChild(cp);
		
		// for the curious, return to see how much
		// did IE miss it
		return { missed_width: dw, missed_height: dh };
	} // if IsIE
}
function clickIE4() {
	if (event.button==2){
		alert(mymsg);
		return false;
	}
}
function clickNS4(e) {
	if (e.which==2 || e.which==3){
		alert(mymsg);
		return false;
	}
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}

var Popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 670,
      height: 500,
      name:"_blank",
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"yes",
      scrollbars:"yes",
      resizable:"yes",
      left:"",
      top:"",
      normal:false
    }
    Object.extend(this.options, options || {});

    if (this.options.normal){
        this.options.menubar = "yes";
        this.options.status = "yes";
        this.options.toolbar = "yes";
        this.options.location = "yes";
    }

    this.options.width = this.options.width < screen.availWidth?this.options.width:screen.availWidth;
    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
    if (this.options.top!="")openoptions+=",top="+this.options.top;
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    printWindow = window.open(this.options.url, this.options.name,openoptions );
    return printWindow;
  }
}

/************************
 *  StringBuffer
 ************************/
 function StringBuffer() {
   this.buffer = [];
 }
 StringBuffer.prototype.add = function add(string) {
   this.buffer.push (string);
   return this;
 };
 StringBuffer.prototype.toString = function toString() {
   return this.buffer.join('');
 }; 