/*
function $(idObject){
    return document.getElementById(idObject);
  }
*/
function getCookie(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 trim(valor){
	var re = /^(\s)*|(\s)*$/;
	var str = (valor ? valor : this);
	return str.replace(re,'');
}
String.prototype.trim = trim;

function checkLetras(){
  document.getElementById('texto').value = document.getElementById('texto').value.trim();
  if (document.getElementById('texto').value.length < 3) {
  	alert("Ingrese por favor al menos 3 letras.");
    return false;
  }
  return true;
}

function RadioPopenVivo() {
  if (navigator.appName.indexOf("Microsoft")!=-1) {
  	window.open("../herramientas/radiopopenvivo.php","radiopopenvivo","width=320,height=335,top=50,left=50");
  }
  else {
  	window.location = "http://pop.telecomdatacenter.com.ar/pop";
  }
}

function RadioVale() {
  window.open("radiovaleenvivo.php","radiovaleenvivo","width=320,height=335,top=50,left=50");

}

function noticiasfotoPopUp(idxNota, idxSeccion, opcion, layout) {
    window.location = '../interior/fotos.php?idxNota=' + idxNota + '&idxSeccion=' + idxSeccion + '&opcion=' + opcion + '&layout=' + layout;
}


function runSWF(archivo, ancho, alto, version, bgcolor, id,idm, menu, FlashVars, quality, allowScriptAccess , wmode)
{
	if(version!=""){
		var version_data=version;
	}else{
		var version_data="6,0,0,0";
	}
	if(menu!=""){
		menu_data=menu;
	}else{
		menu_data=false;
	}
	if(bgcolor!=""){
		var bgcolor_data=bgcolor;
	}else{
		var bgcolor_data="#FFFFFF";
	}
	if(id!=""){
		id_data=id;
	}else{
		id_data="flashMovie";
	}
	if(quality!=""){
		quality_data=quality;
	}else{
		quality_data="high";
	}
	if(allowScriptAccess!=""){
		allowScriptAccess_data=allowScriptAccess;
	}else{
		allowScriptAccess_data="always";
	}
	var quality="high"; // calidad de visualización de la peli
	
	if(typeof(wmode)!="undefined"){
		wmode_data=wmode;
	}else{
		wmode_data="transparent";
	}

	var agt=navigator.userAgent.toLowerCase();
	
	if((navigator.appName == "Microsoft Internet Explorer") || ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1)))
	{
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version_data+'" width='+ancho+' height='+alto+' id='+id_data+'>\n');
		document.write('<param name="movie" value='+archivo+'>\n');
		document.write('<param name="allowScriptAccess" value='+allowScriptAccess_data+'>\n');
		document.write('<param name="quality" value='+quality_data+'>\n');
		document.write('<param name="wmode" value='+wmode_data+'>\n');
		//document.write('<param name="FlashVars" value='+FlashVars+'>\n');
		document.write('<param name="bgcolor" value='+bgcolor_data+'>\n');
		//document.write('<param name="menu" value='+menu_data+' >\n');
		document.write('<param name="allowFullScreen" value=true >\n');
		//FlashVars='+FlashVars+' menu='+menu_data+' swLiveConnect=true
		document.write('</object>\n');
	}
	else
	{
		document.write('<embed src='+archivo+' bgcolor='+bgcolor_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' id='+idm+' wmode='+wmode_data+' allowFullScreen=true></embed>');
	}
}

function Votar(idx,cantidad) {
	var check = false;
	for (i=0;i<cantidad;i++) {
		if (document.frmPrincipal.rEncuesta[i].checked) {
			window.open("../herramientas/check_cookies.php?IdxEncuesta="+idx+"&IdxOpcion="+document.frmPrincipal.rEncuesta[i].value,"Votar","width=387,height=290,top=150,left=150");
			var check = true;
		}
	}
	if( check == false ) alert('Para votar debe seleccionar una opción');
}

function isMSIE()
{
	return (navigator.appName == "Microsoft Internet Explorer");
}

function isSafari()
{
	var agt=navigator.userAgent.toLowerCase();
	return ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;;
}

function IframeSetReloj(){
  document.write("<iframe style='display:none' src='../interior/setdatareloj.php'></iframe>");
}


function muestraPopUp(sUrl,overflow,showElement,zIndexElement)
{
	var overflow        = overflow      || "hidden" ;
	var showElement     = showElement   || "" ;
	var zIndexElement   = zIndexElement || 99999999;
	var objDivBackground;
	var objDivContenedor;
	var objIframe;
	var appendBackground  = false;
	var appendContenedor  = false;
	var appendIframe      = false;

	if( ! (objDivBackground = document.getElementById('divBackground')) ){
		objDivBackground	  = document.createElement('DIV');
		appendBackground = true;
	}
	  
	objDivBackground.name 								 = "divBackground";
	objDivBackground.id 									 = "divBackground";
	objDivBackground.style.top 						 = "0px";
	objDivBackground.style.left 					 = "0px";
	objDivBackground.style.position 			 = "absolute";
	objDivBackground.style.backgroundColor = "#000000";
	objDivBackground.style.background 		 = "#000000"
	objDivBackground.style.filter 				 = "alpha (opacity=60);";
	objDivBackground.style.MozOpacity 		 = ".6";
	objDivBackground.style.Opacity 		     = ".6";
	objDivBackground.style.width 					 = "100%";
	/* [EKA] 17/03/2009 07:38:03 p.m. */
	objDivBackground.style.width 					 = document.body.offsetWidth+'px';
	/* [EKA] 17/03/2009 07:38:03 p.m. */
	objDivBackground.style.height 				 = document.body.offsetHeight+'px';
	objDivBackground.style.display         = "block";


	sUrl = sUrl.trim();
  if(sUrl.trim()){
	  if( !(objDivContenedor = document.getElementById('DivContenedor')) ){
      objDivContenedor 	= document.createElement('DIV');
      appendContenedor  = true;
	  }

    objDivContenedor.className 						 = "DivContenedor";
    objDivContenedor.id 									 = "DivContenedor";
    objDivContenedor.name 								 = "DivContenedor";
    objDivContenedor.style.backgroundColor = "#FFFFFF";
    objDivContenedor.style.border 				 = "0px none";
    objDivContenedor.style.top	 					 = "80px";
    objDivContenedor.style.left 					 = "350px";
    /* [EKA] 18/03/2009 */
    /*objDivContenedor.style.position 			 = "fixed";*/
    /*objDivContenedor.style.position 			 = "absolute";*/
    /* [EKA] 18/03/2009 */
    objDivContenedor.style.width 					 = "520px";
    objDivContenedor.style.height 				 = "615px";
    objDivContenedor.style.overflow 			 = "hidden";
    objDivContenedor.style.display         = 'block';

    if( !(objIframe = document.getElementById('iFrameContenedor')) ){
      objIframe = document.createElement('IFRAME');
      appendIframe = true;
    }

  	objIframe.name 						= "iFrameContenedor";
  	objIframe.id	 						= "iFrameContenedor";
  	objIframe.src 						= sUrl
  	objIframe.width 					= "100%";
  	objIframe.height					= "100%";
  	objIframe.frameBorder 		= "none";
  	objIframe.overflow 				= overflow;
  	objIframe.style.overflow 	= overflow;
  	objIframe.style.display   = 'block';
  }

  if(appendBackground){
	  document.body.appendChild(objDivBackground);
	}


	if(sUrl && appendContenedor){
	  document.body.appendChild(objDivContenedor);
	}

	if(sUrl && appendIframe){
	  document.getElementById('DivContenedor').appendChild(objIframe);
	}

	if(!sUrl && showElement){
	  document.getElementById(showElement).style.display = "block";
	  document.getElementById(showElement).style.zIndex  = zIndexElement;
	}
  //block();
	window.scrollBy(0,-1000);
}



function resizePopUp(width,height) {
  if(width > 420){
    document.getElementById('DivContenedor').style.left = 280+"px";
  }
  else{
    document.getElementById('DivContenedor').style.left = 380+"px";
  }
	window.document.getElementById('DivContenedor').style.width = width+"px";
	window.document.getElementById('DivContenedor').style.height = height+"px";
}

function ocultaPopUp() {
	if(document.getElementById('divBackground')   ) { document.getElementById('divBackground').style.display = 'none';    }
	if(document.getElementById('DivContenedor')   ) { document.getElementById('DivContenedor').style.display = 'none';    }
	if(document.getElementById('iFrameContenedor')) { document.getElementById('iFrameContenedor').style.display = 'none'; }
	//unblock();
}


function ingresasPOP( url  , url_redirectto  )
{
  url_redirectto = (typeof(url_redirectto) != "undefined")  ? url_redirectto : "" ;
  muestraPopUp("../interior/login_pop.php?returnto=" + url + "&redirectto=" + url_redirectto);
}

function checkCaracteres( inputElement, cantidad ) {
	if( inputElement.value.length > cantidad ) {
		inputElement.value = inputElement.value.substr(0, cantidad);
	}
	document.frmPrincipal.lcomentario.value = inputElement.value.length;
}

function ingresasPOPComentario( url ){
	muestraPopUp("../interior/login_pop.php?submitTo=" + url);
}

function NombreUsuario(){
	return getCookie("Login[user]");
}


function checkCaracteres( inputElement, cantidad ) {
	if( inputElement.value.length > cantidad ) {
		inputElement.value = inputElement.value.substr(0, cantidad);
	}
	//document.frmPrincipal.lcomentario.value = inputElement.value.length;
}
