var dyn = (document.all || document.layers || document.getElementById) ? true : false;

var ie = (navigator.appName.indexOf('Microsoft') != -1) ? true : false;
var ie4 = (ie && document.all && !document.getElementById) ? true : false;
var ie5 = (ie && document.getElementById && navigator.userAgent.indexOf('MSIE 6.0') == -1) ? true : false;
var ie6 = (ie && document.getElementById && !ie5) ? true : false;
var ie4Min = (ie4 || ie5 || ie6) ? true : false;
var ie5Min = (ie5 || ie6) ? true : false;
var ie6Min = ie6;

var ns = (navigator.appName.indexOf('Netscape') != -1 || navigator.appName.indexOf('Opera') != -1) ? true : false;
var ns4 = (ns && document.layers) ? true : false;
var ns6 = (ns && document.getElementById) ? true : false;
var ns4Min = (ns4 || ns6) ? true : false;
var ns6Min = ns6;

var comments=new Array()
var comtCount=0;
function commentLoaded(cmt,aut){
	var tempLayerObj = getLayerObj(cmt);
	var aux=tempLayerObj.innerHTML;
	comments[comtCount]=aux.substr(aux.indexOf(">")+1);
	//alert (comments[comtCount]);
	ctt="<a href='javascript:openComment("+'"'+cmt+'"'+","+comtCount+","+'"'+aut+'"'+")'>[+] "+aut+"</a>";
	setLayerHTML(tempLayerObj,ctt);
	comtCount++;
}

function openComment(cmt,ind,aut){
	ctt="<a href='javascript:closeComment("+'"'+cmt+'"'+","+ind+","+'"'+aut+'"'+")'>[-] "+aut+"</a><br /><br />";
	content=ctt+comments[ind];
	var tempLayerObj = getLayerObj(cmt);
	setLayerHTML(tempLayerObj,content);
}

function closeComment(cmt,ind,aut){
	ctt="<a href='javascript:openComment("+'"'+cmt+'"'+","+ind+","+'"'+aut+'"'+")'>[+] "+aut+"</a>";
	var tempLayerObj = getLayerObj(cmt);
	setLayerHTML(tempLayerObj,ctt);
}

function setContent(video){
	var kindOfVideo = video.substring(0,2);
	var videoID = video.substring(2);
	if (kindOfVideo=="YT"){
		var contenido = '<p><embed type="application/x-shockwave-flash" src="http://www.youtube.com/v/'+videoID+'&hl=es&fs=0;&showsearch=0;&showinfo=0;&loop=1;color1=dca84c&amp;color2=dca84c&amp" allowscriptaccess="never" allowfullscreen="false" width="456" height="342"></embed></p>';
	} else {
		var contenido = '<p><object width="456" height="342"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+video+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=dca84c&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+video+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=dca84c&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="456" height="342"></embed></object></p>';
	}	var tempLayerObj = getLayerObj("movie");
	setLayerHTML(tempLayerObj,contenido);
}

function setLayerHTML(LAYEROBJ,STR) {
   if (navigator.userAgent.indexOf('MSIE 5.0') && navigator.userAgent.indexOf('Mac') != -1) STR += '\n';
   if (ns4) {
      LAYEROBJ.document.open();
      LAYEROBJ.document.write(STR);
      LAYEROBJ.document.close();
      }
   else if (dyn) {
	   LAYEROBJ.innerHTML = STR;
   }
}

function getLayerObj(LAYERID) {
   if (ie4) return document.all[LAYERID];
   else if (ns4) {
      var tempLayerObj = null;
      var tempParentObj = (arguments.length == 1) ? document : arguments[1];
      for (var tempLayerLoop in tempParentObj.layers) {
         var tempObj = tempParentObj.layers[tempLayerLoop];
         var tempConstructor = tempObj.constructor + '';
         if (tempConstructor.indexOf('function Layer()') != -1) {
            if (tempLayerLoop == LAYERID) return tempObj;
            else if (tempObj.document.layers.length > 0) tempLayerObj = getLayerObj(LAYERID,tempObj);
            }
         }
      return tempLayerObj;
      }
   else if (dyn) return document.getElementById(LAYERID);
   }
      
   
function destacamos() {
	document.getElementById('DestacamosTab').className = 'SelectedTab';
	document.getElementById('EntrandoTab').className = 'Tab';

	document.getElementById('Destacamos').style.display= 'block';
	document.getElementById('Entrando').style.display = 'none';
}

function entrando() {
	document.getElementById('DestacamosTab').className = 'Tab';
	document.getElementById('EntrandoTab').className = 'SelectedTab';
	
	document.getElementById('Destacamos').style.display = 'none';	
	document.getElementById('Entrando').style.display = 'block';
		
}  

function addDestacamos (vid,img,legenda,link){
	layer=getLayerObj("destacamosIcons");
	cod=layer.innerHTML;
	icon='<div class="vidDest"><a href="javascript:setDestacamosContent('+"'"+vid+"'"+','+"'"+legenda+"'"+','+"'"+link+"'"+')"><img src="http://www.vidbook.tv/wp-content/frames/'+img+'"></a><br />'+legenda+'</div>';
	cod=cod+icon;
	setLayerHTML(layer,cod);	
} 

function setDestacamosContent(video,pnome,plink){
	var kindOfVideo = video.substring(0,2);
	var videoID = video.substring(2);
	if (kindOfVideo=="YT"){
		var contenido = '<embed type="application/x-shockwave-flash" src="http://www.youtube.com/v/'+videoID+'&hl=es&fs=0;&showsearch=0;&showinfo=0;&loop=1;color1=dca84c&amp;color2=dca84c&amp" allowscriptaccess="never" allowfullscreen="false" width="456" height="342"></embed>';
	} else {
		var contenido = '<object width="456" height="342"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+video+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=dca84c&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+video+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=dca84c&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="456" height="342"></embed></object>';
	}
	var tempLayerObj = getLayerObj("movDestacamos");
	setLayerHTML(tempLayerObj,contenido);
	setLinkDestacamos(pnome,plink);
}

function addEntrando (vid,img,legenda,link){
	layer=getLayerObj("entrandoIcons");
	cod=layer.innerHTML;
	icon='<div class="vidDest"><a href="javascript:setEntrandoContent('+"'"+vid+"'"+','+"'"+legenda+"'"+','+"'"+link+"'"+')"><img src="http://www.vidbook.tv/wp-content/frames/'+img+'"></a><br />'+legenda+'</div>';
	cod=cod+icon;
	setLayerHTML(layer,cod);	
} 

function setEntrandoContent(video,pnome,plink){
	var kindOfVideo = video.substring(0,2);
	var videoID = video.substring(2);
	if (kindOfVideo=="YT"){
		var contenido = '<embed type="application/x-shockwave-flash" src="http://www.youtube.com/v/'+videoID+'&hl=es&fs=0;&showsearch=0;&showinfo=0;&loop=1;color1=dca84c&amp;color2=dca84c&amp" allowscriptaccess="never" allowfullscreen="false" width="456" height="342"></embed>';
	} else {
		var contenido = '<object width="456" height="342"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+video+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=dca84c&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+video+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=dca84c&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="456" height="342"></embed></object>';
	}	var tempLayerObj = getLayerObj("movEntrando");
	setLayerHTML(tempLayerObj,contenido);
	setLinkEntramos(pnome,plink);
}

function setLinkDestacamos(nome,link) {
	var contenido = '<a href="http://www.vidbook.tv/'+link+'">Ir a la página de '+nome+'</a>';
	var tempLayerObj = getLayerObj("linkDestacamos");
	setLayerHTML(tempLayerObj,contenido);
}

function setLinkEntramos(nome,link) {
	var contenido = '<a href="http://www.vidbook.tv/'+link+'">Ir a la página de '+nome+'</a>';
	var tempLayerObj = getLayerObj("linkEntrando");
	setLayerHTML(tempLayerObj,contenido);
}

function setCookie(yy,mm){
	//alert (yy+"  "+mm);
	var date = new Date();
	date.setTime(date.getTime()+(50*60*60*1024));
	var expires = "; expires="+date.toGMTString();
	var cName="vlv"
	var cValue=(yy+","+mm).toString();
	document.cookie = cName+"="+cValue+expires+"; path=/";	
}

function resetCookie(ck){
	var date = new Date();
	date.setTime(date.getTime());
	var expires = "; expires="+date.toGMTString();
	var cName=ck
	var cValue="".toString();
	document.cookie = cName+"="+cValue+expires+"; path=/";
}




