var NetReady_Script_Loaded = true;

onerror=handleErr

function handleErr(msg,url,l)
{
	return true
}

function HookuptoControl(control, function_name, use_validation) {

if (!control) { return }

   if (use_validation = true) {
     if (!(!Page_ValidationVer)) { //1march
       use_validation = false
     }
   }  
        
//    if (typeof(control.tagName) == "undefined" && typeof(control.length) == "number") {
	if ((!(!control.tagName)) && (typeof(control.length) == "number")) {
        var i;
        for (i = 0; i < control.length; i++) {
            var inner = control[i];
            if (typeof(inner.value) == "string") {
                HookuptoControl(inner, function_name);
            } 
        }
        return;
    }
    else 
      if (control.tagName != "INPUT" && control.tagName != "TEXTAREA" && control.tagName != "SELECT") {
        var i;        
        for (i = 0; i < control.children.length; i++) {
            HookuptoControl(control.children[i], function_name);
        }
        return;
      } else {
         var ev;
         if ((control.type == "radio") || (control.type == "submit")) {
             ev = control.onclick;
         } else {
             ev = control.onchange;
         }
          
         if ((control.type == "checkbox")) 
         {
             ev = control.onclick;
         }
             
         if (typeof(ev) == "function" ) {            
             ev = ev.toString();
             ev = ev.substring(ev.indexOf("{") + 1, ev.lastIndexOf("}"));
         } else {
             ev = "";
         }        
         
         ev = ev.toString();
         //If this function includes some validation then 
         //do the validation before your own function.
         var Code
         if (ev.indexOf("Valid") > 0) {
           //if the function has an if statement without brackets 
           //then we need to add brackets.
           if (ev.indexOf("if") > 0)  {
             if (ev.indexOf("{") != 0) {
               ev = ev.substring(ev.indexOf("if"), ev.lastIndexOf(";") + 1);
                                             
               condition = ev.substring(ev.indexOf("if"), ev.lastIndexOf(") ") + 1);
                            
               action = ev.substring(ev.lastIndexOf(") ") + 1 );
               
               ev = condition + " {" + action + "}" + "\n"
               
               if (use_validation == true) {
                 ev = ev + "if (Page_IsValid == true) {" + function_name + "();}"
               } else {
                 ev = ev + function_name + "();"
               }
                            
               Code = ev
                       
             } else {
               Code = ev + ";" + function_name + "(); "           
             }
           } else {
             Code = ev + ";" + function_name + "(); "           
           }
           
         } else {
           Code = function_name + "(); " + ev           
         }
                   
         var func = new Function(Code);       
         if (control.type == "submit") {
             control.onclick = func;
         } else {   
            if (control.type == "radio") {
               control.onclick = func;
            } else {            
               if (control.type == "checkbox") {
                  control.onclick = func;
               } else {
			       control.onchange = func;
			   }
            }
         }      
      }    
    
  }
  
  
  //=============================================================
  //Add Event Handler
      var Handlers =  new Array(); //this array contains all events for page
     
     function AddHandler(control, type, handler, atBeginning) 
      {
		var addedExistingEvents = false;
		var func;
		var guid = control.id + type;
		var isNewHandle = (!Handlers.hasOwnProperty(guid))
		var currentEvents = (!isNewHandle) ? (Handlers[guid]) : (new Array());
		
		//if isNewHandle, 
		//	get existing events for this control that have not been added using this function, 
		//  and add handler for each
		var evnt;
		if (isNewHandle)  {
			evnt = GetExistingHandler(control, type);
			if (!(!evnt)){
				if (typeof(evnt) == 'function') {
					func = evnt;
					addedExistingEvents = true;
				}
			}
		}
		//if no existing event handlers found, use passed handler as current function
		if (!func){
			func = new Function( handler );	
		}
		
		// if atBeginning - place handler at beginning of current elements array  
		//		else - place at end
		if (atBeginning) {
			var newA =  new Array();
			newA[0] = func	
			currentEvents = newA.concat(currentEvents)
		}else{
			currentEvents[currentEvents.length] = func;
		}
		
		//add current events to Handlers array
		Handlers[guid]= currentEvents;  
		//all handler functions must repsond to one event handler. 
		//	This adds the generic handler to the event the first time event added only
		if (isNewHandle) control["on" + type] = HandleEvent;
		//if existing events have been captured, add the passed event now.
		if (addedExistingEvents) AddHandler(control, type, handler, atBeginning)
		
	}
     
   
		function GetExistingHandler(control, type){
			var evtHandle;
			switch (type){
				case "abort" :
					evtHandle = control.onabort
					break
				case "blur" :
					evtHandle = control.onblur
					break
				case "change" :
					evtHandle = control.onchange
					break
				case "click" :
					evtHandle = control.onclick
					break
				case "dblclick" :
					evtHandle = control.ondblclick
					break
				case "error" :
					evtHandle = control.onerror
					break
				case "focus" :
					evtHandle = control.onfocus
					break
				case "keydown" :
					evtHandle = control.onkeydown
					break
				case "keypress" :
					evtHandle = control.onkeypress
					break
				case "keyup" :
					evtHandle = control.onkeyup
					break
				case "load" :
					evtHandle = control.onload
					break
				case "mousedown" :
					evtHandle = control.onmousedown
					break
				case "mousemove" :
					evtHandle = control.onmousemove
					break
				case "mouseout" :
					evtHandle = control.onmouseout
					break
				case "mouseover" :
					evtHandle = control.onmouseover
					break
				case "mouseup" :
					evtHandle = control.onmouseup
					break
				case "reset" :
					evtHandle = control.onreset
					break
				case "resize" :
					evtHandle = control.onresize
					break
				case "select" :
					evtHandle = control.onselect
				case "submit" :
					evtHandle = control.onsubmit
					break
				case "unload" :
					evtHandle = control.onunload
					break
				}
			return evtHandle;
		}

     function HandleEvent(event) {
		var returnValue = true;
    	if (!event) event = window.event; //if (navigator.appName.indexOf("Microsoft") != -1) event = window.event;
    	if (!event) return 
    
		var guid = this.id + event.type;
		var currentEvents = (Handlers.hasOwnProperty(guid)) ? (Handlers[guid]) : ("");
		//if event not added to Handlers
		if (currentEvents == "") return false
					
		for (i=0; i< currentEvents.length; i++){
			currentEvents[i]();
		}
		return false
	};
  
  
  
  //==============================================================
  
  //Timer Functions 
  var Timer_Period = 5 * 60000 //5 Minutes 

  function Set_Reload_Page_Timer(time)
  {
    Timer_Period = time * 60000;
    setTimeout('Timed_Reload_Page()',Timer_Period);
  }
	
  function Timed_Reload_Page()
  {
    setTimeout('Timed_Reload_Page()',Timer_Period);
    document.location.reload(true);	  
  }		
    
  function RedirectTimer(time, Target)
  {
    var callingfunc = "RedirectTo('" + Target + "')"
    setTimeout( callingfunc , time);
  } 
  
  function RedirectTo (Target)
  {
    window.location = Target;
  }  
  
  
  function disableRightClick(e)
  {
  var message = "Please view our legal pages about the use of images from this website.";
  
  if(!document.rightClickDisabled) // initialize
  {
    if(document.layers) 
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
    }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
  }
  if(document.layers || (document.getElementById && !document.all))
  {
    if (e.which==2||e.which==3)
    {
      alert(message);
      return false;
    }
  }
  else
  {
    alert(message);
    return false;
  }
}

function MaximiseWindow()
{
	top.window.moveTo(0,0); 
	if (document.all) 
		{top.window.resizeTo(screen.availWidth,screen.availHeight);} 
	else 
	if (document.layers || document.getElementById) 
	{ 
		if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth)
		{
			top.window.outerHeight = top.screen.availHeight; 
			top.window.outerWidth = top.screen.availWidth; 
		} 
	} 
}

function ClearCreditCardTextBoxOnCondition(textbox)
{
   if (textbox.value.indexOf('.') > 0) {
       textbox.value = '';
   }
}

