var showmenu = 0;
var hide_timer = 0;

function sMenu(id, action){
  window.status = id + ' a ' + action;
  // show specified element
  if (action=="show") {
    if(hide_timer) {
    	window.clearTimeout(hide_timer); hide_timer=0;
    }
    _hmenu();
    if (document.getElementById(id))
     $('#'+id).show();
  } else {
    if(showmenu==2) showmenu=1;
    else  if(!hide_timer) {
    	hide_timer=window.setTimeout('_hmenu()',500);
    }
    // hide all elements

  }
}


function hMenu(){
  window.status = "hide "+showmenu;
  if(showmenu==0 && !hide_timer) {
    hide_timer=window.setTimeout('_hmenu()',100); //this number defined speed to hide drop down menu after mouse out
  }
  else {
  	showmenu=0;
		window.setTimeout('hMenu()',100); //this number defined speed to hide drop down menu after mouse out
  }
}

function _hmenu() {
  window.status = "_hide";
  $("div.pagemenu").hide();
  hide_timer=0;
}

function chLang(obj) {
  location.href=obj.value;
}

function openTab(tabNum)
{s="tab"+tabNum;
 k="more"+tabNum;
 var dL=document.getElementById(s).style;
 if(!dL.display.length){
 	dL.display="none";
// 	if(str=='/clearplay_about')
	if (document.getElementById(k))
 		document.getElementById(k).innerText = 'Read more...';

            }
  else {
  	dL.display="";
//  	if(str=='/clearplay_about')
	if (document.getElementById(k))
		document.getElementById(k).innerText = 'Close';
  }
}

//scratch promotion
function ValidateFormScratch(){
	
	//alert(document.getElementById('email').value);
	 if(document.getElementById('realAcc').value == "")  {
	 alert("Please enter your account number!");
	 document.getElementById('realAcc').focus();
	 return false;
	}
	
	var str1=document.getElementById('realAcc').value;
	var regex = /[a-zA-Z0-9]$/;
	if(!regex.test(str1))
	{	alert("Invalid Account Number. Please check and try again.");
		document.getElementById('realAcc').focus();
		return false;
	}

	 if(document.getElementById('realEmail').value == "") {
		 alert("Please enter your email!");
		 document.getElementById('realEmail').focus();
		 return false;
	}
	var str=document.getElementById('realEmail').value;
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	if(!regex.test(str))
	{	alert("Email not valid, Please try again!");
		document.getElementById('realEmail').focus();
		return false;
	}
		
	return true;
}

function checkUrl(href) {
//leaving = ((href.indexOf("://") > -1) || (href.indexOf("www.") > -1));
leaving = (((href.indexOf("://") > -1) || (href.indexOf("www.") > -1)) && (href.indexOf(window.location.host) == -1));
//alert(leaving + " " + window.location.host);
return leaving;
// add in more things to include in the line above as you see fit
}

//PopUp on Exit
var needPopup = 1;
function confirm_exit(){
		
	//if(checkUrl(location.href))
	//alert("Exiting");
	if(needPopup == 1)
	{
	  //open('exit_popup.html','WindowName','toolbar=0,directories=0,menubar=0,scrollbars=0,resizable=0,width=310,height=210');
	  //alert("You have chosen to close this window");
	    if (confirm("Hit the jackpot at All Jackpots!")) {
	      window.open("http://www.alljackpotscasino.com");
		  self.close();
	    }
	    else
	    	self.close();          	
	}  
	  
}
//End popup 

function Get_Cookie( check_name ) {
        // first we'll split this cookie up into name/value pairs
        // note: document.cookie only returns name=value, not the other components
        var a_all_cookies = document.cookie.split( ';' );
        var a_temp_cookie = '';
        var cookie_name = '';
        var cookie_value = '';
        var b_cookie_found = false; // set boolean t/f default f

        for ( i = 0; i < a_all_cookies.length; i++ )
        {
               // now we'll split apart each name=value pair
               a_temp_cookie = a_all_cookies[i].split( '=' );


               // and trim left/right whitespace while we're at it
               cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

               // if the extracted name matches passed check_name
               if ( cookie_name == check_name )
               {
                       b_cookie_found = true;
                       // we need to handle case where cookie has no value but exists (no = sign, that is):
                       if ( a_temp_cookie.length > 1 )
                       {
                               cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
                       }
                       // note that in cases where cookie is initialized but no value, null is returned
                       return cookie_value;
                       break;
               }
               a_temp_cookie = null;
               cookie_name = '';
        }
        if ( !b_cookie_found )
        {
               return '';
        }
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it’s in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires ){
expires = expires * 1000 * 60 * 60 * 24;
}


var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + '=' + escape( value ) +
( ( expires ) ? ';expires=' + expires_date.toGMTString() : '' ) +
( ( path ) ? ';path=' + path : '' ) +
( ( domain ) ? ';domain=' + domain : '' ) +
( ( secure ) ? ';secure' : '' );

}

function Login(){
  var pnumber=Get_Cookie("msisdn");
	var ppass=Get_Cookie("pincode");
	
	if(pnumber)
	   document.getElementById("Loginname").value = pnumber;
	   
	if(ppass)
	   document.getElementById("Password").value = ppass;
		
 	document.getElementById('form').submit();
 }




