﻿// Common Functions

function ShowContent(d) 
{

    if (document.getElementById) { // DOM3 = IE5, NS6

    document.getElementById(d).style.visibility = "";

    } else {

    if (document.layers) { // Netscape 4

    document.d.visibility= "";

    } else { // IE 4

    document.all.d.style.visibility = "";

    }

    }

    //if(d.length < 1) { return; }

    //document.getElementById(d).style.visibility = "";

}

function UpdateUserControl(userControlID, e) 
{
    var key;
    if(window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;                  //firefox

    if (key == 13)
    {
        if (window.event)
        {
            showLoader();
            document.getElementById(userControlID).click()
            hideLoader();
        }
        else
        {
            var btn = document.getElementById(userControlID);
            if (btn != null)
            { //If we find the button click it
                btn.click();
                event.keyCode = 0
            }
            
        }
    } 
}

function HideContent(d) 
{

    document.getElementById(d).style.visibility = "hidden";

    //alert(d);

    if (document.getElementById) { // DOM3 = IE5, NS6

    document.getElementById(d).style.visibility = "hidden";

    } else {

    if (document.layers) { // Netscape 4

    document.d.visibility= "hidden";

    } else { // IE 4

    document.all.d.style.visibility = "hidden";

    }

    }

    //if(d.length < 1) { return; }

}

function doKey(method, e)
{
    var key;
    
    if(window.event)
          key = window.event.keyCode;     //IE
    else
          key = e.which;     //firefox

    if (key == 13)
    {
        CallAnthemWLoader(method,'')
        event.keyCode = 0   
    }
} 

function ScrollToTop() 
{
	window.scroll(0,0); 
}

 
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

 
