//
//  These are old functions created by AZ
//
	/* script to set form selected index */
	function formSelectIndex(formName,id,indexValue) {
	   document.forms[formName][id].selectedIndex = indexValue;	 							
	}

	
	/* script to make login button default */
	function keyHandler(e) {
		//alert(2)
		var key = document.all? window.event.keyCode:e.which;
		if(key == 13){
		if(document.all){
			if(event.srcElement){
				if(event.srcElement.id=="topsearch" ||event.srcElement.id=="inUserName" || event.srcElement.id=="inUserPass"  ){
					return true;
				}
				if(event.srcElement.id=="m_Deposit_Amount" || event.srcElement.id=="m_ChangeGOCode"){
				
					return false;
				}
				
				if(event.srcElement.tagName.toLowerCase()=='textarea'){
					return true;
				}
				
				
				
			}
			
			
			
			
			
			
			
		}else{
			if(e.target){
			
				if(e.target.id=="topsearch" || e.target.id=="inUserName" || e.target.id=="inUserPass"){
					return true;
				}
				if(e.target.id=="m_Deposit_Amount" || e.target.id=="m_ChangeGOCode" ){
				
					return false;
				}
				if(e.target.tagName.toLowerCase()=='textarea'){
					return true;
				}
				
				
				
			}
			
		}
	
			if(document.links){
				
				for(i=0;i<document.links.length;i++){
					id=document.links[i].id
					if(id.indexOf("@DEFAULT")>0){	
						
						return document.links[i].onclick();
					}
				}	
			}
			
			
			return false;
		}
		return true;	
	}
		
	document.onkeypress = keyHandler;	
	if (document.layers) document.captureEvents(Event.KEYPRESS);
	
    /* function for focusing on the first input field of the form */		
	function putFocus(formInst, elementInst) {
		if(document.forms["ActionForm"] && 
			document.forms["ActionForm"].elements["inUserName"] ){
				document.forms["ActionForm"].elements["inUserName"].focus();			
		}
		else if(document.forms[formInst]&& 
			document.forms[formInst].elements[elementInst]){	  		
	   			document.forms[formInst].elements[elementInst].focus();	  		
	  	}
 	}


	var ie4 = (document.all) ? true : false;
	var ns4 = (document.layers) ? true : false;
	var ns6 = (document.getElementById && !document.all) ? true : false;
	function hidelayer(lay) {
	if (ie4) {document.all[lay].style.visibility = "hidden";}
	if (ns4) {document.layers[lay].visibility = "hide";}
	if (ns6) {document.getElementById([lay]).style.display = "none";}
	}
	function showlayer(lay) {
	if (ie4) {document.all[lay].style.visibility = "visible";}
	if (ns4) {document.layers[lay].visibility = "show";}
	if (ns6) {document.getElementById([lay]).style.display = "block";}
	}
	
	/* function to change states display based on the country */
	function createOption(f,e,newValue,newText){
		var objSelect=document.forms[f].elements[e];
		var objOption = document.createElement("option");
		objOption.text = newText;
		objOption.value = newValue;
		if(document.all && !window.opera){
			objSelect.add(objOption);
		}else{
			objSelect.add(objOption, null);
		}
	}
	
	function clearSelect(f,e){
		var objSelect=document.forms[f].elements[e];
		while(objSelect.options.length > 0){
			objSelect.remove(0);
		}
		return objSelect;
		}
	
	

	 
	 /**
	 * Sets a Cookie with the given name and value.
	 *
	 * name       Name of the cookie
	 * value      Value of the cookie
	 * [expires]  Expiration date of the cookie (default: end of current session)
	 * [path]     Path where the cookie is valid (default: path of calling document)
	 * [domain]   Domain where the cookie is valid
	 *              (default: domain of calling document)
	 * [secure]   Boolean value indicating if the cookie transmission requires a
	 *              secure transmission
	 */
	 
	function setCookie(name, value, expires, path, domain, secure)
	{
	    document.cookie= name + "=" + encodeURIComponent(value) +
	        ((expires) ? "; expires=" + expires.toGMTString() : "") +
	        ((path) ? "; path=" + path : "") +
	        ((domain) ? "; domain=" + domain : "") +
	        ((secure) ? "; secure" : "");
	}

	
	/**
	 * Gets the value of the specified cookie.
	 *
	 * name  Name of the desired cookie.
	 *
	 * Returns a string containing value of specified cookie,
	 *   or null if cookie does not exist.
	 */
	 
	function getCookie(name)
	{
	    var dc = document.cookie;
	    var prefix = name + "=";
	    var begin = dc.indexOf("; " + prefix);
	    if (begin == -1)
	    {
	        begin = dc.indexOf(prefix);
	        if (begin != 0)
	        return null;
	    }
	    else
	    {
	        begin += 2;
	    }
	    var end = document.cookie.indexOf(";", begin);
	    if (end == -1)
	    {
	        end = dc.length;
	    }
	    return unescape(dc.substring(begin + prefix.length, end));
	}
		
			
	/* function to modify text link style */
	
	function getTargetElement(evt) {
  		var elem;
		if (evt.target) {
			elem = (evt.target.nodeType == 3) ? evt.target.parentNode : evt.target;
		} else {
		    elem = evt.srcElement;
		  }
		return elem;
	}
	
	function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
	
	function setCookieForPeriod(name, value, expires, path, domain, secure){
		var expdate = new Date ();
		expdate.setTime (expdate.getTime() + expires); 
		setCookie(name, value, expdate, path, domain, secure)
	}
	
	function setNickNameCookie(name, domain){
		
		setCookieForPeriod("nickname", name, 1000*60*60*24*90,"/", domain);
	
	}
	
	function setMoolaNoExpireCookie(name, value, domain){
		
		setCookieForPeriod(name, value, 1000*60*60*24*365,"/", domain);
	
	}
	
	
