

/* iframe embed removed for now

// Hangle iframe issues.
if (_iframeEmbed){
	// The server thinks we are embedded - if we are not then we must force the page to breakout.
	if (window.parent.frames.length == 0){
		window.location.href="/logoff";
	}
} else {
	// if the server thinks we are not embedded but we are then we must force embedding
	if (window.parent.frames.length > 0){
		window.location.href="/?e=true";
	}
}

*/



function grValidator_mail(address){
     var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; 
   if(reg.test(address) == false) {
      //alert('Invalid Email Address');
      return false;
   }
      return true;
}


function cleanInput(element)
{
	if($(element).val() == "Email")
		$(element).val("");
}
function loginAndReturn()
{
	var _data = [];
	var email = $('#dropdown_login').val();
	var password = $('#password__').val();
	var remember = $('#remember_me').attr("checked");
	_data = "email="+email;
	_data += "&p="+password;
	_data += "&remember_me="+remember;
	_data += "&return=1";
	
	$.ajax({
		type: 	'POST',
		url: 	'/login.php',
		data:	_data,
		success : function (html){
			if(html == "error")
			{
				/*$('#notify_content').html("The email address or password you typed is incorrect.<br/><br/>
If you have forgotten your Goalrun password you should click the 'Forgot your password?' link that can be found on the left hand side");
				modal_base.init("error", "Notification", "#notification", "OK",tryAgain);*/
				tryAgain();
				
			}
			else
			{
				if(location.href.indexOf('login') >= 0 || location.href.indexOf('join') >= 0)
					location.href = "/index";
				else
					location.href=location.href;
			}
 			return;
		}
	});
}
function toggleLoginDropdown()
{
	$("#login_dropdown").slideToggle('normal');	
}

function removeProfileImage(){
	if (confirm("Are you sure you wish to remove this image?")){
		location.href="/scripts.php?script=remove_profile_image";
	}
}


function removeProfileImageBeta(){
	if (confirm("Are you sure you wish to remove this image?")){
		location.href="/scripts.php?script=remove_profile_image_beta";
	}
}

function logoff(){
	document.location.href="/logoff.php";
}

function resendActivation(email){ 
       	$.ajax({
		type: 	'POST',
		url: 	'scripts.php?script=resend_activation',
		success: function(html){
			$('#notify_content').html("A re-activation link has been sent to the following email address: <br/>"+email);
			modal_base.init("error", "Re-activation request sent", "#notification", "OK");
		}
	});
}

function resendActivationMitoo(email){ 
	_data = "mitoo=true";
    
	$.ajax({
		type: 	'POST',
		url: 	'scripts.php?script=resend_activation',
		data:	_data,
		success: function(html){
			$('#notify_content').html("A re-activation link has been sent to the following email address: <br/>"+email);
			modal_base.init("error", "Re-activation request sent", "#notification", "OK");
		}
	});
}

var genMod;
var acctMod;
function createFixedModal(elementId){
	/* Create a modal dialog to show embed & RSS suggestions */
	genMod = new modalDialog({width:'550', height:'380', center:true, border:0, transparent:true});
	genMod.setHTML($(elementId).html());
	genMod.show(true);
	hideAdvert();
	
};

function createDynamicModal(_html){
	genMod = new modalDialog({width:'550', height:'380', center:true, border:0, transparent:true});
	genMod.setHTML(_html);
	genMod.show(true);
	hideAdvert();
};

function createAcctModal(elementId){
	acctMod = new modalDialog({width:'550', height:'230', center:true, border:0, transparent:true});
	acctMod.setHTML($(elementId).html());
	acctMod.show(true);
	hideAdvert();
};

function createClaimModal(elementId){
	acctMod = new modalDialog({width:'550', height:'317', center:true, border:0, transparent:true});
	acctMod.setHTML($(elementId).html());
	acctMod.show(true);
	hideAdvert();
};

function hideAdvert(){
	$('#advert_container').css("visibility", "hidden");
	$('#flashcontent').css("visibility", "hidden");
	$("embed").hide();
};

function showAdvert(){
	$('#advert_container').css("visibility", "visible");
	$('#flashcontent').css("visibility", "visible");
	$("embed").show();
};

function sendSearch(){
	document.location.href="/search?query="+$('#query').val()+"&catOnly="+$('#catOnly').val();	
};
// TOggle the news

function toggleNews(_key){
	var _style = $('#row_'+_key).css("display");
	$('#row_'+_key).slideToggle();
	
	if (_style == "none"){
		// About to expand - change to text close
		$('#open_'+_key).css("display","none");
		$('#closed_'+_key).css("display","inline");
		
	} else {
		// About to close - change to text open	
		$('#open_'+_key).css("display","inline");
		$('#closed_'+_key).css("display","none");
	}
};

function toggleLeague(_key){
	var _style = $('#table_'+_key).css("display");
	$('#table_'+_key).slideToggle();
	
	if (_style == "none"){
		// About to expand - change to text close
		$('#lopen_'+_key).css("display","none");
		$('#lclosed_'+_key).css("display","inline");
		
	} else {
		// About to close - change to text open	
		$('#lopen_'+_key).css("display","inline");
		$('#lclosed_'+_key).css("display","none");
	}
};

var debug = false;//true;

function debugLog(text){
	if (debug){
		console.log(text);
	}
};

function registerAlert(){
	alert("You must register and login to use this functionality");
};

function stopBubble(e){
	e = e || window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
};

function testForObject(Id){
	return document.getElementById(Id)?true:false;
};

function tag(tag) {
	return document.getElementsByTagName(tag).item(0);
};

function createCookie(name,value,days)	{
	if (days)	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
};

function readCookie(name)	{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
};

function eraseCookie(name)	{
	this.createCookie(name,"",-1);
};

function setLoggedRequestValues(info) {
	$('#facebox').find('#facebox_logBox').hide();
	$('#facebox').find('#user_info').show();
	$('#facebox').find('#name').val(info[0]);
	$('#facebox').find('#source_email').val(info[1]);
	$('#facebox').find('#name_league').val(info[0]);
	$('#facebox').find('#email_league').val(info[1]);
};

function sendLoginForm(){
	var _data = $('#facebox').find('#login_form').serialize();	
	$.ajax({
		type: 	'POST',
		url: 	'/login.php',
		data:	_data,
		success : function (){
			var url = location.href;
            //alert(_data);
				location.href=location.href;
		//	if( (url).substr(-1,1) != "/")
 			//	location.href=location.href+"login?check=1";
		//	else
			//	location.href=location.href;
 			return;
		}
	});
};

function clubFaceboxLogin()
{
	var _data = $('#facebox').find('#club_request').serialize();
	faceboxLogin(_data);
	return false;
};
function leagueFaceboxLogin()
{
	var _data = $('#facebox').find('#league_request').serialize();
	faceboxLogin(_data);
	return false;
};

function faceboxLogin(_data){
	//var _data = $('#facebox').find('#club_request').serialize();
	$("#facebox").css("cursor","wait");
	$("#facebox").find(".CallToActionbtn").css("background-color","#DDDDDD");
	
	//alert(_data.toSource()); return;
	$.ajax({
		type: 	'POST',
		url: 	'/login.php',
		data:	_data,
		success : function (html)
					{
						$("#facebox").find(".CallToActionbtn").css("background-color","#FF3300");
						$("#facebox").css("cursor","default");
						if(html)
						{
							var info = html.split('#');
							setLoggedRequestValues(info);							
						}
						else
						{
							$("#facebox").find("#facebox_login_error_msg").html("The email address or password you typed is incorrect.");	
						}
					}
	});
};
function validateJoinRequiredFields()
{
	if( $('#facebox').find('#reg_forename').val() == "" || $('#facebox').find('#reg_surname').val() == "" || $('#facebox').find('#user_email').val() == "" || $('#facebox').find('#reg_passwd__').val() == "" || $('#facebox').find('#user_repassword').val() == "")
	{
		alert("Please fill all fields to complete your registration.");
		return false;
	}
	if($('#facebox').find('#dob_day').val() == "" || $('#facebox').find('#dob_month').val() == "" || $('#facebox').find('#dob_year').val() == "")
	{
		alert("Please fill all fields to complete your registration.");
		return false;
	}
		
	return true;
};
function clubFaceboxJoin()
{
	var _data = $('#facebox').find('#club_request').serialize();	
	faceboxJoin(_data);
	return false;
};
function leagueFaceboxJoin()
{
	var _data = $('#facebox').find('#league_request').serialize();	
	faceboxJoin(_data);
	return false;
};
function faceboxJoin(_data){
	if(!validateJoinRequiredFields())
		return false;
	if(!checkAge())
		return false;
	//var _data = $('#facebox').find('#club_request').serialize();
	$("#facebox").css("cursor","wait");
	$("#facebox").find(".CallToActionbtn").css("background-color","#DDDDDD");
	//alert(_data);
	//alert(_data.toSource()); return;
	$.ajax({
		type: 	'POST',
		url: 	'/join.php',
		data:	_data,
		success : function (html)
					{
						//alert(html);
						$("#facebox").find(".CallToActionbtn").css("background-color","#FF3300");
						$("#facebox").css("cursor","default");
						if(html)
						{
							var info = html.split('#');
							//alert(info);
							if(info.length > 1 )
							{								
								var email = $('#facebox').find('#user_email');
								var password = $('#facebox').find('#reg_passwd__');
								//alert(email+" "+password);
								$.ajax({
									type: 	'POST',
									url: 	'/login.php?email='+email+'&p='+password,
									data:	_data,
									success : function (html)
										{ 
											//alert("logged");
											setLoggedRequestValues(info); 										
										}
									});
							}
							else
								$("#facebox").find("#facebox_join_error_msg").html(html);
						}						
					}
	});
};
/*Request a club!*/
function requestClub(){		
		if($('#facebox').find('#source_email').val() == "")
		{
			alert("To request your free site please Log in or Join goalrun first");
			return false;
		}
		if($('#facebox').find('#nameOfClub').val() == "")
		{
			alert("Please enter the name of the club.");
			return false;
		}
		/*if($('#facebox').find('#asociation').val() == "0")
		{
			alert("Please fill all fields.");
			return false;
		}*/
		//getting required info from the user submitted form
		var _name 		= $('#facebox').find('#name').val();
		var _email 		= $('#facebox').find('#source_email').val();
		var _nameOfClub 	= $('#facebox').find('#nameOfClub').val();
		var _officialSite 		= $("input[name='official_site']:checked").val();
		var _exists_mitoo 		= $("input[name='exists_mitoo']:checked").val();
		var _colour 		= $('#facebox').find('#colour').val();
		var _sponsor 		= $('#facebox').find('#sponsor').val();
		var _referer 		= $('#facebox').find('#referer').val();
		var _club_league 		= $('#facebox').find('#club_league').val();
		var _club_association 		= $('#facebox').find('#association').val();
				
		$.ajax({
			type: 	'POST',
			url: 	'scripts.php?script=clubRequest',
			data:	'request='+_name+'&email='+_email+'&nameOfClub='+_nameOfClub+'&officialSite='+_officialSite+'&exists_mitoo='+_exists_mitoo+'&colour='+_colour+'&sponsor='+_sponsor+'&club_league='+_club_league+'&referer='+_referer+'&referer='+_referer+"&association="+_club_association,
			success: function(html)
			{
				$('#notify_content').html("Great! We can't wait to see your FREE club/ league site on Goalrun.<br/>One of the Goalrun Team will be in touch to discuss the options within 48 hours.<br/><br/>Thank you!");
				modal_base.init("error", "Request sent", "#notification", "OK");
			}
		});
		
	};
/*End of request a club*/

/*Request a league!*/
function requestLeague(){
		if($('#facebox').find('#email_league').val() == "")
		{
			alert("To request your free site please Log in or Join goalrun first");
			return false;
		}
		if($('#facebox').find('#nameOfLeague').val() == "")
		{
			alert("Please enter the name of the league.");
			return false;
		}
		//getting required info from the user submitted form
		var _name_league 			= $('#facebox').find('#name_league').val();
		var _email_league 			= $('#facebox').find('#email_league').val();
		var _nameOfLeague 			= $('#facebox').find('#nameOfLeague').val();
		var _officialSite_league	= $("input[name='official_site_league']:checked").val();
		var _exists_mitoo_league 	= $("input[name='exists_mitoo_league']:checked").val();
		var _colour_league 			= $('#facebox').find('#colour_league').val();
		var _sponsor_league 		= $('#facebox').find('#sponsor_league').val();
		var _referer 				= $('#facebox').find('#referer_league').val();
		var _league_association 		= $('#facebox').find('#association').val();
				
		$.ajax({
			type: 	'POST',
			url: 	'scripts.php?script=leagueRequest',
			data:	'request_league='+_name_league+'&email_league='+_email_league+'&nameOfLeague='+_nameOfLeague+'&officialSite_league='+_officialSite_league+'&exists_mitoo_league='+_exists_mitoo_league+'&colour_league='+_colour_league+'&sponsor_league='+_sponsor_league+'&referer_league='+_referer+"&association="+_league_association,
			success: function(html)
			{
				$('#notify_content').html("Thanks for your request, we aim to get in touch within 24hrs. The goalrun team");
				modal_base.init("error", "Notification", "#notification", "OK");
			}
		});
		
	};
/*End of request a league*/

function grid_overlay(){
	$( function () {
		$('#notify_content').html($('#overlayGrid').html());
				modal_base.init("error", "Grid View", "#notification", "Close","Ok","");
					$('#facebox').css("width", "100%");
					$('#facebox').css("left", "5%");
					$('#facebox').find('table').css("width", "90%");
	});
};

function showLoginModal(){
	$( function () {
		$('#notify_content').html($('#pre_login').html());
        	$('#facebox').width("600");
				$('#facebox').height("300");
				modal_base.init("error", "Login to continue", "#notification", "Login", sendLoginForm, "", 1);
			
	});
};
function registerToSupportClub(){
	$( function () {
		$('#notify_content').html($('#pre_login').html());
		$('#notify_content').find("#login_modal_body_text").html("Login or Register and become a supporter of this club today!");
		modal_base.init("error", "Login to continue", "#notification", "Login", sendLoginForm, "", 1);
		

	});
}
function passwordChangeStatus(){
	$('#notify_content').html($('#password_change_success_message').html());
	//$('#notify_content').find("#login_modal_body_text").html("Login or Register and become a supporter of this club today!");
	modal_base.init("error", "Notification", "#notification", "OK", goToSettings, "", 1);
}


function showRequestPageModal(type){
	$( function () 
	{
		var title = '<span class="facebox_mixed_title">' + type + ' website request </span>';				
		var titleImage = ' <img src="/themes/goalrun/images/gr3_1/icons/header_clubs.png" style="margin-top:-5px;"/> ';
		
		if(type.toLowerCase() == "league")
			titleImage = ' <img src="/themes/goalrun/images/gr3_1/icons/header_leagues.png" style="margin-top:-5px;"/> ';
		
		title = "<div>" + titleImage + title + "</div>";
		
		var templateForm =  "#requestClub";
		if(type.toLowerCase() == "league")
			templateForm =  "#requestLeague";
		
		$('#notify_content').html($('#requestClub').html());
		
		modal_base.init("error", title, templateForm, "Submit", "", "", "no action");
		
	});
	return false
};
/* Autocompleter code */
function rc_formatItem(row) {
	return row[0];
};

function rc_formatResult(row) {
	return row[0].replace(/(<.+?>)/gi, '');
};
/*
 * autocompleter for edit
 */
function faceboxRegClubAutoCompleter(_elem, _id, _key) {
	
	var elem = $('#facebox').find(_elem);
	elem.autocomplete('scripts.php?script=predictiveSearch&cat=club', {
		width :290,
		max :50,
		minChars :2,
		cacheLength :0,
		multiple :false,
		matchContains :false,
		formatItem :rc_formatItem,
		formatResult :rc_formatResult
	});

	elem.result( function(event, data, formatted) {
		var _name 	= data[0];
		var _type 	= data[1];
		var _id 	= data[2];
		/* populate dropdown */
		if (_id){
			$('#facebox').find('#club_id').val(_id);
			faceboxRegFindTeams(_id);
		}
		//console.log(data);
		
		elem.keyup(function(me) {
			faceboxRegFindTeams(0);
	    });

	});
};
/* 
 * Get the team dropdown for the selected club  
 */
function faceboxRegFindTeams(_id){
	$.ajax({
		type: 	'POST',
		url: 	'scripts.php?script=getClubTeams',
		data:	'club_id='+_id,
		success: function(html){
			$('#facebox').find('#team_selector').html(html);
		}
	});
};
function validEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
//	}

		/*
	return (email.indexOf(".") > 2) && (email.indexOf("@") > 0);

	
var filter = '/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/';
	if (!filter.test(email.value)) 
	{
		alert('Please provide a valid email address');
		return false;
	}
	return true;*/
}
function checkAge()
{
	/* the minumum age you want to allow in */
	var min_age 		= 13;
	var youthEndAge 	= 18;
	var year 			= parseInt($('#facebox').find('#dob_year').val()); 
	var month 			= parseInt($('#facebox').find('#dob_month').val() - 1); 
	var day 			= parseInt($('#facebox').find('#dob_day').val()); 
	var theirDate 		= new Date((year + min_age), month, day);	
	var today 			= new Date();
	var isYouth 		= (today.getTime() - new Date((year + youthEndAge), month, day) < 0) ? 1:0;
	
//	var year 			= $('#dob_year').val(); 
//	var month 			= $('#dob_month').val(); 
//	var day 			= $('#dob_day').val(); 
    

	if(year == "" || month == "" || day == "")
	{
		$('#notify_content').html("<div style='text-align:left'>" + "- Please select your date of date of birth." + "</div>");
		modal_base.init("error", "Please review your registration", "#notification", "OK");	
	}
	
	
	if ( !theirDate.getTime() || (today.getTime() - theirDate.getTime()) < 0) { 
		//$('#notify_content').html("<div style='text-align:left'> Goalrun does not knowingly collect or solicit personal information from anyone under the age of 13 or knowingly allow such persons to register. If you are under 13, please do not attempt to register or send any information about yourself to us, including your name, address, telephone number or email address. No one under the age of 13 may provide any personal information to or on Goalrun. In the event that we learn that we have collected personal information from a child under the age of 13 without verification of parental consent, we will delete that information as quickly as possible. If you believe that we might have any information from or about a child under the age of 13, please contact us through the Site Feedback Button at the bottom of the page.</div>");
        $('#notify_content').html("<div style='text-align:left'> Goalrun does not knowingly collect or solicit personal information. <br/>Persons under the age of 13 should not attempt to register with the site or send any information without prior parental consent. <br/>For more information click to see a full breakdown of <a href='/legal?privacy'>Goalrun site policy</a>.</div>");
		modal_base.init("error", "Children aged under 13", "#notification", "Explore", exploreNow);
		return false;
	}
	
	if (isYouth) {
		alert("We recommend that minors 13 years of age or older ask their parents for permission before sending any information about themselves to anyone over the Internet.");		
	}
	
	return true;
};
function roundCorners(id,radius)
{
    var defaultRadius = '10px';
    if(id != 'undefined' && id != null)
    {
        if(radius != 'undefined' && radius != null)
            $(id).corner(radius);
        else
            $(id).corner(defaultRadius);
            
    }else{
        
       // alert("rounding corners");
        $('.profile_left').corner('top '+defaultRadius);
        $('.profile_tabbedBox').corner('top '+defaultRadius);
        $('.tier2Tab').corner('top '+defaultRadius);
        $('.secundaryRightProfileWraper').corner('top '+defaultRadius);
       
    }
    //$('.jqTransformSelectWrapper').corner()
}

function setClubMasterCache(club_id,module)
{    
    $.ajax({
			type: 	'POST',
			url: 	'scripts.php?script=clubMasterCache',
			data:	'cid='+club_id+"&module="+module,
			success: function(html){
					//alert(html);			
			}
		});

}
function setTeamMasterCache(club_id,team_id,module)
{    
    $.ajax({
			type: 	'POST',
			url: 	'scripts.php?script=teamMasterCache',
			data:	'cid='+club_id+"&tid="+team_id+"&module="+module,
			success: function(html){
					//alert(html);			
			}
		});

}
function setLeagueMasterCache(league_id,all,division_id)
{
    var division = 0;
    if(all != 1 && division_id != 'undefined' && division_id != null)
        division = division_id;
    else
        all = 1;
        
    $.ajax({
			type: 	'POST',
			url: 	'scripts.php?script=leagueMasterCache',
			data:	'lid='+league_id+"&did="+division+"&all="+all,
			success: function(html){
					//alert(html);			
			}
		});

}
function setDivisionMasterCache(league_id,division_id,module)
{    
    $.ajax({
			type: 	'POST',
			url: 	'scripts.php?script=divisionMasterCache',
			data:	'lid='+league_id+"&did="+division_id+"&module="+module,
			success: function(html){
					//alert(html);			
			}
		});

}
function thameDropdown(type)
{
   if ($.browser.msie) 
    {
        if($("#team_Dropdown_list_val").val() == 1 )
        {
            setTimeout('$("#team_Dropdown_list").css("width","300px");',200)
            $("#team_Dropdown_list_val").val("0");            
        }
        else
        {
            if(type == 1)
            {
               $("#team_Dropdown_list").css("width","auto");
               $("#team_Dropdown_list_val").val("1");
            }
        }
    }                   
}
function GetParentbyClass(element,classname)
{
    while($(element).attr('class') !=  classname && $(element).parent() != null)
        return GetParentbyClass($(element).parent(),classname);
    return element;
}        

function exploreNow(){
	location.href = "/search";
}; 
function tryAgain(){
	location.href = "/login?login_submited=1";
}; 
function goToSettings(){
	location.href = "/index?settings";
}; 






function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	if($('#gallery a').length > 2){
    setInterval('gallery()',6000);
    }
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	

    
    
	//Get next image caption
	var caption = next.find('img').attr('rel');	
    
        //alert(caption);
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	//Set the opacity to 0 and height to 1px
	$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#gallery .caption').animate({opacity: 0.9},80 ).animate({height: '80px'},500 );
	
	//Display the content
	$('#gallery .content').html(caption);
    
	
	
}

	function showModal(_url) {
		var _this = this;
	//	alert(_url);
		$('#notify_content').html("<IFRAME src='"+_url+"' width='100%' height='"+$(window).height()/1.1+"' frameborder=0></IFRAME>");
		modal_base.init("error", "Western League External Photos", "#notification", "OK", null,null,2 );
		//alert(modal_base.init);
		$('#facebox .body').width($(window).width() / 1.1);
		$('#facebox .body').height($(window).height() / 1.0);

//alert($(window).width());

		$('#facebox').css('left', $(window).width()/18);
		$('#facebox').css('top', '0');
	}



	function showHTMLModal(_html,_title) {
		var _this = this;
 
        
	//	alert(_url);
		$('#notify_content').html(_html);
        
        $('#fb_invite').css('display','block');
        
		modal_base.init("error", _title, "#notification", "OK", null,null,2 );
		//alert(modal_base.init);
		$('#facebox .body').width($(window).width() / 2.1);
	//	$('#facebox .body').height($(window).height() / 3.0);

//alert($(window).width());

		$('#facebox').css('left', $(window).width()/5);
		$('#facebox').css('top', '50%');
	}




function showFBModal(){
    
		modal_base.init("error", "dsdds", "#fb_invite", "OK", null,null,2 );
        
     $('#facebox').css('visibility', 'hidden');
     $('#fb_invite').css('display', 'block'); 
}


function toolpix(){
_url = 'http://toolstationwesternleague.fotopic.net/';
showModal(_url);

}


function toggleCheck(cbox, divarea){
    cbox = "#"+cbox;
    divarea = "#"+divarea;
     
    
    if($(cbox).attr('checked') == true){
        $(divarea).fadeIn("slow");
    }else{
        $(divarea).fadeOut("slow");
    }
}



function grShowmenu(str){
    str = "#"+str;
        $(str).css("display","block");    
	$("#level1_ads").css("visibility","hidden");   ;
    
	$("#level1_ads").css("z-index","-999");   ;
    
}


function grHidemenu(str){
    str = "#"+str;
       // $(str).fadeOut();    
        $(str).css("display","none");
	$("#level1_ads").css("z-index","0"); 
	$("#level1_ads").css("visibility","visible");   ;
    
}
