// JavaScript Document

function openPhotoAlbum(albumid)
{
var ourl = '/content/photoalbum4.jhtml?cid=' + albumid;
if(schid!=null && schid==11529)
	window.open(ourl,'photopopup','left=3,top=3,screenx=3,screeny=3,scrollbars=no,width=770,height=600');
else
    window.open(ourl,'photopopup','left=3,top=3,screenx=3,screeny=3,scrollbars=no,width=770,height=585');
}
function openAudioLink(audioid)
{
 var ourl = '/content/audio.jhtml?cid=' + audioid;
  if(schid!=null && schid==11529)
 {
  	ourl = '/content/audio_nfl.jhtml?cid=' + audioid;
	window.open(ourl,'audiopopup','left=20,top=20,screenx=20,screeny=20,scrollbars=no,width=765,height=392');
  }
  else
	window.open(ourl,'audiopopup','left=20,top=20,screenx=20,screeny=20,scrollbars=no,width=770,height=364');
}
function openVideoLink( videoid )
{
    if (schid == null || schid != 11529)
    {
        location.href = '/content/videoplayer.jhtml?cid=' + videoid;
    }
    else
    {
        var child;
        if (child != undefined) {child.close; } 

        var left = 3; 
        var top = 3;
        var width = 750;
        var height = 640;

        var ourl = '/content/video.jhtml?cid=' + videoid;

        if ( navigator.appName.indexOf('Microsoft') != -1 )
        {
            left = window.screenLeft + ( window.document.body.clientWidth/2 - width/2 );
            top =  window.screenTop;
        }
        else
        {
            left = window.screenX + ( window.outerWidth/2 - width/2 );
            top =  0;
        } /* endif */

        child = window.open(ourl,'videopopup','left=' + left + ',top=' + top + ',screenx=' + left + ',screeny=' + top + ',scrollbars=no,width=' + width + ',height=' + height);
    }
}
function goToURL(linkElement)
{
	window.location = document.all[linkElement].href;
}
function goToURL2(linkElement)
{
	top.location = document.all[linkElement].href;
}

function tdOver( Element, linkElement )
{
	document.all[linkElement].style.textDecoration = "underline";
	Element.style.cursor = "pointer";
}
function tdOut( Element,linkElement )
{
	document.all[linkElement].style.textDecoration = "";
	Element.style.cursor = "default";
}
function changeVideoObjectURL(videoName, videoURL)
{
	var video = null;
	if( document.getElementById )
		video = document.getElementById( videoName );
	else
		video = eval( "document." + videoName );
	if( video )
	{
		if( video.Filename )
			video.Filename = videoURL;
		else if( video.src )
			video.src = videoURL;
	} 
}


// news ticker rotation
// Example: newsTicker( 'fe', 5000, '#0468B2', '#2D81BD', '#68A7D4', '#B5D4EB', '#FFF' );

var itemTotal = 0;
var itemCounter = 0;
var currentItem = 0;
var currentColor = 0;
var firstItemInnerHTML = '';
var Params = '';

function rotateW( ulId, timeInterval, c1, c2, c3, c4, c5 )
{
	if (currentItem < itemTotal-1 ) currentItem++;
	else currentItem = 0;
	var x = document.getElementById( ulId );
	var y = x.getElementsByTagName( 'li' );
	if (currentItem == 0) y[ 0 ].innerHTML = firstItemInnerHTML;
	else y[ 0 ].innerHTML = y[ currentItem ].innerHTML;
	cAlpha( 1, ulId, timeInterval, c1, c2, c3, c4, c5 );
}

// alpha fading and out for news ticker
function cAlpha( dir, ulId, timeInterval, c1, c2, c3, c4, c5 )
{
	cArray = new Array ( c1, c2, c3, c4, c5 );
	var x = document.getElementById( ulId );
	var y = x.getElementsByTagName( 'li' );
	var a = y[0].getElementsByTagName( 'a' );
	if ( ( dir == 0 ) && ( currentColor < cArray.length ) )
	{
		a[0].style.color = cArray[ currentColor++ ];
		setTimeout( 'cAlpha( 0, ' + Params + ' );', 75 );
		
	}
	else if ( ( dir == 1 ) && ( currentColor >= 0 ) )
	{
		a[0].style.color = cArray[ currentColor-- ];
		setTimeout( 'cAlpha( 1, ' + Params + ' );' , 75 );
	}
	else
	{
		if (dir == 1){	
			currentColor = 0;
			setTimeout( 'cAlpha( 0, ' + Params + ' );', timeInterval );
		}
		else{
			currentColor = 4;
			rotateW( ulId, timeInterval, c1, c2, c3, c4, c5 );
		}
	}
}

// newsTicler starter
function newsTicker( ulId, timeInterval, c1, c2, c3, c4, c5 ){
	var x2 = document.getElementById( ulId );
	var y2 = x2.getElementsByTagName( 'li' );
	itemTotal = y2.length;
	itemCounter = 0;
	currentItem = 0; 
	firstItemInnerHTML = y2[0].innerHTML;
	Params = '\'' + ulId + '\', ' + timeInterval + ', \'' + c1 + '\', \'' + c2 + '\', \'' + c3 + '\', \'' + c4 + '\', \'' + c5 + '\'';
	setTimeout('cAlpha( 0, ' + Params + ' );', timeInterval );
}

// 2x4 ad tag redering and sync function

/* var sync = '';

 function renderFIAdTag( fiAdtagSrc ){
	var syncParam = '';
	if ( sync != '' ) syncParam = '&SYNC=' + sync;
	fiAdtagSrc = fiAdtagSrc.replace( /&SIZE/i, syncParam + '&SIZE' );
	iframeSrc = fiAdtagSrc.replace( "/js.ng/Params.richmedia=yes&", "/html.ng/" );
	tagCode = '<iframe marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" width="0" height="0" src="' + iframeSrc + '"><scr' + 'ipt type="text/javascr'+ 'ipt" src="' + fiAdtagSrc + '"></scr' + 'ipt></iframe>';
	document.write(tagCode);
}
*/

// chat room login

function sala(x){
	var dom = "http://www.univision.com/content/channel.jhtml?";
	if (x == "mexico")	{location.href = dom + 'schid=13&secid=11400&sala=Mexico';}
	else if (x == "miami")  {location.href = dom + 'chid=9514&schid=11352&secid=11385&sala=Miami';}
	else if (x == "losangeles") {location.href = dom + 'chid=9450&schid=11362&secid=11379&sala=Los_Angeles';}
	else if (x == "albuquerque") {location.href = dom + 'chid=10014&schid=11376&secid=11394&sala=Albuquerque';}
	else if (x == "austin")	{location.href = dom + 'chid=10032&schid=11372&secid=11390&sala=Austin';}
	else if (x == "chicago") {location.href = dom + 'chid=9627&schid=11369&secid=11387&sala=Chicago';}
	else if (x == "dallas")	{location.href = dom + 'chid=9683&schid=11364&secid=11381&sala=Dallas';}
	else if (x == "elpaso")	{location.href = dom + 'chid=10068&schid=11374&secid=11392&sala=El_Paso';}
	else if (x == "fresno") {location.href = dom + 'chid=9542&schid=11367&secid=11384&sala=Fresno';}
	else if (x == "houston"){location.href = dom + 'chid=9655&schid=11363&secid=11380&sala=Houston';}
	else if (x == "lasvegas") {location.href = dom + 'chid=10104&schid=11377&secid=11395&sala=Las_Vegas';}
	else if (x == "mcallen") {location.href = dom + 'chid=10086&schid=11375&secid=11393&sala=McAllen';}
	else if (x == "newyork") {location.href = dom + 'chid=9486&schid=11368&secid=11386&sala=Nueva_York';}
	else if (x == "phoenix") {location.href = dom + 'chid=9466&schid=11371&secid=11389&sala=Phoenix';}
	else if (x == "puertorico") {location.href = dom + 'chid=9466&schid=11371&secid=11389&sala=Phoenix';}
	else if (x == "sacramento") {location.href = dom + 'chid=9570&schid=11366&secid=11383&sala=Sacramento';}
	else if (x == "sanantonio")	{location.href = dom + 'chid=9711&schid=11370&secid=11388&sala=San_Antonio';}
	else if (x == "sandiego") {location.href = dom + 'chid=10050&schid=11373&secid=11391&sala=San_Diego';}
	else if (x == "sanfrancisco") {location.href = dom + 'chid=9598&schid=11365&secid=11382&sala=San_Francisco';}
	else if (x != "AUDITORIO") {location.href = dom + 'schid=13&secid=11400&sala=Amigos';	}
	else {
	url = "http://especiales.univision.com/portada/chat/auditorio.html"; 
	window.open(url,'entrada','width=584,height=460,resizable=yes,left=20,top=5,scrollbars=no,toolbar=no,alwaysRaised=yes');
	}
}

// music preview
function fnPreviewTrack (pid,tid) {
moonwin = window.open( "http://www.univision.com/rdt.dyn?trt=502&rid=10&requrl=http://bajarmusica.univision.com/mediaplayer/buytrackpreview.aspx?pid=" + pid + "&tid=" + tid + "&lang=es", "moonwin", "left=20,top=20,screenx=20,screeny=20,scrollbars=no,width=750,height=250" );
	setTimeout('moonwin.focus();',250);
}

////////////////////////////////////////////////////////////////////////////////

function printArticle(contentID)
{
	window.open( "/content/print.jhtml?cid=" + contentID + "&FilePath=" + globalParams[ "FilePath" ]
					+ "&CommonImagePath=" + globalParams[ "CommonImagePath" ] + "&ImagePath=" + globalParams[ "ImagePath" ],
					"imprimir", "left=20 top=20 screenx=20 screeny=20 scrollbars=yes,width=516,height=400" );
}

////////////////////////////////////////////////////////////////////////////////

function sendToFriend(contentID)
{
	window.open( "/content/enviar_gen.jhtml?cid=" + contentID + "&FilePath=" + globalParams[ "FilePath" ]
					+ "&CommonImagePath=" + globalParams[ "CommonImagePath" ] + "&ImagePath=" + globalParams[ "ImagePath" ],
					"compartelo", "left=20 top=20 screenx=20 screeny=20 scrollbars=no,width=300,height=400" );
}

////////////////////////////////////////////////////////////////////////////////

function writeToEditor(contentID)
{
	window.open( "/content/mess_editor.jhtml?cid=" + contentID + "&ChannelName=" + globalParams[ "ChannelName" ]
					+ "&FilePath=" + globalParams[ "FilePath" ] + "&CommonImagePath=" + globalParams[ "CommonImagePath" ]
					+ "&ImagePath=" + globalParams[ "ImagePath" ], "escribe", "left=20 top=20 screenx=20 screeny=20 scrollbars=no,width=300,height=400" );
}

function getElementsByClassName(oElm, strTagName, oClassNames){
            var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
            var arrReturnElements = new Array();
            var arrRegExpClassNames = new Array();
            if(typeof oClassNames == "object"){
                        for(var i=0; i<oClassNames.length; i++){
                                    arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
                        }
            }
            else{
                        arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
            }
            var oElement;
            var bMatchesAll;
            for(var j=0; j<arrElements.length; j++){
                        oElement = arrElements[j];
                        bMatchesAll = true;
                        for(var k=0; k<arrRegExpClassNames.length; k++){
                                    if(!arrRegExpClassNames[k].test(oElement.className)){
                                                bMatchesAll = false;
                                                break;
                                    }
                        }
                        if(bMatchesAll){
                                    arrReturnElements.push(oElement);
                        }
            }
            return (arrReturnElements)
}
if(typeof Array.prototype.push != "function"){
            Array.prototype.push = ArrayPush;
            function ArrayPush(value){
                        this[this.length] = value;
            }
}


             months = new Array(13);
             months[0] = 'enero';
             months[1] = 'febrero';
             months[2] = 'marzo';
             months[3] = 'abril';
             months[4] = 'mayo';
             months[5] = 'junio';
             months[6] = 'julio';
             months[7] = 'agosto';
             months[8] = 'septiembre';
             months[9] = 'octubre';
             months[10] = 'noviembre';
             months[11] = 'diciembre';
             today = new Date();
             tmonth = months[today.getMonth()];
             tdate = today.getDate();
             tyear = today.getYear();
             if (tyear <= 199) {
             tyear +=1900
             }
             
function setDates() {
            var tdates = getElementsByClassName(document,'*','tdate');
            for (x=0; x<tdates.length; x++) { tdates[x].innerHTML = tdate + ' '; }
            var tmonths = getElementsByClassName(document,'*','tmonth');
            for (y=0; y<tmonths.length; y++) { tmonths[y].innerHTML = tmonth + ' '; }
            var tyears = getElementsByClassName(document,'*','tyear');
            for (z=0; z<tyears.length; z++) { tyears[z].innerHTML = tyear + ' '; }
}




