﻿function ClickButton(e, buttonid) 
{
    var bt = document.getElementById(buttonid); 
    if (typeof bt == 'object')
    { 
        if (event.keyCode == 13)
        {             
            bt.click(); 
            return false; 
        } 
    }
}

function validateEmail( tboEmailID )
{
    var tboEmail = document.getElementById( tboEmailID );
    if( tboEmail.value.length > 0 ){
        var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
        if( !filter.test( tboEmail.value ) ){ return false; }
    }
    else{
        return false;
    }
    return true;
}

function changeFontSize( size )
{    
    if( size == 'normal' )
    {
        document.body.style.fontSize = '62.5%';
        eraseCookie( 'fontSizeB' );
        createCookie( 'fontSizeB', 'normal', 1 );        
    }
    else if( size == 'large' )
    {
        document.body.style.fontSize = '80%';
        eraseCookie( 'fontSizeB' );
        createCookie( 'fontSizeB', 'large', 1 );
    }
    else if( size == 'largest' )
    {
        document.body.style.fontSize = '100%';
        eraseCookie( 'fontSizeB' );
        createCookie( 'fontSizeB', 'largest', 1 );
    }
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

/*function checkForSizeCookie( )
{
    var cookie = readCookie('fontSizeB');    
    if( cookie != null )
    {
        if( cookie == 'normal' )
        {
            document.body.style.fontSize = '62.5%';       
        }
        else if( cookie == 'large' )
        {
            document.body.style.fontSize = '80%';
        }
        else if( cookie == 'largest' )
        {
            document.body.style.fontSize = '100%';
        }
    }
}

addLoadEvent( checkForSizeCookie );*/
