// JavaScript Document
$(function() {

	/*CALENDAR*/
	$("a#foxydiary, a.fbdiary").colorbox({width:"999px", height:"750px", iframe:true, opacity: "0.5"});	
	
	/* YOU TUBE LIGHTBOX*/
	$("a.youtube_lightbox").colorbox({iframe:true, innerWidth:640, innerHeight:385}); 
	
	/*POPUP BEHAVIOURS*/
	$("a.popup").click(function(e) { 
		e.preventDefault();
		var $this = $(this);
		var properties;
		
		/*MEGA GUARANTEED JACKPOT*/
		if ($this.attr("id")=="megaguaranteed") 
		{
			properties = "toolbar=0,location=0,left=0,top=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=820,height=800";
			
		}
		
		window.open($this.attr("href"),"",properties); 
	});
	
	/*CONTACT FORM*/
	$(".send-contact-email").livequery(function(){
		$(".send-contact-email").click(function(e) {
			e.preventDefault();
			var $this = $(this);
			//var type;
			var type = $this.attr("id").replace(/^send-/,'');
			//console.log(type);
			var selectval = $("#"+type+"-team .field_subject").fieldValue();
			//console.log(selectval[0]);
			$("#email-feedback").load("/pop/help/sendemail.php",
				{
					type: type,
					name : $("#"+type+"-team .field_name").val(),
					email: $("#"+type+"-team .field_email").val(),
					email_confirm: $("#"+type+"-team .field_email_confirm").val(),
					alias: $("#"+type+"-team .field_alias").val(),
					querytype: selectval[0],
					query: $("#"+type+"-team .field_message").val(),
					refer: $("#"+type+"-team .refer").val(),
					sitename: $("#"+type+"-team .sitename").val()
				}
			);
			$("#email-forms").empty();
		});
	});
	
});
/* Timed Content 
---------------------------*/

function getTime()
{
var d = new Date();
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
return weekday[d.getDay()];
}

function timed(dir,div,override,includepath,playerClass)
{
	var sPath = window.location.pathname;
//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
 	//if (sPage=="main.php" || sPage=="") dir = dir.replace(/^./,"");
	//alert(dir);
	var today;
	if (override=="")today = getTime();
	else today = override;
	$(div).load("../include/timed/timed_function.php?day="+today+"&dir="+dir+"&includepath="+includepath+"&playerClass="+playerClass);
	
}


/* Display Calendar Picker
-----------------------------------*/
	function formSubmitIntercept(sender, event){
		if (event && event.keyCode == 13) {
		datePickerClosed(sender);
		return false;
		}
	}
	function datePickerClosed(dateField){
		(valDate(dateField));
		go(dateField.attributes["formAction"].value,false);			
	} 
	function GameDetail(gameID){
			document.mainForm.gameID.value = gameID;
			go('MYGAMEDETAIL', false, 'mygamesdetail.php');
	}

/* Curfon fonts declarations 
---------------------------------*/
Cufon.DOM.ready(function() {
  Cufon.replace(".page-header span", {fontFamily: "Marketing Script"});    
	Cufon.replace("#section-header, .inner-content h2, .sub-header, .inner-content h3, #foxysynopsis h2", {fontFamily: "VAGRounded"});
	Cufon.replace("#loginfrm label, .label-name, #loginfrm a, .playermsg, #subnav-container p, #closelink, #bottom-edge p, #today-message h2, #today-message h3, .newsletterlinks", {fontFamily: "VAGRounded"});
	Cufon.replace(".input-row label, #forgotlink, #registerlink, #morelink, #display-subnav a, #member-subnav p, #member-subnav li a", {fontFamily: "VAGRounded"});
	Cufon.replace("#navbar li a",{hover:true , fontFamily: "VAGRounded"});
});

/* jquery call to libraries functions
----------------------------------------*/

$(document).ready(function ()
{
	
	var $atozlinks = $(".content-section");
	var $archivenews = $("#newsletterpg .content-section ");
	$archivenews.hide();
    // atozlinks.hide().filter(":first").show();
     $(".intro-links a").click(function (e) {
     	  e.preventDefault();
        $atozlinks.hide();
        $atozlinks.filter(this.hash).show();
        $(".intro-links a").removeClass("selected");
        $(this).addClass("selected");
      return false;
   }).filter(":first").click();
   
   $(".newsletterlinks a").click(function (e) {
   	e.preventDefault();
   	$archivenews.hide();
        $atozlinks.filter(this.hash).show();
        $(".newsletterlinks a").removeClass("selected");
        $(this).addClass("selected");
        $archivenews.insertAfter($(this));
   	 return false;
   }).filter(".content-section:first").click();	
   
       
   // set page-headers
   $(".page-header > span").css("padding-top","38px");
   $("#section-header > span").css("padding-top","0");
   
   $(".facebook-refer").click(function(e) {
		e.preventDefault();								   
	});
	
	/* style tables */
   $(".tbl_content tr > td:first-child").addClass("first");
   $(".tbl_content tr  td:last-child").addClass("last");
	 $("<div class=bottomtbl><!-- --></div>").insertAfter($(".tbl_content"));
  
    
  	showhideNav();
  
});
function showhideNav(){
	$("#display-subnav").hide();
	$("#morelink").click(function(){
  	$("#display-subnav").slideToggle("slow"); 
  	$(this).toggleClass("active").css("visibility","hidden");
  	return false; 
  });
  
 $("#closelink").click(function(){
  	 $("#display-subnav").slideToggle("slow");
  	 $(this).toggleClass("active");
  	 $("#morelink").css("visibility","visible");
  	 return false;
  });
 }
/*function showhideNav(){
	$("#display-subnav").hide();
    
  $("#morelink").click(function() {
    $("#display-subnav").slideDown("slow");
    //$("#morelink").hide();
    return false;
  });
  
  $("#closelink").click(function(){
  	$("#display-subnav").slideUp("slow");
  	return false;
	});
}*/


/* Open new window functions - LEGACY FUNCTIONS NOT SURE IF IN USE STILL
------------------------------------------------------------------------ */
function newWindow(theURL,winName,features) { //v2.0 replaces name 'MM_openBrWindow'
  window.open(theURL,winName,features);
}

function playRoom(iRoomID){
   playWin = window.open("/skin/play.php?room=" + iRoomID, "playWin", "height="+screen.height-2+",width="+screen.width-2+",screenY=1,screenX=1,resizable");
}
	
function advent(){
		var $i = window.open('/skin/promotions/advent/advent_calendar.html',"advent","toolbar=0,top=0,left=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=770,height=585");
}
	
function howtoplay(){
	window.open('/skin/howtoplay.php',"game","toolbar=0,location=0,left=0,top=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=720,height=520"); 
}

function expand() {
	styleObj = document.getElementById('playertop').style;
  styleObj.display = 'inline';
}

function megajackpots(){
		window.open('/skin/games/coverall/guaranteed-schedule.php',"guaranteeds","toolbar=0,location=0,left=0,top=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=820,height=800"); 
}

function megajackpots_ball(){
window.open('/skin/games/coverall/guaranteed-schedule-ball.php',"guaranteeds","toolbar=0,location=0,left=0,top=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=820,height=750"); 
}