﻿var onLoadCode = "";
function addOnLoad(code)
{
    onLoadCode += code + "();";
}

function execOnLoad()
{
    eval(onLoadCode);
}

window.onload = execOnLoad;

function initShadowBox()
{
    Shadowbox.init({});
	if (document.getElementById('mensajes'))
		document.getElementById('mensajes_list').style.display = 'block';
}
function flashPluginDetection()
{
    try
    {
    if (pluginlist.indexOf("Flash") == -1)
    {
        $j("#FlashPlugin").show();
    }
    }catch(e){}
}

addOnLoad("initShadowBox");
addOnLoad("flashPluginDetection");



function RaiseShadowbox(width,height,layer,params)
{
	var elem = document.createElement('a');
	var attr = document.createAttribute('rel');
	attr.value = 'shadowbox;width=' + width + ';height=' + height;

	elem.setAttributeNode(attr);

	var attr3 = document.createAttribute('href');
	attr3.value = '/' + layer;
	if (params != '')
	{
		attr3.value += '?' + params
	}
	elem.setAttributeNode(attr3);
    Shadowbox.init();
	Shadowbox.open(elem);
}

function checkEnterSearch(e, text) {
	if (e && e.which) {
		e = e;
		characterCode = e.which;
	}
	else {
		e = event;
		characterCode = e.keyCode;
	}

	if (characterCode == 13) {
		window.location = '/Search/Search.aspx?Type=Friends&Search=' + text;
	}
	else {
		return true;
	}
}

function showovertabs() {
	document.getElementById("overflowtabs").style.display = "block";
	document.getElementById("flowback").style.display = "block";
}

function showovertabsi() {
	document.getElementById("overflowtabs").style.display = "block";
	document.getElementById("flowback").style.display = "block";
}

function hideovertabs() {
	document.getElementById("overflowtabs").style.display = "none";
	document.getElementById("flowback").style.display = "none";
}

function check(obj, val, re)
{
	if(obj.value == val)
	{
		obj.value = re;
		try{obj.type = 'text';}catch(e){}
	}
}

function checkpass(obj, val, re)
{
	if(obj.value == val)
	{
		obj.value = re;
		try{obj.type = 'password';}catch(e){}
	}
}

function hideAllBut(id, pre)
{
    var c = true;
    var i = 0;
    var d;
    while(c)
    {
        if(i!= id)
        {
            d = document.getElementById(pre + i);
            if(d != null)
            {
                d.style.display = 'none';
            }
            else c = false;
            
        }
        i++;
    }
}


function classAllBut(id, pre, selClass, defClass)
{
    var c = true;
    var i = 0;
    var d;
    while(c)
    {
        d = document.getElementById(pre + i);
        if(d != null)
        {
            if(i == id)d.className = '' + selClass;
            else d.className = defClass;
        }
        else c = false;
        i++;
    }
}

function switchDiv(diva,divb)
{
    document.getElementById(diva).style.display = 'block';
    document.getElementById(divb).style.display = 'none';
}

function emptySwitchDiv(diva, divb)
{
    if(document.getElementById(divb).value == '') switchDiv(diva, divb);
}

function setFocus(diva)
{
    document.getElementById(diva).focus();
}

var currentDay = 0;
var currentMonth = 0;
var toDateDay = 0;
var toDateMonth = 0;
var gdays = [23, 31, 6, 16, 27, 1, 4, 5, 9, 2, 4, 25, 6, 7, 17, 7];
var gmonths = [8, 8, 9, 9, 9, 10, 11, 11, 11, 12, 1, 1, 2, 2, 3, 12];
var gprice = ["Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!", "Ser destacado en Soy tu Súper Star y ¡hasta podrías salir en la pantalla de Nick!"];
var gtheme = ["Nieve", "Pop", "Vampiros", "Plateada", "New York", "Moto Rock", "Angeles", "Bollywood", "Futurística", "Hollywood", "París", "Flower Power", "Venecia", "Safari", "Japón"];
var music = [0, 4, 11, 12, 13, 14, 15, 16, 17, 22, 23, 19, 24, 25, 28];
var gal = 0;
var d = 0;



function initDiff(day, month, daysMonth)
{
    setCurrentDate(day, month);
    gal = getCurrentGala();
    setToDate(gdays[gal], gmonths[gal]);
    d = getDiff(daysMonth);
}

function getCurrentGala()
{
    for(var i = gdays.length - 1; i >= 0; i--)
    {
        if(gmonths[i] < currentMonth) return i + 1;
        else if(gmonths[i] == currentMonth)
        {
            if(gdays[i] <= currentDay) return i + 1;
        }
    }
    return 0;
}


function setCurrentDate(day, month)
{
    currentDay = day;
    currentMonth = month;
}

function setToDate(day, month)
{
    toDateDay = day;
    toDateMonth = month;
}

function getDiff(daysMonth)
{
    var mdiff = toDateMonth - currentMonth;
    var ddiff = toDateDay - currentDay;
    var retd = 0;
    if(mdiff > 0) retd = daysMonth - currentDay + toDateDay; 
    else if(mdiff == 0)
    {
        retd = toDateDay - currentDay;
    }
    return retd;
}

function ShowLastContent()
{
    var LastPhoto;
    var LastVideo;

    if (document.getElementById('LastPhoto') != null)
        LastPhoto = document.getElementById('LastPhoto').value;
    else
        LastPhoto = '0000-00-00T00:00:00.0-03:00';

    if (document.getElementById('LastVideo') != null)
        LastVideo = document.getElementById('LastVideo').value;
    else
        LastVideo = '0000-00-00T00:00:00.0-03:00';

    var FotoFecha = LastPhoto.substring(0,4) + LastPhoto.substring(5,7) + LastPhoto.substring(8,10);
    var FotoHora = LastPhoto.substring(11,13) + LastPhoto.substring(14,16) + LastPhoto.substring(17,19);

    var VideoFecha = LastVideo.substring(0,4) + LastVideo.substring(5,7) + LastVideo.substring(8,10);
    var VideoHora = LastVideo.substring(11,13) + LastVideo.substring(14,16) + LastVideo.substring(17,19);

    if (parseInt(FotoFecha) > parseInt(VideoFecha))
    {
        document.getElementById('UltimaFoto').style.display = 'block';
        document.getElementById('UltimoVideo').style.display = 'none';
        document.getElementById('TabVideo').className = 'Default';
        document.getElementById('TabFoto').className = 'Selected';
    }
    else if (parseInt(VideoFecha) > parseInt(FotoFecha))
    {
        document.getElementById('UltimoVideo').style.display = 'block';
        document.getElementById('UltimaFoto').style.display = 'none';
        document.getElementById('TabFoto').className = 'Default';
        document.getElementById('TabVideo').className = 'Selected';
    }
    else if(parseInt(VideoFecha) == parseInt(FotoFecha))
    {
        if(parseInt(FotoHora) > parseInt(VideoHora))
        {
            document.getElementById('UltimaFoto').style.display = 'block';
            document.getElementById('UltimoVideo').style.display = 'none';
            document.getElementById('TabVideo').className = 'Default';
            document.getElementById('TabFoto').className = 'Selected';
        }
        else
        {
            document.getElementById('UltimoVideo').style.display = 'block';
            document.getElementById('UltimaFoto').style.display = 'none';
            document.getElementById('TabFoto').className = 'Default';
            document.getElementById('TabVideo').className = 'Selected';
        }
    }
}
function tabsActions(Selec)
{
    document.getElementById('TabVideosAccion').className = 'Default';
    document.getElementById('TabFotosAccion').className = 'Default';
    document.getElementById('TabNotasAccion').className = 'Default';
    
    document.getElementById('ActionVideos').style.display = 'none';
    document.getElementById('ActionFotos').style.display = 'none';
    document.getElementById('ActionNotas').style.display = 'none';
    
    document.getElementById('Tab'+Selec+'Accion').className = 'Selected';
    document.getElementById('Action'+Selec).style.display = 'block';
}
function getGala()
{
    return gal;
}

function getGalaMusic()
{
    return music[gal - 1];
}

function getGalaTheme()
{
    return gtheme[gal - 1];
}

function global(key)
{
    return document.getElementById("tr-" + key).value;    
}

function initG(count)
{
    document.getElementById('galaNumber').innerHTML = gal;
    try { 
    if(d > 1) document.getElementById('galaDayDiff').innerHTML = d + " " + global("Days"); 
    else document.getElementById('galaDayDiff').innerHTML = d + " " + global("Day");
    }catch(e){}
    
    document.getElementById('galaPrice').innerHTML = gprice[gal - 1];
    
    /*for(var i = 1; i < count; i++)
    {
        try{ document.getElementById('gala-' + i + '-gala,' + gal).style.display = 'block' } catch(e) {}; 
        try{ document.getElementById('gala-' + i + '-gala,' + gal +',').style.display = 'block' } catch(e) {}; 
        try{ document.getElementById('gala-' + i + '-gala,' + gal +',promostsscolomb').style.display = 'block' } catch(e) {}; 
        
    }*/
}

function ChangeTab(Selec, DesSelec)
{

    document.getElementById(DesSelec).className = 'Default';
    document.getElementById(Selec).className = 'Selected';
    
    if (Selec == 'TabFoto')
    {
        document.getElementById('UltimaFoto').style.display = 'block';
        document.getElementById('UltimoVideo').style.display = 'none';
    }
    else
    {
        document.getElementById('UltimaFoto').style.display = 'none';
        document.getElementById('UltimoVideo').style.display = 'block';
    }
}

function ShowActions()
{
	document.getElementById('MoreAction_1').style.display = 'block';
	document.getElementById('MoreAction_2').style.display = 'block';
	document.getElementById('MoreAction_3').style.display = 'block';
}
