﻿/*
function addAjaxRequests()
{
    alert('hi');
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(function (sender, args) { 
                showcurtain();  }); 
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function (sender, args) { 
                hidecurtain();  });
}
*/
function hidecurtain(){
 if(document.getElementById("curtain1")!=null)
     document.getElementById("curtain1").style.display="none";
 }
 
function showcurtain(){
    if(document.getElementById("curtain1")!=null) {
         var str = document.location.href;
         if(str.indexOf("MessagePlaybackSummaryReport.aspx") == -1  && str.indexOf("CampaignPlaybackStatisticsReport.aspx") == -1 && 
            str.indexOf("MessagePlaybackStatisticsReport.aspx") == -1 && str.indexOf("CampaignPlaybackSummaryReport.aspx") == -1 )
         { document.getElementById("curtain1").style.display=""; }  }
    }
function hideTheCalendarMaster(){
    try{                    
        var ce1 = $find("CalPickupDate");
        var ce2 = $find("CaltxtDateCreatedTo");
        var ce3 = $find("ceFromDate");
        var ce4 = $find("ceToDate");
        if(ce1!=null)
            $find("CalPickupDate").hide();
        if(ce2!=null)
            $find("CaltxtDateCreatedTo").hide();
        if(ce3!=null)
            $find("ceFromDate").hide();
        if(ce4!=null)
            $find("ceToDate").hide();                        
    }
    catch(err){}
}

function validateZip(CountryCode,Zip){                
    var re5digit=new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
    var re6digit=new RegExp(/(^[ABCEGHJKLMNPRSTVXY][0-9][A-Z][0-9][A-Z][0-9]$)|(^[ABCEGHJKLMNPRSTVXY][0-9][A-Z].[0-9][A-Z][0-9]$)/);
    if(CountryCode == "US"){
        if(Zip.length==5){
            if(re5digit.test(Zip))
                return true;
            else
                return false;
        }
        else{
            return false;
        }
    }
    else if(CountryCode == "CD"){
        Zip = Zip.toUpperCase();
        if(Zip.length==6){
            if(re6digit.test(Zip.toUpperCase()))
                return true;
            else
                return false;
        }
        else{
            return false;
        }
    }
    return true;
}

function unvalidate(myValidationGroup)
{
    // Remove the validator control(s) from display.
    var myValidators = Page_Validators;
    if ((typeof(myValidators) != "undefined") && (myValidators != null))
    {
        for (i=0;i<myValidators.length;i++)
        {
            var myValidator = myValidators[i];
            if (myValidationGroup == null || IsValidationGroupMatch(myValidator, myValidationGroup))
            {
                if (myValidator.style.visibility.length > 0 && myValidator.style.display.length == 0)
                {
                    myValidator.style.visibility = 'hidden';
                }
                else if (myValidator.style.display.length > 0 && myValidator.style.visibility.length == 0)
                {
                    myValidator.style.display = 'none';
                }
            }
        }
    }
}

function OpenPrivacyPolicy(){
    window.open("http://www.playnetwork.com/About/PlayNetwork-Privacy.aspx");
    return false;
}

/*
function addFloatingBehavior(ctrl, ctrlHandle){  
    $create(Sys.Preview.UI.FloatingBehavior, 
          {'handle': ctrlHandle},null, null, ctrl);
}
*/
function hideModalPopup(id){
    if($find(id)!=null)
        $find(id).hide();
    return false;
}

function showModalPopup(id){
    if($find(id)!=null)
        $find(id).show();
    return false;
}

function hideControl(id){   
    if(document.getElementById(id)!=null)
        document.getElementById(id).style.display = 'none'; }

function showControl(id){   
    if(document.getElementById(id)!=null)
        document.getElementById(id).style.display = ''; }

function clearCtrls(ids){   
    for (idsCount = 0; idsCount < ids.length; idsCount ++){
        var ctrl = document.getElementById(ids[idsCount]);
        if(ctrl != null){        
            if(ctrl.type == 'text' || ctrl.type == 'password')
                ctrl.value = '';
            else if(ctrl.type == 'select-one')
                ctrl.selectedIndex = 0;            
            else if(ctrl.type == undefined && ctrl.nodeName == 'SPAN' )
                ctrl.visible = false;
            else if(ctrl.type == undefined && ctrl.nodeName == 'DIV' )
                ctrl.style.display = 'none';            
        }
    }
}

function setValue(id, val){
    if(document.getElementById(id)!=null)
        document.getElementById(id).value = val;
}

function setUploadControl(ddlInstruction, messageRequestUploadDiv)
{
    var selectedValue = ddlInstruction.options[ddlInstruction.selectedIndex].value;
    if(selectedValue != 1)
        messageRequestUploadDiv.style.display = 'none';
    else
        messageRequestUploadDiv.style.display = '';
}