  
        function openDemo(){
            window.open('consumerDemo.htm','Terms','menubar=no,toolbar=no,scrollbars=no,resizable=yes,width=730,height=530,top=35,left=35');
        }
      

        function terms_popup()
        {
	        window.open('Terms.htm','Terms','menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=800,height=450,top=35,left=35');
        }
        
   
// JavaScript Documents

// To prevent pasting of values into a textbox.
function noCopyKey(e) 
{
    var forbiddenKeys = new Array('c','x','v');
    var keyCode = (e.keyCode) ? e.keyCode : e.which;
    var isCtrl;

    if(window.event)
        isCtrl = e.ctrlKey
    else
        isCtrl = (window.Event) ? ((e.modifiers & Event.CTRL_MASK) == Event.CTRL_MASK) : false;

    if(isCtrl) 
    {
        for(i = 0; i < forbiddenKeys.length; i++) 
        {
            if(forbiddenKeys[i] == String.fromCharCode(keyCode).toLowerCase()) 
            {
                return false;
            }
        }
    }
    return true;
}

            function ValidateName(oSrc, args)
            {	           
	            //List of valid characters which the name can contain.
	            var validList = "'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- ";
	            //Check if invalid characters are contained in the code.
	            for(var i = 0; i < args.Value.length; i++)
	            {               
		            if(validList.indexOf(args.Value.charAt(i) )== -1)
		            {
		            args.IsValid = false;
		            return false;
		            }
	            }            		
	            return true;
	            args.IsValid = true;
            }

function ValidatePhoneNumber(oSrc, args)
{
	//List of invalid characters which the phone can not contain.
	//var invalidList = "~!@#$%^*()_+|\`={}[]:;<>?,/\\";
	//List of invalid characters which the phone can contain.
	var validList = "0123456789()-+.extEXT ";
	//Check if invalid characters are contained in the code.
	for(var i = 0; i < args.Value.length; i++)
	{	    	    
		if(validList.indexOf(args.Value.charAt(i) )!= -1)
		{
		args.IsValid = false;
		//return false;
		}
	}
		
	//return true;
	args.IsValid = true;
}
function ValidatePhone(p1)
{	
	p=p1.value
	if(p.length>3)
	{
		d1=p.indexOf('')
		d2=p.indexOf('-')
		if (d2==-1)
		{
			l30=p.length;
			p30=p.substring(0,3);
		
			p30=p30+"-"
			p31=p.substring(3,l30);
			pp=p30+p31;
							
			document.getElementById(p1.id).value=pp;
		p=pp
		d2=p.indexOf('-')
		}
	}
	if(p.length>5)
	{
		p11=p.substring(d1+1,d2);
		if(p11.length>3)
		{
			p12=p11;
			l12=p12.length;
			l15=p.length
		
			p13=p11.substring(0,3);
			p14=p11.substring(3,l12);
			p15=p.substring(d2+1,l15);
			document.getElementById(p1.id).value="";
			pp="("+p13+")"+p14+p15;
			document.getElementById(p1.id).value=pp;
				
		}
		l16=p.length;
		p16=p.substring(d2+1,l16);
		l17=p16.length;
		if(l17>3 && l17!=4 && p16.indexOf('-')==-1)
		{
			p17=p.substring(d2+1,d2+4);
			p18=p.substring(d2+4,l16);
			p19=p.substring(0,d2+1);
			
			pp=p19+p17+"-"+p18;
			document.getElementById(p1.id).value="";
			document.getElementById(p1.id).value=pp;
		}
	}
	/*if (typeof (ValidatorOnChange) == "function")
	{
		ValidatorOnChange()
	}*/	
}
function OnEnterClick(window,control)
{
	if( window.event.keyCode =='13' && document.getElementById(control) )
	{
		document.getElementById(control).click();
	}
	return true;
}	

function datemask(t)
{
var donepatt = /^(\d-{2})\/(\d-{2})\/(\d-{4})$/;

var patt = /(\d{2}).*(\d{2}).*(\d{4})/;
var str = t.value;

if (!str.match(donepatt))
{
	result = str.match(patt);

	if (result!= null)
	{
		if(window.event.keyCode != 37 && window.event.keyCode != 39 )
			{
				    t.value = t.value.replace(/[^\d-/]/gi,'');				    	
		    		str = result[1] + '/' + result[2] + '/' + result[3];					
					t.value = str;									
			}
		else
			{
				if (t.value.match(/[^\d-/]/gi))
				{
					t.value = t.value.replace(/[^\d-/]/gi,'');
				}
			}
		}
	else
		{
			if (t.value.match(/[^\d-/]/gi))
			{
				t.value = t.value.replace(/[^\d-/]/gi,'');
			}
		}
	}
}	
//date  masking with N/A string
function datemaskexp(t)
{
	if(t.value.match(/^[N/A]/))
	{	t.value='N/A';
		return false;
	}
var donepatt = /^(\d-{2})\/(\d-{2})\/(\d-{4})$/;
var patt = /(\d{2}).*(\d{2}).*(\d{4})/;
var str = t.value;
if (!str.match(donepatt))
{
	result = str.match(patt);
	if (result!= null)
	{
	t.value = t.value.replace(/[^\d-/]/gi,'');
	str = result[1] + '/' + result[2] + '/' + result[3];
	t.value = str;
	}else{
	if (t.value.match(/[^\d-/]/gi)){
		t.value = t.value.replace(/[^\d-/]/gi,'');
	}
	}
}
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_openBrWindow(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
}


/**************************************************************************
 *                                                                        *
 *  JAVASCRIPT MENU HIGHLIGHTER v.1.0 (051123)                            *
 * --------------------------------------------                           *
 * ©2005 Media Division (www.MediaDivision.com)                           *
 *                                                                        *
 * Written by Marius Smarandoiu & Armand Niculescu                        *
 *                                                                        *
 * You are free to use, modify and distribute this file, but please keep  *
 * this header and credits                                                *
 *                                                                        *
 * Usage:                                                                 *
 * - the script will apply the .current class to the <a> and its parent   *
 *   <li> that is contained in the element with id="primarynav" and points*
 *   to the current URL                                                   *
 * - works in IE6, Firefox and Opera                                      *
 **************************************************************************/
function extractPageName(hrefString)
{
	var arr = hrefString.split('.');
	arr = arr[arr.length-2].split('/');
	return arr[arr.length-1].toLowerCase();		
}

function setActiveMenu(arr, crtPage)
{	
	for(var i=0; i < arr.length; i++) {
		if(extractPageName(arr[i].href) == crtPage)
		{
			arr[i].className = "navON";
			arr[i].parentNode.className = "navON";
		}
	} 
}
function privacy_popup()
{
    
	window.open('Privacy.htm','PrivacyPolicy','menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=835,height=450,top=35,left=35');
}
 
function setPage()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;

	if (document.getElementById("navbar")!=null)
		setActiveMenu(document.getElementById("navbar").getElementsByTagName("a"), extractPageName(hrefString));
}

function goToLogin()
{
    var page;
    var type = document.getElementById("hdnType").value;
    if(type == "dni")
    {
    page = "DNICSR/Login.aspx";
    }
    else if (type == "user")
    {
      page="homelogin.aspx";
    }
    if(page != "")
    {
        document.location.href = page;
        }
          
    }     

function forgotPassword_popup()
{
	window.open('forgotpassword.asp','ForgotPassword','menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=500,height=250,top=200,left=200');
}
function CheckForSpecialCharacter(oSrc, args)
{
	//List of invalid characters which the phone can not contain.
	//var invalidList = "~!@#$%^*()_+|\`={}[]:;<>?,/\\";
	var invalidList = "=~<>/\\!@#$^_|\`{}[]:;?\"%&'";
	//Check if invalid characters are contained in the code.
	for(var i = 0; i < args.Value.length; i++)
	{
	    
		if( invalidList.indexOf(args.Value.charAt(i) )!= -1)
		{
		args.IsValid = false;
		return false;
		}
	}
		
	//return true;
	args.IsValid = true;
}

function countLength(ctlId, dispId)
{
      var txt = document.getElementById(ctlId);
      if (txt != null)
      {
            var length =txt.value.length;
            var disp = document.getElementById(dispId);
//            if(length >= 1000)
//            {
//                 alert("Note cannot exceed more than 1000 characters.");
//                 evt.returnValue = false;
//                 return false;
//            }  
            if (disp != null)
            {
                disp.innerText = length.toString();
            }
       }
}
function ValidatePromocodePercentage(src,args)
            {
            
                 var promocodeSingle =document.getElementById('ctl00_ContentPlaceHolder1_percetageTextBox');
      
      if(promocodeSingle.style.display == "inline")
      {
                if(promocodeSingle.value == null || Trim(promocodeSingle.value) == "")
                {    
                  promocodeSingle.value="";
                   promocodeSingle.focus();
                    args.IsValid = false;
                  
                }
                }
                else
                {
                 args.IsValid = true;
                }
            }
function ValidatePromocodeDollar(src,args)
            {
         
                 var promocodeSingle =document.getElementById('ctl00_ContentPlaceHolder1_txtReductionDollar');
     
      if(promocodeSingle.style.display == "inline" )
      {
                if(promocodeSingle.value == null || Trim(promocodeSingle.value) == "")
                {    
                  promocodeSingle.value="";
                  promocodeSingle.focus();
                    args.IsValid = false;
                    
                }
                }
                else
                {
                 args.IsValid = true;
                }
            }
// Trims all spaces to the left of a specific string
function LTrim(str)
{
        var whitespace = new String(" \t\n\r ");
        // last space character is not a space, but alt+0160,
        // another invisible char.
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
            // We have a string with leading blank(s)...
            var j=0, i = s.length;
            // Iterate from the far left of string until we
            // don't have any more whitespace...
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;
            // Get the substring from the first non-whitespace
            // character to the end of the string...
            s = s.substring(j, i);
        }
        return s;
}
// Trims all spaces to the right of a specific string
function RTrim(str)
{
        // We don't want to trip JUST spaces, but also tabs,
        // line feeds, etc.  Add anything else you want to
        // "trim" here in whitespace
        var whitespace = new String(" \t\n\r ");
        // last space character is not a space, but alt+0160,
        // another invisible char.
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            // We have a string with trailing blank(s)...
            var i = s.length - 1;       // Get length of string
            // Iterate from the far right of string until we
            // don't have any more whitespace...
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;
            // Get the substring from the front of the string to
            // where the last non-whitespace character is...
            s = s.substring(0, i+1);
        }
        return s;
}
                                                                                                                        
// Trims all spaces to the left and right of a specific string by calling RTim
// and LTrim
function Trim(str)
{
        return RTrim(LTrim(str));
}
function maxLength(ctlId,evt)
{
    var txt = document.getElementById(ctlId);
    if (txt != null)
     {
        var length =txt.value.length;
        if(length >= 1000)
        {
            alert(GetResourceData("CreateSbAccount_Value_cannot_exceed" ));                         
             evt.returnValue = false;
             return false;
        }  
     }
}
function ValidateAliasName(oSrc, args)
{		
	var invalidList = "=~<>/\\!@#$^*_|\`{}[]:;?\"%'";
	//Check if invalid characters are contained in the code.
	for(var i = 0; i < args.Value.length; i++)
	{
	    
		if( invalidList.indexOf(args.Value.charAt(i) )!= -1)
		{
		args.IsValid = false;
		return false;
		}
	}
		
	//return true;
	args.IsValid = true;
}

function CheckForInvalidCharacter(oSrc, args)
{    
	//List of invalid characters which the phone can not contain.	
	var invalidList = "<>#';";
	//Check if invalid characters are contained in the code.
	for(var i = 0; i < args.Value.length; i++)
	{	    
		if( invalidList.indexOf(args.Value.charAt(i) )!= -1)
		{
		    args.IsValid = false;		    
		    return false;
		}
	}
	args.IsValid = true;
	
	return true;
}
function CheckForInvalidAddress(oSrc, args)
{    
	//List of invalid characters which the phone can not contain.	
	var invalidList = "<>#';";
	//Check if invalid characters are contained in the code.
	for(var i = 0; i < args.Value.length; i++)
	{	    
		if( invalidList.indexOf(args.Value.charAt(i) )!= -1)
		{
		    args.IsValid = false;		    
		    return false;
		}
	}
	args.IsValid = true;
	
	return true;
}
function CheckForInvalidCharacterNumber(oSrc, args)
{
	//List of invalid characters which the phone can not contain.	
	var invalidList = "<>#1234567890'";
	//Check if invalid characters are contained in the code.
	for(var i = 0; i < args.Value.length; i++)
	{	    
		if( invalidList.indexOf(args.Value.charAt(i) )!= -1)
		{
		    args.IsValid = false;
		    return false;
		}
	}
	args.IsValid = true;
	return true;
}

