// JavaScript Document

/*CONTACT FORM*/
$(function() {

     /* YouTube popup */
     $("#advertlink").colorbox({iframe:true, innerWidth:640, innerHeight:385});
     $("#eawlink").colorbox({iframe:true, innerWidth:480, innerHeight:255});


	$(".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("../include/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,url)
{
	var urlmatch, path;

        urlmatch = url.search("main.php");
	//if (urlmatch==1) path= '/include/timed/';	//there is a match
	//else
	path = '/include/timed/';
	/*if (jQuery.browser.mozilla) console.log("ajax call: "+path+"timed_function.php?day="+today+"&dir="+dir+"&includepath="+includepath+"&playerClass="+playerClass);*/
	//alert(dir);
	var today;
	if (override=="")today = getTime();
	else today = override;

	$(div).load(path+"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(".inner-content h1, h2, #content h3, .actionbtns h1, #display-date, #notamember, #loginfrm label, .toplinks, .label-name, #tag p, #or, .account-help, #lottojackpot p ", {fontFamily: "Cocon"});
 Cufon.replace("#nav li a, .trigger a",{hover:true , fontFamily: "Cocon"});
 Cufon.replace("#jackpotfigure",{color:'-linear-gradient( #ed1c24,#f5aa1d)' , fontFamily: "Cocon"});
});

/* jquery call to libraries functions
----------------------------------------*/

$(document).ready(function ()
{
 $("#nav li:last").addClass("last");
 $("#bottom-nav li:last").addClass("last");
 $(".displaybalance li:last").addClass("last");

    /* Accordion */
    $(".trigger:first").addClass("active");
	$(".display-sections .block:not(:first)").hide();
	$(".trigger").click(function(e){
          e.preventDefault();
	  $(this).next(".block").slideToggle("slow")
	  .siblings(".block:visible").slideUp("slow");
	  $(this).toggleClass("active");
	  $(this).siblings(".trigger").removeClass("active");
	});
        
});


/* Open rooms */

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");
}
