﻿function ShowDefaultText(textbox, DefaultText)
{
	if(textbox.value == "")
	{
		textbox.value = DefaultText;
	}
}

function HideDefaultText(textbox, DefaultText)
{
	if(textbox.value.toLowerCase() == DefaultText.toLowerCase())
	{
		textbox.value = "";
	}
}
function displayBrandSpeed()
{
    location.href = "BandTest.aspx";
}

var arrDropDownVisibilityStatus = new Array();
function ShowBlocker()
{
    var intLoop;
    var blocker = document.getElementById("divMask");
    arrSelects = new Array();
    
    arrSelects = document.getElementsByTagName("SELECT");
    for (intLoop=0; intLoop < arrSelects.length; intLoop++)
    {
        arrDropDownVisibilityStatus[intLoop] = arrSelects[intLoop].style.visibility;
        arrSelects[intLoop].style.visibility = "hidden";
    }
    blocker.style.width = document.documentElement.clientWidth + "px";
    blocker.style.height = document.documentElement.scrollHeight + "px";
    blocker.style.display = "";
}

function HideBlocker()
{
    var intLoop;
    var blocker = document.getElementById("divMask");
    arrSelects = new Array();
    
    arrSelects = document.getElementsByTagName("SELECT");
    for (intLoop=0; intLoop < arrSelects.length; intLoop++)
    {
        arrSelects[intLoop].style.visibility = arrDropDownVisibilityStatus[intLoop];
    }
    blocker.style.display = "none";
}

function Alert(Title, Message)
{
    ShowBlocker();
    document.getElementById("spnTitle").innerHTML = Title;
    document.getElementById("spnMessage").innerHTML = Message;
    
    document.getElementById("divAlert").style.visibility = "hidden";
    document.getElementById("divAlert").style.display = "";
    setPopUpPoistion("divAlert");
    document.getElementById("divAlert").style.visibility = "visible";
    
    return false;
}

function CloseAlert()
{
    document.getElementById("divAlert").style.display = "none";
    HideBlocker();
}

function setPopUpPoistion(popUpId)
{
   var divHeight = 150;
   var divWidth = 350;
  
   if(parseInt(document.getElementById(popUpId).style.height) > 0)
   {
        divHeight = parseInt(document.getElementById(popUpId).style.height);
   }
   else if(parseInt(document.getElementById(popUpId).offsetHeight) > 0)
   {
        divHeight = parseInt(document.getElementById(popUpId).offsetHeight);
   }
        
   if(parseInt(document.getElementById(popUpId).style.width) > 0)
   {
        divWidth = parseInt(document.getElementById(popUpId).style.width);
   }
    
   document.getElementById(popUpId).style.top = ((screen.availHeight - divHeight)/2 + getScrollTop() - 120) + "px";
   
   document.getElementById(popUpId).style.left = ((screen.availWidth - divWidth)/2 + document.documentElement.scrollLeft) + "px";
}

function getScrollTop()
{
	var scrollTop;
	
	if(document.body.scrollTop == 0)
	{
	    scrollTop=document.documentElement.scrollTop;
	}
	else
	{
	    scrollTop=document.body.scrollTop;
	}
	return scrollTop;
}
function AllowNumeric(event)
 {
  
    var keyval=window.event?window.event.keyCode:event.which;

    if ( (!( (((keyval >= 48) && (keyval <= 57))||(keyval ==46)) ))) 
       {
            if(!window.XMLHttpRequest)
            {        
            window.event.keyCode = null;                
            }
            else if(navigator.userAgent.toLowerCase().indexOf("msie") > -1)
            {
                window.event.keyCode = null;
            }
            else
            {
                if (!((keyval == 0) || (keyval <= 8))) 
                {
                        event.preventDefault();
                }
            }                                        
      }                           
} 
function AllowNumeric(event)
 {
  
    var keyval=window.event?window.event.keyCode:event.which;

    if ( (!( (((keyval >= 48) && (keyval <= 57))||(keyval ==46)) ))) 
       {
            if(!window.XMLHttpRequest)
            {        
            window.event.keyCode = null;                
            }
            else if(navigator.userAgent.toLowerCase().indexOf("msie") > -1)
            {
                window.event.keyCode = null;
            }
            else
            {
                if (!((keyval == 0) || (keyval <= 8))) 
                {
                        event.preventDefault();
                }
            }                                        
      }                           
} 
function ChkValidEmail(object)
{
    var myRegxp = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/

    return myRegxp.test(object);
}

function IncludeAnd(strErr)
{	
    var lastindex=0;	
    if(strErr.indexOf(",")>-1)
    {    	
        lastindex=strErr.lastIndexOf(",") 
        var strcheckstringwithcoma="";
        var strcheckstringwithand="";
        strcheckstring=strErr.substring(lastindex,parseInt(strErr.length));
        strcheckstringwithand=strcheckstring.replace(","," and")
        strErr=strErr.replace(strcheckstring, strcheckstringwithand);
    }
    return strErr; 
}
function CheckDelete(value)
{
    if(confirm("Are you sure you want to delete selected " + value + "?"))
    {
        return true;    
    }
    else
    {
        return false;
    }
}