﻿function Komment() {
    var TableGraphElement = document.getElementById("grafica");
    if (TableGraphElement != null) {
        TableGraphElement.style.display = "none";
    }
    $find('CommentPopup').show();
}
function Referral() {
    var TableGraphElement = document.getElementById("grafica");
    if (TableGraphElement != null) {
        TableGraphElement.style.display = "none";
    }
    $find('ReferralPopup').show();
}
function LogIn() {
    var TableGraphElement = document.getElementById("grafica");
    if (TableGraphElement != null) {
        TableGraphElement.style.display = "none";
    }
    $find('LoginPopup').show();
}
function Reg() {
    var TableGraphElement = document.getElementById("grafica");
    if (TableGraphElement != null) {
        TableGraphElement.style.display = "none";
    }
    $find('RegPopup').show();
}
function Reg2() {
    var TableGraphElement = document.getElementById("grafica");
    if (TableGraphElement != null) {
        TableGraphElement.style.display = "none";
    }
    $find('MobilePopup').show();
}
function LogOff() {
    var TableGraphElement = document.getElementById("grafica");
    if (TableGraphElement != null) {
        TableGraphElement.style.display = "none";
    }
    $find('LogoutPopup').show();
}
function Klose(Invoker) {
    var TableGraphElement = document.getElementById("grafica");
    if (TableGraphElement != null) {
        TableGraphElement.style.display = "block";
    }
    $find(Invoker).hide();
}
function CerrarLogin(Invoker) {
    var TableGraphElement = document.getElementById("grafica");
    if (TableGraphElement != null) {
        TableGraphElement.style.display = "block";
    }
    parent.window.location="http://www.signumresearch.com/Default.aspx";
    
    //parent.window.location.replace(parent.window.location.href = parent.window.location.href);
}
function CerrarLogOff(Invoker) {
    alert('Gracias por tu visita a Signum Research');
    var TableGraphElement = document.getElementById("grafica");
    if (TableGraphElement != null) {
        TableGraphElement.style.display = "block";
    }
   parent.window.location="http://www.signumresearch.com/Default.aspx";
        //parent.window.location.replace(parent.window.location.href = parent.window.location.href);
}
function Welcome()
{
    parent.window.location = "http://www.signumresearch.com";
}


//Generating Pop-up Print Preview page
function getPrint(print_area) {
    //Creating new page    
    var pp = window.open("location=0,status=0,menubar=0,resizable=1,scrollbars=1,width=960,height=600");
    //Adding HTML opening tag with <HEAD> … </HEAD> portion 
    pp.document.writeln('<HTML><HEAD><title>Print Preview</title>')
    pp.document.writeln('<LINK href="/styles/general.css" type="text/css" rel="stylesheet">')
    pp.document.writeln('<LINK href=PrintStyle.css ' +
                        'type="text/css" rel="stylesheet" media="print">')
    pp.document.writeln('<base target="_self"></HEAD>')

    //Adding Body Tag
    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0"');
    pp.document.writeln(' leftMargin="0" topMargin="0" rightMargin="0">');
    //Adding form Tag
    pp.document.writeln('<form method="post">');

    //Creating two buttons Print and Close within a HTML table
    pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right>');
    pp.document.writeln('<INPUT ID="PRINT" type="button" value="Print" ');
    pp.document.writeln('onclick="javascript:location.reload(true);window.print();">');
    pp.document.writeln('<INPUT ID="CLOSE" type="button" ' +
                        'value="Close" onclick="window.close();">');
    pp.document.writeln('</TD></TR><TR><TD></TD></TR></TABLE>');

    //Writing print area of the calling page
    pp.document.writeln(document.getElementById(print_area).innerHTML);
    //Ending Tag of </form>, </body> and </HTML>
    pp.document.writeln('</form></body></HTML>');
}

function detectEventEnter(val,e,id)
{   
    var key;   
    var keychar;   
  
    if(window.event || !e.which)
    {   
        key = e.keyCode;
    }   
    else if(e)
    {   
        key = e.which;   
    }   
    else  
    {   
        return true;   
    }   
  
    if (key==13)
    {
      replacePege(id);
    }   
}  

//function detectEventEnter()
//{
//    var nombre = navigator.appName
//	if (nombre == "Microsoft Internet Explorer")
//	{ 			
//         var band=false;
//         var b=1;
//         var c=event.keyCode;
//         var str= new String(val);    
//        if (c==13)
//        {
//            replacePege(id);
//        }
//        event.returnValue=band;	
//    }
//    else if (nombre != "Microsoft Internet Explorer")
//	{
//	        tecla = (document.all) ? e.keyCode : e.which;  	
//			if (tecla==13)  
//			{
//    			replacePege(id);
//			}
//        event.returnValue=band;	
//	}	
//}
//function detectEventEnter(val,e,id)
//{   
//    var nombre = navigator.appName
//	if (nombre == "Microsoft Internet Explorer")
//	{ 			
//     var band=false;
//     var b=1;
//     var c=event.keyCode;
//     var str= new String(val);         
//     if(c==13)
//     {
//        replacePege(id);
//     }
//     else
//     {  
//		if((c>=65 && c<=90)||(c>=97 && c<=122)||(c>=48 && c<=57))
//		{
//		    band=true;
//		}               
//		if(c==32)
//		{
//		    band=true;
//		}
//		if(c>159 && c<166 || c == 209 ||c==241)
//		{
//		    band=true;
//		}
//		if (c==8 ||c==241 || c==209 || c==225 || c==233 || c==237 || c==243 || c==250) 
//		{
//		    band=true;
//		}
//		if(c==130)
//		{
//		    band=true;
//		}    
//		event.returnValue=band;	
//     }						
//    }        
//    if (nombre != "Microsoft Internet Explorer")
//	{
//	tecla = (document.all) ? e.keyCode : e.which;  	
//			if (tecla==13)  
//			{replacePege(id);}
//			else
//			{
//				tecla = (document.all) ? e.keyCode : e.which;
//				if (tecla==8 ||tecla==241 || tecla==209 || tecla==225 || tecla==233 || tecla==237 || tecla==243 || tecla==250) return true; 
//				if (tecla==193 || tecla==201 || tecla==205 || tecla==211 || tecla==218) return true; 							  
//				patron =/[\w\s]/; 					
//				te = String.fromCharCode(tecla); 					
//				return patron.test(te);
//			}
//	}	
//}
function replacePege(id) {
    var word;
    var sChar = String.fromCharCode(250);
    var cadena = String(window.location).split("/");
    var cutPage = String(cadena[(cadena.length - 1)]);
    var dateini;
    var datefin;
    try 
    {
        dateini = document.getElementById("dateIni").value;
        datefin = document.getElementById("dateFin").value;
    }
    catch (err) 
    { 
    
    }
    var Page = String(cutPage).split('.');
    var Page1 = Page[0];

    if (id == "1")
        word = document.getElementById("txtSearch").value;
    else if (id == "2") {
        word = document.getElementById("txtSearchnews").value;
        if (dateini != "" && datefin != "")
        { word == dateini; }
    }
    if (word) {
        if (validateUser(word)) 
        {
            if (Page1 == "Default")
            { window.location.replace("Search/SearchSig.aspx?idSearch=" + word); }
            else
                if (Page1 != "Default")
            { window.location.replace("../Search/SearchSig.aspx?idSearch=" + word); }
        }
        else 
        {
            if (dateini != "" && datefin != "") {
                if (id == "2") {
                    word = dateini + "_" + datefin;
                    if (Page1 == "Default")
                    { window.location.replace("Search/SearchSig.aspx?idSearch=" + word); }
                    else
                        if (Page1 != "Default")
                    { window.location.replace("../Search/SearchSig.aspx?idSearch=" + word); }
                }
            }
            else { alert("Selecciona una fecha, palabra clave ...."); }
        }
    } else { alert("Selecciona parametros de b" + sChar + "squeda"); }
}

function ClearTextBox(Id)
{
    var DOMElementContainer = document.getElementById(Id);
    if (DOMElementContainer != null) {
        DOMElementContainer.value="";
    }
}
function InitializeTextBox(Id)
{
    if(Id=='txtSearch')
    {
        var DOMElementContainer = document.getElementById(Id);
        if (DOMElementContainer != null) {
            DOMElementContainer.value="Buscar en Noticias";
        }
    }
    if(Id=='txtAutoCom')
    {
        var DOMElementContainer = document.getElementById(Id);
        if (DOMElementContainer != null) {
            DOMElementContainer.value="Búsqueda por Emisora";
        }
    }
}

function acceso() {
    alert("Para accesar a está página debe estar registrado");
}
        function validateUser(word)
		{
			var valuesError=new Array("BUSCAR","SELECT","DELETE","UPDATE","INSERT","DROP","TABLE","EXEC","EXECUTE","CREATE","'","<",">","/","OR");
			var str = word; 	
			var idx =0;		  
			var strOut = word.toUpperCase(); 	
			
			var chrs = new Array("<",">","|","°","#","$","%","&","/","(",")","=","?","¡","¿","}","{","]","[",",",".",":",";","*","+","\\","-","@","¬"); 
			idx = str.indexOf(chrs);
			if(idx==-1)idx=0;
			for (var i=0; i< chrs.length-1;i++) 
			{
				if (strOut.indexOf(chrs[i]) >= 0) 
				{ 
					idx=strOut.indexOf(chrs[i]);						
					break;			   
				} 
			}
			if(idx==-1)idx=0;
			if(idx == 0)
			{
				for (var j=0;j<valuesError.length -1;j++) 
				{ 
					if (strOut.indexOf(valuesError[j])>= 0) 
					{ 
						idx+=1;	
						break;									   
					} 
				} 	
			}
			if(idx==-1)idx=0;
			if(idx == 0)
				return true; 
			else return false;
        }
