﻿// JScript File
function LoadDisplayInformation()
{    
    try
    {
        var eDiv = document.getElementById('divPageAttributes');
        eDiv.style.width=screen.availWidth-100;
        eDiv.style.height=screen.availHeight-120;
    }
    catch(ex)
    {
      alert(ex);
    }
    return true;
}



function NaviagatePages(eurl)
{    

    if(eurl.length>0)
    {
        if(eurl.toLowerCase().indexOf('login')>=0)
        {
            if(document.getElementById('mobilenumber')!=null)
            {
                var eNo=document.getElementById('mobilenumber').value;
                if (eNo.toLowerCase()=='login')
                {
                    alert("Please Enter Valid Number");
                    return false;
                }

                if(!IsValidNumber(document.getElementById('mobilenumber').value))
                {
                    alert("Please Enter Valid Mobile Number");
                    return false;
                }
                eurl="Login.aspx?type=login&no="+document.getElementById('mobilenumber').value;
            }
            else
                eurl="Login.aspx?type=login";
                location.href= eurl;
            }
            else if(eurl.toLowerCase().indexOf('searchresults')>=0)
            {
                if(document.getElementById('searchtextbox')!=null)
                {
                    var eNo=document.getElementById('searchtextbox').value;
                    if (eNo.toLowerCase()=='search')
                    {
                        alert("Please Enter Valid Search text")          ;
                        return false;
                    }

                    eurl='default.aspx?pageid=searchresults&searchtext='+eNo;

                }
                else   
                {
                    alert("Please Enter Valid Search text")                ;
                    return false;
                }
                    location.href= eurl;
            }
            else if(eurl.toLowerCase().indexOf('genresearch')>=0)
            {
                if(document.getElementById('txtGenre')!=null)
                {
                    var eNo=document.getElementById('txtGenre').value;
                    if (eNo.length<=3)
                    {
                    alert("Search Text Should be greater than 3 Characters");
                    return false;
                    }

                   eurl='default.aspx?pageid=searchresults&searchtype=genresearch&cattype=g&searchtext='+eNo;                    
                }
                else
                {
                    alert("Please Enter Valid Search text")                ;
                    return false;
                }
                 location.href= eurl;
            }
            else if(eurl.toLowerCase().indexOf('publishersearch')>=0)
            {
                if(document.getElementById('txtPulisher')!=null)
                {
                    var eNo=document.getElementById('txtPulisher').value;
                        if (eNo.length<=3)
                        {
                        alert("Search Text Should be greater than 3 Characters");
                        return false;
                        }

                    eurl='default.aspx?pageid=searchresults&searchtype=publishersearch&cattype=g&searchtext='+eNo;                    
                }
                else
                {
                    alert("Please Enter Valid Search text")                ;
                    return false;
                }
                location.href= eurl;
           }
          else if(eurl.toLowerCase().indexOf('pricesearch')>=0)
          {
                if(document.getElementById('txtPrice')!=null)
                {
                   var eNo=document.getElementById('txtPrice').value;

                    if (eNo.length<2)
                    {
                        alert("Search Text Should not be  Empty");
                        return false;
                    }

                eurl='default.aspx?pageid=searchresults&searchtype=pricesearch&cattype=g&searchtext='+eNo;                    
           }
           else
           {
                alert("Please Enter Valid Search text");
                return false
           }
           location.href= eurl;
         }
         else
             location.href= eurl;

    }
}
//old for Menu Navigation
function OLDOnNavigateMenus(divInline,divIds)
{                

var eids = divIds.split(',');
var esel_style='';
var esel_css='';
var enew_style='';
var enew_css='';

    for(var i=0;i<eids.length;i++)
    {
        if(eids[i].length>3)
        {
            var ediv = document.getElementById('div_'+eids[i]);
                if(ediv!=null)        
                {
                    if(document.getElementById(eids[i]).style.display=='block')
                    {             

                      esel_style=ediv.getAttribute("style",true);
                      esel_css=ediv.getAttribute("refclass",true);
                    }
                    else
                    {                                
                      enew_style=ediv.getAttribute("style",true);
                      enew_css=ediv.getAttribute("refclass",true);
                    }
                }
                     
        } 
        for(var i=0;i<eids.length;i++)
        {
            if(eids[i].length>3)
            {

            var ediv = document.getElementById(eids[i]);
                if(ediv!=null)
                {                                
                ediv.style.display='none';

                }    
            }
        }       

        for(var i=0;i<eids.length;i++)
        {
            if(eids[i].length>3)
            {                   
                 var ediv = document.getElementById('div_'+eids[i]);  
                if(ediv!=null)
                {                                                                        
                ediv.setAttribute("style",enew_style,true);                         
                ediv.setAttribute("class",enew_css,true);     
                ediv.setAttribute("refclass",enew_css,true);                                                                
                }
            }
        } 

        var divsel= document.getElementById('div_'+divInline);
        if(divsel!=null)
        {         
            divsel.setAttribute("style",esel_style,true);                         
            divsel.setAttribute("class",esel_css,true);   
            divsel.setAttribute("refclass",esel_css,true);  
        }   
        var divDis= document.getElementById(divInline);
        if(divDis!=null)
        {         
            divDis.style.display='block';
        }      
        var hidItm = document.getElementById('hidDivItems');
        if(hidItm!=null)
        {
           
        hidItm.value = divInline ;  
        }
    }  
}


function OnNavigateMenus(divInline,divIds)
{                

    var eids = divIds.split(',');
    var esel_style='';
    var esel_css='';
    var enew_style='';
    var enew_css='';
    var ePrevStyle='';
    for(var i=0;i<eids.length;i++)
    {
        if(eids[i].length>3)
        {
         var ediv = document.getElementById('div_'+eids[i]);
            if(ediv!=null)        
            {
                if(document.getElementById(eids[i]).style.display=='block')
                {             
                    ePrevStyle=ediv;
                    esel_style=ediv.getAttribute("style",true);
                    esel_css=ediv.getAttribute("refclass",true);
                }
                else
                {                                
                    enew_style=ediv.getAttribute("style",true);
                    enew_css=ediv.getAttribute("refclass",true);
                }
            }
        }         
    } 
    for(var i=0;i<eids.length;i++)
    {
        if(eids[i].length>3)
        {          
          $("#"+eids[i]).hide();
        }
    }                   
     
    if(ePrevStyle!=null)
    {

        ePrevStyle.setAttribute("style",enew_style,true);                         
        ePrevStyle.setAttribute("class",enew_css,true);     
        ePrevStyle.setAttribute("className",enew_css,true);     
        ePrevStyle.setAttribute("refclass",enew_css,true);    
    }    
    var divsel= document.getElementById('div_'+divInline);
    if(divsel!=null)
    {         
        divsel.setAttribute("style",esel_style,true);                         
        divsel.setAttribute("class",esel_css,true);   
        divsel.setAttribute("className",esel_css,true);   
        divsel.setAttribute("refclass",esel_css,true);  
    }  

    $("#"+divInline).fadeIn();    
    var hidItm = document.getElementById('hidDivItems');
    if(hidItm!=null)
    {
         hidItm.value = divInline ;  
    }
 
}    

function OnMenuOver(did)
{
    if(document.getElementById(did)!=null)
    {
        document.getElementById(did).style.display='inline';
    }
}

function OnMenuOut(did)
{
    if(document.getElementById(did)!=null)
    {
     document.getElementById(did).style.display='none';
    }
}

function OnSearchCommand(tid,e)
{

    var code=e.keyCode? e.keyCode : e.charCode;
    if(code==13)
    {                

         var etext=document.getElementById(tid);
        if(etext!=null && etext.value.length>2)
        {
             var etexttype=etext.getAttribute('ref',true);
            if(etexttype!=null)
            {
                 var cattype= getParameter('cattype');
                if(cattype==null || cattype=="null")
                cattype='s';
                 var eURL='';
                switch(etexttype.toLowerCase())
                {
                    case 'search':
                        eURL='default.aspx?pageid=searchresults&searchtext='+etext.value;
                        //alert("Under Construction");
                        location.href= eURL;
                    break;
                    case 'login':
                        if(!IsValidNumber(etext.value))
                        {
                            alert("Please Enter Valid Mobile Number");
                            return false;
                        }
                        eURL="Login.aspx?type=login&no="+etext.value;
                        location.href= eURL;
                    break;
                }
            }
        }
        else
        {
            alert("Please Enter Valid Value");
        }
    }
}
function onClickTextBox(tid)
{
        var etext=document.getElementById(tid);
        if(etext!=null && etext.value.length>2)
        {
            var etexttype=etext.getAttribute('ref',true);
            if(etexttype!=null)
            {
                var cattype= getParameter('cattype');
                if(cattype==null || cattype=="null")
                cattype='s';
                var eURL='';
                switch(etexttype.toLowerCase())
                {
                    case 'search':
                        eURL='default.aspx?pageid=searchresults&searchtext='+etext.value;        
                        location.href= eURL;
                    break;
                    case 'login':
                        if(!IsValidNumber(etext.value))
                        {
                            alert("Please Enter Valid Mobile Number");
                            return false;
                        }
                        if(etext.value.length>7)
                        {
                            eURL="Login.aspx?type=login&no="+etext.value;
                            location.href= eURL;
                        }
                    break;
                }
            }
        }
}

function getParameter ( parameterName )
{         
    try
    {
        parameterName=parameterName.toLowerCase();

        var queryString = window.top.location.search.substring(1);
        queryString=queryString.toLowerCase();
        var parameterName = parameterName + "=";
        if ( queryString.length > 0 )
        {           
            begin = queryString.indexOf ( parameterName );            
            if ( begin != -1 )
            {            
                begin += parameterName.length;            
                end = queryString.indexOf ( "&" , begin );
                if ( end == -1 )
                {
                    end = queryString.length
                }        
                     return unescape( queryString.substring ( begin, end ) );
            }        
             return "null";
        }
    }
    catch(e)
    {
    }
    return '';
} 


function ToggleDiv(evt)
{

    var brtype=navigator.appName
    var divInner=null;
    var isvalid=1;
    divInner = document.getElementById(evt);       
    isvalid=0;
    var disValue=divInner.style.display;    
    if(navigator.userAgent.indexOf('Firefox')>=0 && disValue=='none')
    disValue='inline-block';     
    switch(disValue)
    {
        case "none":
            divInner.style.display = 'inline';			    
        break;
        case "inline":	
             divInner.style.display = 'none';

        break;
        case "inline-block":
              divInner.style.display = '-moz-inline-box';
        break;
        default:
             divInner.style.display = 'none';                
        break;

    }  
}


var Svalues="White,,images/Musicheading.gif,,arial,1,White,#2b2b2b,,,,1,150,,1,gray,5,24,0.5,,2,000000,,,,";			
var TipId="tipplayer";
var FiltersEnabled = 1; 

function stmPre(HdrVal,BodyVal)
{

}	

function initTips()
			{
				mig_clay()
			}		
			// [for IE5.5+] if your not going to use transitions or filters in any of the tips set this to zero.			
			
			function stmPreview(HdrVal,BodyVal)
			{
				stm("&nbsp;" + "MTN",BodyVal,Svalues.split(','));
			}		

function onSelectDropDownChanged(eDropID,eDynamic)
{
    try
    {

        if(eDropID!='')
        {   
           var eDropDown = document.getElementById(eDropID);
            if(eDropDown!=null && eDynamic=="true")
            {
                var eNavURL = eDropDown.value;
                if(eNavURL!='')
                {

                location.href= eNavURL;
                }
            }

        }
    }
    catch(e)
    {
    }
}
function IsValidNumber(eValue)
{
    try
    {

        var eva= parseInt(eValue);			        
        if(eva>=0)			        
            return true;
   }
   catch(e)
   {
         alert(e);
   }
    return false;
}

function SendValidFlashParameter(eid)
{

    var RParma='';
    var varparms=eid;


    if(varparms=='' || varparms=='null')
    {

        if(location.href.toLowerCase().indexOf("myphone.aspx")>=0)
        {

        return 'myphone';                
        }
        else  if(location.href.toLowerCase().indexOf("login.aspx")>=0)
        {
        return 'home';                
        }
        else
        return 'home';                
    }

    if(varparms!='')
    {

        if(varparms=="tartcont" )
        {
          RParma= "artistlisting";
        }
        else     if(varparms=="artistcontentpage" )
        {
            RParma= "artistlisting";
        }
        else if(varparms=="topcallertunez" )
        {
              RParma= "musichome";
        }
        else if(varparms=="subcategories"  || varparms=="genredetails")
        {
              RParma= "categories";                       
        }                       
        else if(varparms=="sportshome" || varparms=="soccernews")
        {
               RParma= "sportshome";
        }
        else if(varparms=="fifahome" ||varparms=="fifanews" ||varparms=="fifatop"  || varparms=="pslhome"|| varparms=="pslnews" || varparms=="eplhome" || varparms=="eplnews" || varparms=="soccerpremierleague")
        {
              RParma= "soccerhome";
        }
        else if(varparms=="wwwresults" || varparms=="wwwnews")
        {
              RParma= "wwehome";
        }
        else if(varparms=="wwwresults" || varparms=="wwwnews")
        {
              RParma= "wwehome";
        }
        else if(varparms=="gamedetails"  )
        {
               RParma= "gamehome";
        }
        else if(  varparms=="gamelisting")
        {
              RParma= "gamecategorieslisted";
        }
        else if(varparms=="articlepageint" || varparms=="articlesports" || varparms=="articletechno")
        {
            var fedtype=getParameter("feedtype"); 
            if(fedtype=="intnews"  || fedtype=="intnews_new")
              RParma= "localinternational";	
            else if(fedtype=="sanews")
              RParma= "localnews";
            else if(fedtype=="sportsnews")
              RParma= "sportsnews";
            else if(fedtype=="finance")
              RParma= "financenews";
            else if(fedtype=="motoring")
               RParma= "motoring";
            else if(fedtype=="technology")
              RParma= "technologynews";
            else
             RParma= "newsinfo";
        }
        else if(varparms=="wallpaperscnt" || varparms=="wallpaperssubcat")
        {
         RParma= "lifestylehome";
        }
        else if(varparms=="smsupdates"  )
        {
         RParma= "lifestylehome";
        }                          
    }

    return RParma; 
}



function MakeMenuHidden(eType)
{

}
function onRightClickPage()
{
    return false;
}
function createXMLHttpRequest()
{
    if (window.XMLHttpRequest)
    {
         return new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        var msxmls = new Array(
        'Msxml2.XMLHTTP',
        'Microsoft.XMLHTTP');
        for (var i = 0; i < msxmls.length; i++) 
        {
            try
            {
            return new ActiveXObject(msxmls[i]);
            } catch (e)
            {}
        }
    }
    throw new Error("Could not instantiate XMLHttpRequest");
}



function LoadXML(url) 
{              
}

function SendValidTypeParameters(eid)
{                
    var RParma='';
    var varparms=eid;
    if(varparms!='')
    {       
 			if(varparms=="lifehome" )
             {
             RParma= "lifestylehome";
             }
			else if(varparms=="enthome" )
             {
             RParma= "entertainmenthome";
             }
			else if(varparms=="varing" )
             {
             RParma= "musichome";
			 }
			else if(varparms=="mhm_loaded" )
             {
             RParma= "musichome";
             }
			else if(varparms=="tfifa" )
             {
             RParma= "sportshome";
             }
    }
    if(RParma=='')
        RParma=eid;
    return RParma; 
}





function onMenuHover(itemid,vtype)
{
    var pItem = document.getElementById("pdiv_"+itemid);  
    var dItem = document.getElementById("divmn_"+itemid);  
    
     if(activemenuId!=itemid) 
     {
         if(pItem!=null )
         {
             if(vtype=='1')        
             {
                pItem.style.display='block';           
                if(dItem!=null)
                {
                    try
                    { 
                        dItem.style.paddingTop+=5;
                        dItem.style.paddingLeft+=5;
                    }
                    catch(e)
                    {
                    }
                }
             }
            else
            {
                pItem.style.display='none';        
                if(dItem!=null)
                {
                    try
                    {    
                    dItem.style.paddingTop-=5;
                    dItem.style.paddingLeft-=5;
                    }
                    catch(e)
                    {
                    }
                }
               
            }
        }
     }     
}





var activemenuId='';
function onMenuNaivationActivation(itemid,idList,vClr)
{

    var pItem = document.getElementById("pdiv_"+itemid);
    var imagItem = document.getElementById("divmn_"+itemid);
    var divItem =document.getElementById("div_"+itemid)
    activemenuId=itemid;
 
    var arridList=idList.split(',');
    for(var i=0;i<arridList.length;i++)
    {
    
        var Imgtemp = document.getElementById("divmn_"+arridList[i]);
        var DIVtemp = document.getElementById("div_"+arridList[i]);
 
            if(Imgtemp!=null)
            {
                var iact= Imgtemp.getAttribute('refactive',true);
                var iInact =Imgtemp.getAttribute('refinactive',true);
                Imgtemp.setAttribute('class',iInact,true);
                Imgtemp.setAttribute('className',iInact,true);
            }
            if(DIVtemp!=null)
            {
                DIVtemp.style.display='none';
            }
            if(pItem!=null)
            {
              pItem.style.display='none';
            }
            onItemHover(arridList[i],vClr,'2');
 
    }
    if(imagItem!=null && divItem!=null)
    {
        var iact= imagItem.getAttribute('refactive',true);
        imagItem.setAttribute('class',iact,true);
         imagItem.setAttribute('className',iact,true);
        divItem.style.display='block';
        pItem.style.display='block';
        onItemHover(itemid,vClr,'1');

    }
}
function onItemHover(itemid,vclr,vtype)
{    

    if( $(".liImages li a")!=null)
    {
        etemp=$(".liImages li a");  
      if(vtype=='1')
      {
            etemp.mouseover(function()
                {
                   etemp.css("background-image", "url(images/icons/navbackround/bg-"+vclr+".png)");               
                }
            ); 
            etemp.mouseout(function()
                {               
                   etemp.css("background", "");
                }
            ); 
       } 
       else
       {
         etemp.mouseover(function()
                {
                   etemp.css("background", "");               
                }
            ); 
            etemp.mouseout(function()
                {               
                   etemp.css("background", "");
                }
            ); 
       }
    }
}


 
function onMenuNavigationHome(eURl)
{
   location.href=eURl+"&hlt="+GetTicksValues();
}
function getParameterByURL ( parameterName,eURL )
{         
    try
    {
        parameterName=parameterName.toLowerCase();

        var queryString = '';
        if(eURL.indexOf('?')>0)
            queryString=queryString.substring(eURL.indexOf('?'));
        
        queryString=queryString.toLowerCase();
        var parameterName = parameterName + "=";
        if ( queryString.length > 0 )
        {           
            begin = queryString.indexOf ( parameterName );            
            if ( begin != -1 )
            {            
                begin += parameterName.length;            
                end = queryString.indexOf ( "&" , begin );
                if ( end == -1 )
                {
                    end = queryString.length
                }        
                     return unescape( queryString.substring ( begin, end ) );
            }        
             return "null";
        }
    }
    catch(e)
    {
    }
    return '';
} 

 function GetTicksValues()
{
    var currentTime = new Date();           
    return  currentTime.getUTCHours() +""+currentTime.getUTCSeconds()+""+currentTime.getUTCMinutes()+""+currentTime.getUTCDate();
}



   function GetWidthDetails()
   {
   
        var viewportwidth;
        var viewportheight;

        // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

        if (typeof window.innerWidth != 'undefined')
        {
        viewportwidth = window.innerWidth,
        viewportheight = window.innerHeight
        }

        // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
        else
        {
            if(document.getElementsByTagName('body')[0].clientWidth!=null && document.getElementsByTagName('body')[0].clientHeight!=null)
            {
                  viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
                  viewportheight = document.getElementsByTagName('body')[0].clientHeight
            }
            else if (typeof document.documentElement != 'undefined'
            && typeof document.documentElement.clientWidth !=
            'undefined' && document.documentElement.clientWidth != 0)
            {
                viewportwidth = document.documentElement.clientWidth;
                viewportheight = document.documentElement.clientHeight;
            }
            
        }
   
        return viewportwidth+"~"+viewportheight;
   }
   
   
    function DetectPageLoad()
    {          
        var ScookieVal =Get_Cookie('validrequestmtn');     
          var vurl=location.href;     
        if((ScookieVal!=null && ScookieVal.length>0) || vurl.indexOf("vReq")>0)
        {
            if(vurl.indexOf("?")<0)
            {
               vurl=vurl+"?vReq="+GetTicksValues();
               location.href=vurl;
            }
        }
        else
        {
            Set_Cookie("validrequestmtn","true");
                 
           if(vurl.indexOf("?")>0)
                vurl=vurl+"&vReq="+GetTicksValues();
            else
                vurl=vurl+"?vReq="+GetTicksValues();           
            location.href=vurl;
        }
	    
    }
    function Delete_Cookie()
    {
         document.cookie=null;
    }
    function Get_Cookie( check_name )
    {
	    var a_all_cookies = document.cookie.split( ';' );
	    var a_temp_cookie = '';
	    var cookie_name = '';
	    var cookie_value = '';
	    var b_cookie_found = false; // set boolean t/f default f

	    for ( i = 0; i < a_all_cookies.length; i++ )
	    {
		    a_temp_cookie = a_all_cookies[i].split( '=' );
		    cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');


		    if ( cookie_name == check_name )
		    {
			    b_cookie_found = true;

			    if ( a_temp_cookie.length > 1 )
			    {
				    cookie_value = unescape( a_temp_cookie[1]);
			    }

			    return cookie_value;
			    break;
		    }
		    a_temp_cookie = null;
		    cookie_name = '';
	    }
	    if ( !b_cookie_found )
	    {
		    return null;
	    }
    }
       
        function Set_Cookie( name, value)
        {                      
           document.cookie = name + "=" +value;
              
        }
        function getDistictURL(eURL)
        {
            if(eURL.indexOf("?")>0)
            {
                eURL=eURL+"&vID="+GetTicksValues();
            }
            else 
            {
                eURL=eURL+"?vID="+GetTicksValues();
            }
            location.href=eURL;
        }
