var prUrl="http://www.goals.gr";

var Url = {

 

	// public method for url encoding

	encode : function (string) {

		return escape(this._utf8_encode(string));

	},

 

	// public method for url decoding

	decode : function (string) {

		return this._utf8_decode(unescape(string));

	},

 

	// private method for UTF-8 encoding

	_utf8_encode : function (string) {

		string = string.replace(/\r\n/g,"\n");

		var utftext = "";

 

		for (var n = 0; n < string.length; n++) {

 

			var c = string.charCodeAt(n);

 

			if (c < 128) {

				utftext += String.fromCharCode(c);

			}

			else if((c > 127) && (c < 2048)) {

				utftext += String.fromCharCode((c >> 6) | 192);

				utftext += String.fromCharCode((c & 63) | 128);

			}

			else {

				utftext += String.fromCharCode((c >> 12) | 224);

				utftext += String.fromCharCode(((c >> 6) & 63) | 128);

				utftext += String.fromCharCode((c & 63) | 128);

			}

 

		}

 

		return utftext;

	},

 

	// private method for UTF-8 decoding

	_utf8_decode : function (utftext) {

		var string = "";

		var i = 0;

		var c = c1 = c2 = 0;

 

		while ( i < utftext.length ) {

 

			c = utftext.charCodeAt(i);

 

			if (c < 128) {

				string += String.fromCharCode(c);

				i++;

			}

			else if((c > 191) && (c < 224)) {

				c2 = utftext.charCodeAt(i+1);

				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));

				i += 2;

			}

			else {

				c2 = utftext.charCodeAt(i+1);

				c3 = utftext.charCodeAt(i+2);

				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));

				i += 3;

			}

 

		}

 

		return string;

	}

 

}

function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}

function hideOverlay() {
	$('#light').css('display', 'none');
	$('#fade').css('display', 'none');	
}


function hideBadgeOverlay() {
	$('#light2').css('display', 'none');
	$('#fade2').css('display', 'none');	
}

function showBadgeOverlay() {
	$('.overlay2').height($(document).height());
	$('#light2').css('display', 'block');
	$('#fade2').css('display', 'block');	
}

function showOverlay() {
	$('.overlay').height($(document).height());
	$('#light').css('display', 'block');
	$('#fade').css('display', 'block');	
}

function updateChart(ids) {  
	$.ajax({
		//url: prUrl+"/charts/xmls/compare.xml",
		url: prUrl+"/ajax/compare.php",
		data: "&ids="+ids,
		type: "GET",
		dataType: "text",
		timeout: 15000,
		cache: false,
		error: function(){
			//alert("Error loading XML document");
		},
		success: function(text){
			var chartObj = getChartFromId("ChartId");  
			chartObj.setDataXML(text);  	
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=compareUsersStats",
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(tbl){
					$("#compStats").html(tbl);
				}
			});			
		}
	});			
}

function copyAdsToLivescore() {
	var ad1Id = $('#hidden1').attr('name');
	$('#google_ads_div_'+ad1Id+'_ad_container').children('script').remove();
	$("#ad1").html($('#google_ads_div_'+ad1Id+'_ad_container').html());

    var ad2Id = $('#hidden2').attr('name');
	$('#google_ads_div_'+ad2Id+'_ad_container').children('script').remove();
    $("#ad2").html($('#google_ads_div_'+ad2Id+'_ad_container').html());
			
    var ad3Id = $('#hidden3').attr('name');
	$('#google_ads_div_'+ad3Id+'_ad_container').children('script').remove();
    $("#ad3").html($('#google_ads_div_'+ad3Id+'_ad_container').html());
				
    var ad4Id = $('#hidden4').attr('name');
	$('#google_ads_div_'+ad4Id+'_ad_container').children('script').remove();
    $("#ad4").html($('#google_ads_div_'+ad4Id+'_ad_container').html());		
}

function showRankings(url) {
	window.location=url;
}

function array_key_exists(key, search) {
   return (typeof search[key] != 'undefined');
}

function calculateComboOdd() {
		var totOdd = 1;
		var selPicks = 0;
		elements = $("#bettingSlip").find('input.inc');
		elements.each(function() { 
			odd = $(this).parent('td').parent('tr').children().find('.odd').html();
			//alert(elemId);
			if ($(this).is(':checked')) {
				totOdd = totOdd*odd;
				++selPicks;
			}
		});	
		if (selPicks > 1) {
			if (totOdd == 1) {
				totOdd = '-';
			} else {
				totOdd = totOdd.toFixed(2);
			}
		} else {
			totOdd = '-';
		}
		$("#totOdd").html(totOdd);	
}


function displayMsg(msg,cls) {
	$("#bsMsg").css('display','block');
	$("#bsMsg").removeClass().addClass(cls);
	$("#bsMsg").html(msg);	
}

function placeBets(ids,radio,stake,totOdd) {
	var r=confirm(confirmBet);
	if (r==true) {
		var result = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=placeBets&ids="+ids+"&radio="+radio+"&stake="+stake+"&totOdd="+totOdd,
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;
		var res = result.split('|');
		if (res[0] == 0) { //code 0 - match already started
			var r = res[2].split('-');
			for(var i=0; i<r.length; i++) {
				$("#"+r[i]).find('.opponents').addClass('started');
			}
			displayMsg(res[1],'bgRed');
		} else if (res[0] == 2 || res[0] == 9) { // code 2 - not logged on | code 9 - bet already exist
			displayMsg(res[1],'bgRed');
		} else if (res[0] == 3) { // code 3 - balance not enough
			displayMsg(res[1]+'('+res[2]+')','bgRed');
		} else if (res[0] == 4) { // code 4 - daily limit
			displayMsg(res[1]+' ('+res[2]+')','bgRed');
		} else if (res[0] == 1) { // code 1 - bet placed
			displayMsg(res[1],'bgGreen');
			if ($('#keepPicks').is(':checked')) {
				
			} else {
				var r = res[2].split('-');
				for(var i=0; i<r.length; i++) {
					var value = r[i];
					$.ajax({
						url: prUrl+"/ajax/ajax.php",
						data: "&type=deleteSlipRow&id="+value,
						type: "GET",
						dataType: "text",
						timeout: 5000,
						cache: false,
						error: function(){
							//alert("Error loading XML document");
						},
						success: function(text) {
							$('#'+text).remove();
							elements = $("#bettingSlip").find('input.inc');
							if (elements.length == 0) {
								$("#slipToolbar").css('display','none');
								/*$("#bsMsg").html("");	
								$("#bsMsg").css('display','none');*/
							} else if (elements.length == 1) {
								$("#comboRow").css('display','none');
							}
						}
					});
				}	
			}
		}
		return true;
	}
}
function addToBettingSlip(user,curGame,type,sel,param,odd) {
/*		var curSlip = $("#bettingSlip").html();
		$("#bettingSlip").html('<img src="'+prUrl+'/images/ajax-loader.gif">');*/
		var voteSelection = user+'|'+curGame+'|'+type+'|'+sel+'|'+param+'|'+odd;
		var result = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=getMatchData&id="+curGame+"&params="+voteSelection,
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;
		 //alert(result);	
		var mData = result.split('|');
		var hTeam = mData[0];
		var aTeam = mData[1];
		var hTeamName = mData[2];
		var aTeamName = mData[3];
		var totOdd = parseFloat(mData[4]);
		var totBets = mData[5];
		var isNew = mData[6];
		if (type == 1) {
			if (hTeam == sel) {
				pick = '1';
			} else if (aTeam == sel) {
				pick = '2';
			} else {
				pick = 'X';	
			}
		} else if (type == 2) {
			if (sel == 0) {
				pick = 'U';
			} else if (sel == 1) {
				pick = 'O';
			}
		}
		if (totBets <= 1) {
			$("tr#comboRow").css('display','none');
			$("#comboBet").attr('disabled',true);
			var result = $.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=radioChanged&sel=single",
				type: "GET",
				dataType: "text",
				timeout: 15000,     
				async:false,
				cache: false
			 }).responseText;
			$('#singleBet').attr("checked",true);
			$('#comboBet').attr("checked",false);
		} else {
			$("#comboRow").css('display','');
			$("#comboBet").attr('disabled',false);
		}
		var curSlip = $("#bettingSlip").html();
		$("#bettingSlip").html(curSlip);
		if (isNew == 0) {
			$("#entry_"+curGame+"_"+type).remove();
		}
		$("#bettingSlip").prepend('<div id="entry_'+curGame+'_'+type+'" style="display: hidden;"></div>');
		//$('<div id="entry_'+curGame+'_'+type+'" style="display: hidden;"></div>').insertBefore('#slipToolbar');
		templ = $("#couponTemplate").html();	
		//$("#totOdd").html(totOdd);
		$("#entry_"+curGame+"_"+type).html(templ);
		$("#entry_"+curGame+"_"+type).children('.bettingSlipHeader').find('.opponents').html(hTeamName+'<br>'+aTeamName);
		$("#entry_"+curGame+"_"+type).children('.bettingSlipHeader').find('.selection').html(pick);
		$("#entry_"+curGame+"_"+type).children('.bettingSlipHeader').find('.odd').html(odd);
		$("#entry_"+curGame+"_"+type).css('display', 'block');
		$("#slipToolbar").css('display','block');	
}

function getSelectedPicks() {
	var ids='';
	elements = $("#bettingSlip").find('input.inc');
	elements.each(function() { 
		elemId = $(this).parent('td').parent('tr').parent('tbody').parent('table').parent('div').parent('div').attr('id');
		if ($(this).is(':checked')) {
			ids = ids+elemId+'|';
		}
	});
	return ids;
}

function usernameAvailable(usr) {
	var result = $.ajax({
		url: prUrl+"/ajax/ajax.php",
		data: "&type=checkAvailability&username="+usr,
		type: "GET",
		dataType: "text",
		timeout: 15000,     
		async:false,
		cache: false
	 }).responseText;
	
	if (result == 1) {
		return true;
	} else {
		return false;
	}
}

function captchaIsWrong(code) {
	var result = $.ajax({
		url: prUrl+"/ajax/ajax.php",
		data: "&type=checkCaptcha&code="+code,
		type: "GET",
		dataType: "text",
		timeout: 15000,     
		async:false,
		cache: false
	 }).responseText;
	
	if (result != 0) {
		var timestamp = new Date().getTime();
		$("#captchaImage").attr("src","captcha_image.php?"+timestamp);
		return true;
	} else {
		return false;
	}
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function divClicked() {

    var divHtml = $(this).text();
    var divId = $(this).attr('id');
	var pick = 	divId.replace('com','');
	
/*		var pick = $(this).attr('pick');
		var user = $(this).attr('user');*/
	var result = $.ajax({
		url: prUrl+"/ajax/ajax.php",
		data: "&type=allowComments&pick="+pick,
		type: "GET",
		dataType: "text",
		timeout: 15000,     
		async:false,
		cache: false
	 }).responseText;	

	var txt = result.split('|');
	if (txt[0] == 0) {
		alert(txt[1]);
	} else {
		$(this).parent('.commentsBox').children('.save_comments').css('display','block');
		$(this).parent('.commentsBox').children('.cancel_comments').css('display','block');
		$('#prev'+pick).val(divHtml);
		var editableText = $("<textarea />");
		editableText.attr('id',divId);
		editableText.attr('class','tempTxt');
		editableText.val(divHtml);
		$(this).replaceWith(editableText);
		editableText.focus();
		// setup the blur event for this new textarea
		//editableText.blur(editableTextBlurred);	
	}

}

/*function editableTextBlurred() {
    var html = $(this).val();
    var viewableText = $("<div>");
    viewableText.html(html);
    $(this).replaceWith(viewableText);
    // setup the click event for this new div
    viewableText.click(divClicked);
}*/
function showNextWallRows(id) {
	$('#grp_'+id).css('display','none');
	$('#loading_'+id).css('display','none');
	$('#more_'+id).css('display','block');
	$('.grp'+parseInt(id+50)).each(function() { 
		$(this).css('display','table-row');
	});	
}

function  showNextFollowingRows(ids,tot) {
	
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=createFollowingNextRows&ids="+ids,
				type: "GET",
				dataType: "text",
				timeout: 5000,
				cache: false,
				error: function(){
					
				},
				success: function(text) {				
					$('#flwTbl tr:last').before(text);
					$('#loading_flw').css('display','none');
					$('#more_flw').css('display','block');		
					$('#tot').val(parseInt(tot)+1);
					if ($('#tot_'+$('#tot').val()).length > 0){
					  
					} else {
						$('#flw').remove();
					}
				}
			});	
}


function  showNextFollowersRows(ids,tot) {
	
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=createFollowersNextRows&ids="+ids,
				type: "GET",
				dataType: "text",
				timeout: 5000,
				cache: false,
				error: function(){
					
				},
				success: function(text) {				
					$('#flwTbl tr:last').before(text);
					$('#loading_flw').css('display','none');
					$('#more_flw').css('display','block');		
					$('#tot').val(parseInt(tot)+1);
					if ($('#tot_'+$('#tot').val()).length > 0){
					  
					} else {
						$('#flw').remove();
					}
				}
			});	
}

$(document).ready(function(){
/*	$("body").click(function(){
		$(".infoCont").css("display","none");
		$(".infoContMain").html("<img src=\""+prUrl+"/images/ajax-loader.gif\">");
	});*/
	$(".close").live("click", function() {
		$(".infoCont").css("display","none");
		$(".infoContMain").html("<img src=\""+prUrl+"/images/ajax-loader.gif\">");
	});
});


$(document).ready(function(){
	$(".gameScore, .gameScoreScore, .scoreDetail").live("click", function() {
		var offset = $(this).offset();
		$(".infoCont").css("display","block");
		$(".infoCont").css("top",offset.top+12);
		if ($(this).attr('class') == 'scoreDetail') {
			$(".infoCont").css("left",offset.left);
		} else {
			$(".infoCont").css("left",offset.left-540);
		}
		$.ajax({
			url: prUrl+"/ajax/matchinfo.php",
			data: "&id="+$(this).parent().attr("id")+"&dt="+$(this).parent().children(".gameSortVal").text().substr(0,12),
			type: "GET",
			dataType: "text",
			timeout: 5000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				$(".infoContMain").html(text);
			}
		});
	});


	$("#derbycastHowTo, #derbycastGifts").live("click", function() {
		var offset = $(this).offset();
		$(".infoCont").css("display","block");
		$(".infoCont").css("z-index","10000");
		$(".infoCont").css("top",385);//offset.top+12
		$(".infoCont").css("left",200);//offset.left-270
		
		
		//$(".infoContMain").html("<div class=\"infoGameTitle\"><div class=\"close\" title=\"close\" alt=\"close\"></div></div>");
		if ($(this).attr('id') == 'derbycastHowTo') {
			//$(".infoContMain").html($(".infoContMain").html()+'how to text here');
			var id = 38;
		} else if ($(this).attr('id') == 'derbycastGifts') {
			//$(".infoContMain").html($(".infoContMain").html()+'prizes text here');
			var id = 37;
		}

		$.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=getStaticPage&id="+id,
			type: "GET",
			dataType: "text",
			timeout: 5000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				$(".infoContMain").html(text);
			}
		});
	});


});

$(document).ready(function(){
	$(".gameOdds").live("click", function() {
		var offset = $(this).offset();
		$(".infoCont").css("display","block");
		$(".infoCont").css("top",offset.top+12);	
		$(".infoCont").css("left",offset.left-530);
		$.ajax({
			url: prUrl+"/ajax/matchodds.php",
			data: "&id="+$(this).parent().attr("id"),
			type: "GET",
			dataType: "text",
			timeout: 5000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				$(".infoContMain").html(text);
			}
		});
	});
});

$(document).ready(function(){	
	$(".tVote").live("click", function() {	
		var curGame = $("#expGame").val();//$("#curGame").val().replace("tools","");		
		
			var offset = $(this).offset();
			$(".infoCont").css("display","block");
			$(".infoCont").css("top",offset.top+12);
			$.ajax({
				url: prUrl+"/ajax/vote.php",
				data: "&id="+curGame,
				type: "GET",
				dataType: "text",
				timeout: 5000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					$(".infoContMain").html(text);
				}
			});
	});	
});

$(document).ready(function(){	
	$(".tOdds").live("click", function(){	
		var curGame = $("#expGame").val();//$("#curGame").val().replace("tools","");
			var offset = $(this).offset();
			$(".infoCont").css("display","block");
			$(".infoCont").css("top",offset.top+12);
			$.ajax({
				url: prUrl+"/ajax/matchodds.php",
				data: "&id="+curGame,
				type: "GET",
				dataType: "text",
				timeout: 5000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					$(".infoContMain").html(text);
				}
			});
		
	});
});

$(document).ready(function(){
	$(".dropDownOption3").click(function(){
		//$(this).removeClass("dropDownOptionOn");
		height = $("#leagueTbl").height();
		curSeason = $("#curSeason").attr("value");
		$("#leagueTbl").height(height);
		$("#leagueTbl").css("display","block");
		$("#leagueTbl").html('<img src="'+prUrl+'/images/ajax-loader.gif">');
		$("#restData").css("display","none");
		if (curSeason == $(this).attr("id")) {
			$("#restData").css("display","block");
		}
		
		$.ajax({
			url: prUrl+"/ajax/getTable.php",
			data: "&season="+$(this).attr("id")+'&league='+$(this).attr("name"),
			type: "GET",
			dataType: "text",
			timeout: 15000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				$("#leagueTbl").html(text);
				$("#leagueTbl").css("display","none");
				$("#leagueTbl").css("display","block");
			}
		});
		
		/* function to sort drop-down's slements*/
		var listitems = $(this).parent("li").children('div').get();
		listitems.sort(function(a, b) {
		   var compA = $(a).text().toUpperCase();
		   var compB = $(b).text().toUpperCase();
		   //return (compA < compB) ? -1 : (compA > compB) ? 1 : 0; //ascending
		   return (compA > compB) ? -1 : (compA < compB) ? 1 : 0;
		})
		$.each(listitems, function(idx, itm) { $(this).parent("li").append(itm); });		
		
		/* move selected element on top*/
		if ( $(this).attr("id") != $(this).parent("li").children("div").first().attr("id") ) {
			$(this).insertBefore($(this).parent("li").children("div").first());
		}
	});
});

	
$.fn.selectRange = function(start, end) {
    return this.each(function() {
        if (this.setSelectionRange) {
            this.focus();
            this.setSelectionRange(start, end);
        } else if (this.createTextRange) {
            var range = this.createTextRange();
            range.collapse(true);
            range.moveEnd('character', end);
            range.moveStart('character', start);
            range.select();
        }
    });
};


$(document).ready(function(){
	
	/// Close the fixed banner at the bottom of the page
	$("#fixed-close").live("click", function() {
		var banner=$(this).children("img").attr("id");
		$.ajax({
			url: prUrl+"/ajax/fixed-banner-close.php",
			data: "&banner="+banner,
			type: "GET",
			dataType: "text",
			timeout: 15000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				var rt=text.split("|");
				if ( rt[0]=="OK" ) {
					$("#"+rt[1]+"-fixed").hide();
				}
			}
		});
	});
	/// Close the fixed banner at the bottom of the page
	
	
	$(".homeWin, .draw, .awayWin, .over, .under, #noBet, #placeBet, .userLink, #closeBsMsg, #bsMsg, .addToBS, #showFavs, .picks_comments, .picks_like, .picks_dislike, .picks_report, .picks_report2, .addPickComments, .close_comments, #favTeamDelete, .deleteFav, #addFriendBtn, .acceptFriend, .removeFriend, .rejectFriend, .seriAnswer, .accSubSectionTitle, .customTab, #expandLatestEvents, .btnDel, #footerBugsRow1, #doLogin, #nextDay, #prevDay, .gameOdd, .expCol, .closeOvl, .showMore, .showMoreF, .showMoreF2, #searchBtn").live("mouseover", function() {	
		$(this).css("cursor", "pointer");			
	});
	
	$('#linkSubmit').live("click", function() {
		//var urlregex = new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)");
		var urlregex = new RegExp("^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&amp;%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&amp;%\$#\=~_\-]+))*$");
		var linkTitle = $("#linkTitle").val().trim();
		var linkUrl = $("#linkUrl").val();
		var linkDescription = $("#linkDescription").val().trim();
		
		if (linkTitle.length === 0) {
			alert(dirNoTitle);
			return false;
		} else if (linkTitle.length > 40) {
			alert(dirTitleMax);
			return false;
		}

		if (linkUrl.length === 0) {
			alert(dirNoUrl);
			return false;
		} else {
			if (!urlregex.test(linkUrl)) {
				alert(dirInvalidUrl);
				return false;				
			}
		}
		
		if (linkDescription.length === 0) {
			alert(dirNoDescription);
			return false;
		} else if (linkDescription.length > 150) {
			alert(dirDescriptionMax);
			return false;
		}
		
		var cat = "";
        $("#catDD option:selected").each(function () {
			cat += $(this).val() + ",";
		});
		if (cat == '') {
			alert(dirNoCategory);
			return false;
		}

		
		$.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=linkSubmit&title="+Url.encode(linkTitle)+"&url="+Url.encode(linkUrl)+"&description="+Url.encode(linkDescription)+"&categories="+cat,
			type: "GET",
			dataType: "text",
			timeout: 15000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				txt = text.split('|');
				alert(txt[1]);
			}
		});			
	});	
	
	$('#addLink').live("click", function() {
		if ($(this).hasClass('allowLink')) {
			$('#addLinkBox').css('display','block');
			$.scrollTo( '#addLinkTop', 800 );
		} else if ($(this).hasClass('dontAllowLink')) {
			alert(loginToAdd);
		}
	});
	
	$('#reportBrokenLink').live("click", function() {
		var name = $(this).attr('name').split('_');
		var linkId = name[1];
		alert('Thank you!');
/*		$.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=reportBrokenLink&odd="+odd+"&gameId="+gameId,
			type: "GET",
			dataType: "text",
			timeout: 15000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				
			}
		});	*/		
	});	
	
	$('#ticker01').css('visibility','visible');

	$("#searchBtn").live("click", function() {
		if ($('#inputString').val() != '' && $('#inputString').val() != searchDefaultValue) {
			window.location.href=prUrl+'/search/a/'+$('#inputString').val();
		} else {
			alert(searchFieldEmpty);
		}
	});
 	
	$(".closeOvl").live("click", function() {
		hideBadgeOverlay();
		if ($('#closeOvlType').val() == 1) {	
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=updateBadgeAlert",
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					
				}
			});	
		} else if ($('#closeOvlType').val() == 2) {
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=disableUnibetAlert",
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					
				}
			});			
		}
	});
	
	$(".expCol").live("click", function() {
		var id = $(this).attr('id');
		if ($('#cat_'+id).css('display') == 'block') {
			$('#cat_'+id).css('display','none');
			$(this).attr('src','/images/expand.png');
		} else {
			$('#cat_'+id).css('display','block');
			$(this).attr('src','/images/collapse.png');
		}
	});
		
	$(".gameOdd").live("click", function() {
		
		var odd = $(this).text();
		var gameId = $(this).parent('.game').attr('id');
						$.ajax({
							url: prUrl+"/ajax/ajax.php",
							data: "&type=createOpapCookie&odd="+odd+"&gameId="+gameId,
							type: "GET",
							dataType: "text",
							timeout: 15000,
							cache: false,
							error: function(){
								//alert("Error loading XML document");
							},
							success: function(text){
								
							}
						});			
	});	
	
	$("#expandLatestEvents").live("click", function() {
		if ($('#latestEventsInner').hasClass('exp')) {
			$('#latestEventsInner').removeClass();
			$(this).removeClass();
		} else {
			$('#latestEventsInner').addClass('exp');
			$(this).addClass('expanded');
		}
	});	
	
	
	$("#lastGames").change(function(){
		var games = $("#lastGames option:selected").val();
		var team = $(this).attr('team');
		$.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=createTeamFormTable&team="+team+"&games="+games,
			type: "GET",
			dataType: "text",
			timeout: 15000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				$("#lastGamesTbl > tbody").children('tr').each(function() { 
					$(this).remove();
				});	
				$('#lastGamesTbl > tbody').append(text);				
			}
		});		

	});	
	
	$("#npdatepicker, #npdatepicker2").change(function(){
		window.location.href=$('#npLink').val()+'/'+$(this).val();
	});	
	
	$("#selectNp").change(function(){
		var sel = $("#selectNp option:selected").val().split('-');
		var id = sel[0];
		var name = sel[1];
		var url = $('#selectLink').val();
		var url1 = url.replace(/npId/gi, id);
		var url2 = url1.replace(/npName/gi, name);
		window.location.href=url2;
	});	
	
	
	$("#footerBugsRow1").live("click", function() {
		$('#fm_message').text(reportBug1+ ': '+$('#curPage').val()+' '+reportBug2+': ');
		$('#fm_message').focus();
	});	
	
	$("#blog_comment_submit").live("click", function() {
		var bid = $('#blogId').val();
		var comments = $('#blog_comments').val();
		$.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=addBlogComment&bid="+bid+"&comments="+comments,
			type: "GET",
			dataType: "text",
			timeout: 15000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				txt = text.split('|');
				if (txt[0] == 1) {
					$('#commentsTop div:first').before(txt[1].replace(/~/g,'|'));
					$('#blog_comments').val(wallYourComment+'...');
					$('#charsLeft').text('160');
					//initPagination();
					$.scrollTo( '#commentsTop', 800, {easing:'elasout'} );
				} else if (txt[0] == 0) {
					alert(txt[1]);
				}
			}
		});		

	});
	
	$(".customTab").live("click", function() {
		 $("#logTbl").css('display','none');
		 $("#mentionsTbl").css('display','none');
		 $("#dmTbl").css('display','none');
		 //$('.customTab').css('text-decoration','underline');
		 //$(this).css('text-decoration','none');
		 $('.active').removeClass('active');
		 $(this).parent('a').parent('li').addClass('active');
		 if ($(this).attr('id') == 'wallShowAll') {
			 $("#logTbl > tbody").children('tr').each(function() { 
					if ($(this).hasClass('grp50')) {
						$(this).css('display','table-row');	
					} else {					
						$(this).css('display','none');	
					}
				});			 
			$("#logTbl").css('display','inline'); 
		 } else if ($(this).attr('id') == 'wallShowFavourites') {
			 
			 $("#logTbl > tbody").children('tr').each(function() { 
					if ($(this).hasClass('favSelected')) {
						$(this).css('display','table-row');
					} else {
						$(this).css('display','none');	
					}
				});
			 
			 $("#logTbl").css('display','inline'); 
		 } else if ($(this).attr('id') == 'wallShowMentions') {
			 $("#mentionsTbl").css('display','inline'); 
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=markAsRead2&uid="+$(this).attr('usr'),
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					txt = text.split('|');
					//alert(txt[1]);
					if (txt[0] == 1) {
						$('#unreadMentions').html('0');
						$('#accountMentions').html('0');
						$('#accountMentionsTxt').html('New mentions:');
					}
				}
			});
		 } else if ($(this).attr('id') == 'wallShowDirect') {
			 $("#dmTbl").css('display','inline');
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=markAsRead&uid="+$(this).attr('usr'),
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					txt = text.split('|');
					//alert(txt[1]);
					if (txt[0] == 1) {
						$('#unreadDMs').html('0');
						$('#accountDMs').html('0');
						$('#accountDMsTxt').html('New DMs:');
					}
				}
			});			 
			 
		 }
	});	
	
	$(".wallFavourite, .wallFavouriteSelected").live("click", function() {
		var uid = $('#userId').val();
		var rowId = $(this).parent('td').parent('tr').attr('id');
		var id = rowId.split('_');
		if ($(this).hasClass('wallFavouriteSelected')) {
			$(this).removeClass().addClass('wallFavourite');
			$(this).parent('td').parent('tr').removeClass();
			var action = 'remove';
		} else {
			$(this).removeClass().addClass('wallFavouriteSelected');
			$(this).parent('td').parent('tr').removeClass().addClass('favSelected');
			var action = 'add';
		}
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=wallFavourites&action="+action+"&uid="+uid+"&data="+id[1],
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					txt = text.split('|');
					//alert(txt[1]);
					if (txt[0] == 1) {
						
					}
				}
			});			
	});	
	
	$(".wallDelete").live("click", function() {
		var uid = $('#userId').val();
		var rowId = $(this).parent('td').parent('tr').attr('id');
		var id = rowId.split('_');
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=removeWallRow&uid="+uid+"&data="+id[1],
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					txt = text.split('|');
					//alert(txt[1]);
					if (txt[0] == 1) {
						$('#'+rowId).remove();
					}
				}
			});	
		
	});	



	$(".wallReply, .wallDM").live("click", function() {
		//alert($(this).attr('posterId'))
		if ($(this).attr('type') == 'dm') {
			var sign = '*';
		} else {
			if ($(this).parent('td').parent('tr').parent('tbody').parent('table').attr('id') == 'dmTbl') {
				var sign = '*';	
			} else {
				var sign = '@';
			}
		}
		$.scrollTo( '#commentsTop', 800, {easing:'elasout'} );
		$('#wall_comments').val(sign+$(this).attr('posterUsername')+' ');
		//$('#wall_comments').focus();
		var charLength = $('#wall_comments').val().length;
		$('#wall_comments').selectRange(charLength,charLength);	
	});	
	
	$("#wall_comment_submit").live("click", function() {
		var uid = $('#userId').val();
		var comments = $('#wall_comments').val();
		//comments = comments.replace('#','~~~');
		$.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=addWallComment&uid="+uid+"&comments="+Url.encode(comments),
			type: "GET",
			dataType: "text",
			timeout: 15000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				txt = text.split('|');
				//alert(txt[1]);
				if (txt[0] == 1) {
					$('#logTbl tr:first').before(txt[1]);
					$('#wall_comments').val(wallYourComment+'...');
					$('#charsLeft').text('160');
				} else if (txt[0] == 2) {;
					$('#wall_comments').val(wallYourComment+'...');
					$('#charsLeft').text('160');
					alert(txt[1]);
				}
			}
		});		

	});	


	$('.saveScorecast').live("click", function() {
		if ($(this).hasClass('notLoggedIn')) {
			alert(scorecastLoginToUse);
		} else if ($(this).hasClass('couponExpired')) {
			alert(scorecastCouponExpired);
		} else {
			var totGames = $('#scTot').val();
			var id = $(this).attr('id').split('_');
			var scId = id[1];
			checked = new Array();
			var num=0;
			trs = $("#tbl_"+scId).find('tr.scRow');
			var game = $(this).attr('id').split('_');
			var matchId = game[1];
			var selection = '';
			trs.each(function() { 
				var trId = $(this).attr('id').split('_');
				var inputs = $(this).find('input');
				var empty = 0;
				inputs.each(function() { 
					if ($(this).val().length == 0) {
						empty = 1;
					}
				});	
				if (empty == 1) {
					alert(scorecastEnterPredictionForMatch+' #'+parseInt(num+1));
					return false;
				} else {
					selection = selection + trId[1] + '-' + $('#homeGoals_'+trId[1]).val() + '-' + $('#awayGoals_'+trId[1]).val() +'|';
					num++;
				}
			});	
			if (num == totGames) {
				$.ajax({
					url: prUrl+"/ajax/ajax.php",
					data: "&type=addScorecast&selection="+selection+"&scorecastId="+scId,
					type: "GET",
					dataType: "text",
					timeout: 15000,
					cache: false,
					error: function(){
						//alert("Error loading XML document");
					},
					success: function(text){
						txt = text.split('|');
						alert(txt[1]);
						//$("#submitMsg").html(txt[1]);					
					}
				});	
			}
		}
	});


	$('.savePropo').live("click", function() {
		if ($(this).hasClass('notLoggedIn')) {
			alert(propoLoginToUse);
		} else {
			var id = $(this).attr('id').split('_');
			var propoId = id[1];
			checked = new Array();
			var num=0;
			trs = $("#tbl_"+propoId).find('tr.propoRow');
			trs.each(function() { 
				num++;
				fixId = $(this).attr('id').split('_');
				fId = fixId[1];
				checked[fId] = '';
				cbx = $(this).find('input');
				cbx.each(function() { 
					cbxId = $(this).attr('id').split('_');
					if ($(this).is(':checked')) {
						//alert($(this).attr('id')+' is checked');
						checked[fId] = checked[fId]+cbxId[1];
					}
				});
				if (checked[fId] == '') {
					alert(propoSelectPick+' #'+num);
					return false;
				}
			});	
			if (num == 14) {
				selection='';
				for(var i in checked) {
					var value = checked[i];
					selection = selection+i+'-'+value+'|';
				}
				$.ajax({
					url: prUrl+"/ajax/ajax.php",
					data: "&type=addPropo&selection="+selection+"&propoId="+propoId,
					type: "GET",
					dataType: "text",
					timeout: 15000,
					cache: false,
					error: function(){
						//alert("Error loading XML document");
					},
					success: function(text){
						txt = text.split('|');
						alert(txt[1]);
						//$("#submitMsg").html(txt[1]);					
					}
				});	
			}
		}
	});


	$('.showMore').live("click", function() {
		var id = $(this).attr('id').split('_');
		$(this).css('display','none');
		$('#loading_'+id[1]).css('display','');
		setTimeout('showNextWallRows('+id[1]+')',3250);
		//alert(id[1]);
	});

	$('.trExp').live("click", function() {
		if ($(this).parent('div').parent('td').parent('tr').next('tr').css('display') == 'none') {
			$(this).parent('div').parent('td').parent('tr').next('tr').css('display','table-row');
		} else {
			$(this).parent('div').parent('td').parent('tr').next('tr').css('display','none');
		}
	});
		
	$('.derbyAnswer').live("click", function() {
		if ($(this).hasClass('inactive')) {
			alert(seriLoginToVote);
		} else if ($(this).hasClass('votingEnded')) {
			alert(seriVotingEnded);
		} else {
			var homeGoals = $('#homeGoals').val();
			var awayGoals = $('#awayGoals').val();
			if (homeGoals.length == 0 || isNaN(homeGoals) || !IsNumeric(homeGoals)) {
				alert(invalidHomeGoals);
				return false;
			} else if (awayGoals.length == 0 || isNaN(awayGoals) || !IsNumeric(awayGoals)) {
				alert(invalidAwayGoals);
				return false;
			}
			//var r=confirm(seriConfirmSelection);
			//if ( r == true ) {
				var qId = $(this).attr('id');
				$.ajax({
					url: prUrl+"/ajax/ajax.php",
					data: "&type=addDerbyAnswer&question="+qId+"&hg="+homeGoals+"&ag="+awayGoals,
					type: "GET",
					dataType: "text",
					timeout: 15000,
					cache: false,
					error: function(){
						//alert("Error loading XML document");
					},
					success: function(text){
						//text: success/failure(0/1)|message
						var txt = text.split('|');
						alert(txt[1]);
/*						$('.seriAnswer').addClass('alreadyVoted');
						$('#'+aId).addClass('myVote');
						$('#seriMsg').html(txt[1]);*/
					}
				});
			//}
		}
	});

	$('.seriAnswer').live("click", function() {
		if ($(this).hasClass('inactive')) {
			alert(seriLoginToVote);
		} else if ($(this).hasClass('alreadyVoted')) {
			alert(seriAlreadyVoted);
		} else if ($(this).hasClass('votingEnded')) {
			alert(seriVotingEnded);
		} else {
			var r=confirm(seriConfirmSelection);
			if ( r == true ) {
				var aId = $(this).attr('id');
				var qId = $(this).parent('td').parent('tr').attr('id');
				$.ajax({
					url: prUrl+"/ajax/ajax.php",
					data: "&type=addSeriAnswer&answer="+aId+"&question="+qId,
					type: "GET",
					dataType: "text",
					timeout: 15000,
					cache: false,
					error: function(){
						//alert("Error loading XML document");
					},
					success: function(text){
						//text: success/failure(0/1)|message
						var txt = text.split('|');
						$('.seriAnswer').addClass('alreadyVoted');
						$('#'+aId).addClass('myVote');
						$('#seriMsg').html(txt[1]);
					}
				});
			}
		}
	});
			
	$('.acceptFriend').live("click", function() {
		showOverlay();
		var inviterId = $(this).parent('div.pendings').attr('fid');
		$(this).parent('div.pendings').children('.rejectFriend').text('['+removeFriend+']');
		$(this).parent('div.pendings').children('.rejectFriend').attr('class','removeFriend');
		$(this).parent('div.pendings').appendTo('#friendsDiv');
		$(this).parent('div.pendings').attr('class','accepts');
		$(this).remove();
		//ajax - change flag in db
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=acceptFriend&inv="+inviterId,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
			
					setTimeout('hideOverlay()',1000);
					elements = $("#pendingDiv").find('div.pendings');
					if (elements.length == 0) {
						$("#pendingDiv").append("<div>"+noEntries+"</div>");
					}
				}
			});

	});
	
	$('.removeFriend').live("click", function() {
		showOverlay();
		var inviterId = $(this).parent('div.accepts').attr('fid');
		$(this).parent('div.accepts').remove();
		//ajax - change flag in db
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=removeFriend&inv="+inviterId,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					setTimeout('hideOverlay()',1000);
					elements = $("#friendsDiv").find('div.accepts');
					if (elements.length == 0) {
						$("#friendsDiv").append("<div>"+noEntries+"</div>");
					}
				}
			});		

	});
	
	$('.rejectFriend').live("click", function() {
		showOverlay();
		var inviterId = $(this).parent('div.pendings').attr('fid');
		$(this).parent('div.pendings').remove();
		//ajax - change flag in db
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=rejectFriend&inv="+inviterId,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					setTimeout('hideOverlay()',1000);
					elements = $("#pendingDiv").find('div.pendings');
					if (elements.length == 0) {
						$("#pendingDiv").append("<div>"+noEntries+"</div>");
					}
				}
			});			

	});

	$('#follow').live("click", function() {
		var user = $(this).attr('usr');
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=followUser&user="+user,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					//text: success/failure(0/1)|message
					var txt = text.split('|');
					$('#follow').attr("src", prUrl+'/images/follow-no.png');
					$('#follow').attr("alt", '');
					$('#follow').attr("title", '');
					$('#follow').attr("id", 'nofollow');
					//alert(txt[1]);
				}
			});
	});
	
	$('#nofollow').live("click", function() {
		var user = $(this).attr('usr');
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=stopFollowUser&user="+user,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					//text: success/failure(0/1)|message
					var txt = text.split('|');
					$('#nofollow').attr("src", prUrl+'/images/follow.png');
					$('#nofollow').attr("alt", '');
					$('#nofollow').attr("title", '');
					$('#nofollow').attr("id", 'follow');
					//alert(txt[1]);
				}
			});
	});

	$('#fol').live("click", function() {
		var user = $(this).attr('usr');
		var obj = $(this);
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=followUser&user="+user,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					//text: success/failure(0/1)|message
					var txt = text.split('|');
					obj.attr("src", prUrl+'/images/follow-no.png');
					obj.attr("alt", '');
					obj.attr("title", '');
					obj.attr("id", 'nofol');
					//alert(txt[1]);
				}
			});
	});
	
	$('#nofol').live("click", function() {
		var user = $(this).attr('usr');
		var obj = $(this);
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=stopFollowUser&user="+user,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					//text: success/failure(0/1)|message
					var txt = text.split('|');
					obj.attr("src", prUrl+'/images/follow.png');
					obj.attr("alt", '');
					obj.attr("title", '');
					obj.attr("id", 'fol');
					//alert(txt[1]);
				}
			});
	});
	
		$('.showMoreF').click(function() {
			var tot = $('#tot').val();
			var ids = $('#tot_'+tot).val();
			$(this).css('display','none');
			$('#loading_flw').css('display','');			
			setTimeout('showNextFollowingRows("'+ids+'",'+tot+')',1250);
										
		});	
	
		$('.showMoreF2').click(function() {
			var tot = $('#tot').val();
			var ids = $('#tot_'+tot).val();
			$(this).css('display','none');
			$('#loading_flw').css('display','');			
			setTimeout('showNextFollowersRows("'+ids+'",'+tot+')',1250);
										
		});	
	
	$('#addFriendBtn').live("click", function() {
		var user = $(this).attr('usr');
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=addFriend&user="+user,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					//text: success/failure(0/1)|message
					var txt = text.split('|');
					$('#addFriendBtn').attr("src", prUrl+'/images/add-friend-dis.png');
					$('#addFriendBtn').attr("alt", pendingApproval);
					$('#addFriendBtn').attr("title", pendingApproval);
					$('#addFriendBtn').attr("id", 'addFriendBtn2');
					alert(friendRequestSent);
				}
			});
	});
	
	//$("#teamDD").dblclick(function() {
	$("#favTeamSubmit").live("click", function() {
		if (!$("#teamDD option:selected").length) {
			alert('nothing selected');
		} else {
			var team = $('select#teamDD option:selected').val();
			var result = $.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=favTeamSelection&team="+team,
				type: "GET",
				dataType: "text",
				timeout: 15000,     
				async:false,
				cache: false
			 }).responseText;
			var data = result.split('|');
			if (data[0] == 1) {
				$("#favTeamName").html(data[1]);
				$("#favTeamBadge").show();
				$("#favTeamDelete").show();	
				$('#favTeamImage').attr("src", prUrl+'/images/teams/'+data[2]);
			}
		}
	});

	//$("#teamDD2").dblclick(function() {
	$("#favTeamSubmit2").live("click", function() {
		if (!$("#teamDD2 option:selected").length) {
			alert('nothing selected');
		} else {
			var team = $('select#teamDD2 option:selected').val(); 
			var result = $.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=selectFav&team="+team,
				type: "GET",
				dataType: "text",
				timeout: 15000,     
				async:false,
				cache: false
			 }).responseText;
			var data = result.split('|');
			if (data[0] == 0) {
				alert(data[1]);
			} else if (data[0] == 1) {
				$('#threeFavs').append('<div style="float:left;width:190px;padding:0 1px;" id="favTeam'+team+'"><table width="100%" style="text-align: center;"><tr><td><span id="favTeamName'+team+'">'+data[1]+'</span></td></tr><tr><td id="favTeamBadge'+team+'"><img src="'+prUrl+'/images/teams/empty-badge.gif" border="0" id="favTeam'+team+'Image" /></td></tr><tr><td><span class="deleteFav" id="'+team+'">['+deleteTeamDiv+']</span></td></tr></table></div>');			
			}
		}		
/*		var team = $('select#teamDD2 option:selected').val(); 
		var result = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=selectFav&team="+team,
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;
		var data = result.split('|');
		if (data[0] == 0) {
			alert(data[1]);
		} else if (data[0] == 1) {
			$('#threeFavs').append('<div style="float:left;width:200px;padding:0 1px;" id="favTeam'+team+'"><table width="100%"><tr><td><span id="favTeamName'+team+'">'+data[1]+'</span></td></tr><tr><td id="favTeamBadge'+team+'"><img src="'+prUrl+'/images/teams/empty-badge.gif" border="0" id="favTeam'+team+'Image" /></td></tr><tr><td><span class="deleteFav" id="'+team+'">['+deleteTeamDiv+']</span></td></tr></table></div>');			
		}*/
	});
	

	$(".accSubSectionTitle").live("click", function() {
			$(this).next('.regForm').slideToggle();								   
	});
	

	$("#accPersSubmit").live("click", function() {
		var name = $('#accName').val();
		var surname = $('#accSurname').val();
		var dob = $('#accDob').val();
		var url = $('#accLink').val();
		var bio = $('#accBio').val();
		
			var result = $.ajax({
					url: prUrl+"/ajax/ajax.php",
					data: "&type=userPers&name="+name+"&surname="+surname+"&dob="+dob+"&url="+url+"&bio="+bio,
					type: "GET",
					dataType: "text",
					timeout: 15000,     
					async:false,
					cache: false
				 }).responseText;
				var data = result.split('|');
				//if (data[0] == 1) {
					$("#submitPersMsgAcc").html(data[1]);
				//}		
	});
	
	$("#accBio, #wall_comments, #blog_comments").keyup(function() {
		var limit = 160;
		
		if ($(this).val().length > limit) {
			$(this).val($(this).val().substr(0,limit));
		} else {
			$('#charsLeft').text(parseInt(limit-$(this).val().length));	
		}
	});	
	
	$("#wall_comments, #blog_comments").focusout(function() {
		var limit = 160;	
		if ($(this).val().length == 0 || $(this).val() == wallYourComment+'...') {
			$('#charsLeft').text(limit);
		}
	});							 

	$("#accBookSubmit").live("click", function() {
		var bookies = $('select#bookies option:selected');
		if (bookies.length > 0) {
			if (bookies.length <= 3) {
				var sel = '';
				bookies.each(function() { 
					sel = sel + $(this).val()+'|';
				});	
				var result = $.ajax({
					url: prUrl+"/ajax/ajax.php",
					data: "&type=userBookies&bookies="+sel,
					type: "GET",
					dataType: "text",
					timeout: 15000,     
					async:false,
					cache: false
				 }).responseText;
				var data = result.split('|');
				if (data[0] == 1) {
					$("#submitBookMsgAcc").html(data[1]);
				}
			} else {
				alert('3 max');
			}
		} else {
			//alert('No selection made');
		}
	});
	
	
	$("#favTeamDelete").live("click", function() {
		$("#favTeamName").html('<i>'+noTeamSelected+'</i>');	
		$("#favTeamDelete").hide();		
		$("#favTeamBadge").hide();
		var result = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=favTeamDelete",
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;
	});
	
	$(".deleteFav").live("click", function() {
		var id = $(this).attr('id');
		$("#favTeam"+id).remove();
		var result = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=deleteFavs&team="+id,
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;
	});	

	$("#country").click(function() {
		var sel = $('select#country option:selected').val(); 
		$('#teamSel').css('display','block');
		var result = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=getTeamsDropDown&country="+sel,
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;
		var ddl = $("#teamDD"); 
		ddl.find('option').remove();
		 if (result.length > 0) {
			var data = result.split('||');
			for (i = 0; i < data.length; i++) {
				var team = data[i].split('|');
				ddl.append("<option value='" + team[0]+ "'>" + team[1] + "</option>");	
			}
		}
	});


	$("#country2").click(function() {
		var sel = $('select#country2 option:selected').val(); 
		$('#teamSel2').css('display','block');
		var result = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=getTeamsDropDown&country="+sel,
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;
		var ddl = $("#teamDD2"); 
		ddl.find('option').remove();
		 if (result.length > 0) {
			var data = result.split('||');
			for (i = 0; i < data.length; i++) {
				var team = data[i].split('|');
				ddl.append("<option value='" + team[0]+ "'>" + team[1] + "</option>");	
			}
		}
	});
	
	$(".submitCommentReply").live("click", function() {
		var id = $(this).parent('div').parent('td').parent('tr').attr('id');
		var pick = id.replace('row','');
		var com = $('#commentReply'+pick).val();	
		if (com.length == 0) {
			alert(commentsReplyEmpty);
		} else {
			var comments = com.replace(/\n/g,"<br>");//replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '<br />');
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=addCommentReply&comments="+comments+"&pick="+pick,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					//text: success/failure(0/1)||message||new div html
					var txt = text.split('||');
					if (txt[0] == 1) {
						$('#commentReply'+pick).val('');
						$('#newComments'+pick).append(txt[2].replace('~','|')); //restore previously converted | -> ~ for split('||')
						//$('#commentReplyMsg'+pick).html(txt[1]);
						alert(txt[1]);
					}
				}
			});
		}
	});

	$(".save_comments").live("click", function() {
		var html = $(this).parent().children('.tempTxt').val();
		var id = $(this).parent().children('.tempTxt').attr('id');
		var pick = id.replace('com','');
		var viewableText = $("<div>");
		viewableText.attr('class','commentsDiv');
		viewableText.attr('id',id);
		viewableText.html(html);
		// add to db
		var result = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=saveComments&pick="+pick+"&comments="+html,
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;	
		//text: success/failure(0/1)|message|num of comments
		var txt = result.split('|');
		$('#comments'+pick).text(txt[2]);
					
		//replace textarea with div
		$(this).parent().children('.tempTxt').replaceWith(viewableText);
		// setup the click event for this new div
		viewableText.click(divClicked);	
		//hide save & cancel img
		$(this).css('display','none');
		$(this).parent().children('.cancel_comments').css('display','none');		
	});

	$(".cancel_comments").live("click", function() {
		//var html = $(this).parent().children('.tempTxt').val();
		var id = $(this).parent().children('.tempTxt').attr('id');
		var pick = id.replace('com','');
		var html = $('#prev'+pick).val();
		var viewableText = $("<div>");
		viewableText.attr('class','commentsDiv');
		viewableText.attr('id',id);
		viewableText.html(html);
		//replace textarea with div
		$(this).parent().children('.tempTxt').replaceWith(viewableText);
		// setup the click event for this new div
		viewableText.click(divClicked);	
		//hide save & cancel img
		$(this).css('display','none');
		$(this).parent().children('.save_comments').css('display','none');
	});
	

	$(".commentsDiv").click(divClicked);	
	
	$(".close_comments").live("click", function() {
		//$(".cancel_comments").trigger('click');										
		$(this).parent('td').parent('tr').css("display","none");
	});	

	$(".addPickComments").live("click", function() {
		var pick = $(this).attr('pick');
		var user = $(this).attr('user');
						var offset = $(this).offset();
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=allowComments&pick="+pick,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					//text: no/yes(0/1)|message
					var txt = text.split('|');
					if (txt[0] == 0) {
						alert(txt[1]);
					} else {
											
/*						$(".infoCont").css("display","block");
						$(".infoCont").css("top",offset.top);
						$.ajax({
							url: prUrl+"/ajax/ajax.php",
							data: "&type=writeComments&pick="+pick,
							type: "GET",
							dataType: "text",
							timeout: 5000,
							cache: false,
							error: function(){
								//alert("Error loading XML document");
							},
							success: function(text){
								$(".infoContMain").html(text);
							}
						});	*/					
					}
				}
			});
	});	

	$(".matchStarted").live("mouseover", function() {	
		$(this).css("cursor", "help");			
	});

	$(".picks_report2").live("click", function() {
		var r=confirm(userConfirmReport);
			if ( r == true ) {
				var pick = $(this).attr('id');
				var id = pick.replace('reportR','');
				$.ajax({
					url: prUrl+"/ajax/ajax.php",
					data: "&type=reportComment&id="+id,
					type: "GET",
					dataType: "text",
					timeout: 15000,
					cache: false,
					error: function(){
						//alert("Error loading XML document");
					},
					success: function(text){
						//text: success/failure(0/1)|message
						var txt = text.split('|');
						alert(txt[1]);
					}
				});
		}
	});	
	
	$(".picks_report").live("click", function() {
		var r=confirm(userConfirmReport);
		if ( r == true ) {
			var pick = $(this).closest('.betInteractiveRow').attr('id');
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=reportPick&pick="+pick,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					//text: success/failure(0/1)|message|reports
					var txt = text.split('|');
					$('#report'+pick).text(txt[2]);
					alert(txt[1]);
				}
			});
		}
	});	

	$(".picks_like, .picks_dislike").live("click", function() {
		var pick = $(this).closest('.betInteractiveRow').attr('id');
		var vote = $(this).attr('vote');
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=votePick&pick="+pick+'&vote='+vote,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					//text: success/failure(0/1)|message|positive votes|negative votes
					var txt = text.split('|');
					$('#like'+pick).text(txt[2]);
					$('#dislike'+pick).text(txt[3]);
					alert(txt[1]);
				}
			});
	});	

	$(".picks_comments").live("click", function() {
		var pick = $(this).closest('.betInteractiveRow').attr('id');
		$('#row'+pick).css("display","table-row");
	});	

	$("#iframeCode").live("click", function() {
		if ($(this).val() != '') {
			$(this).select();
		}
	});	
	
	$("#formFootSubmit").live("click", function() {
		var emailVal = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var name = $("#fm_name").val().trim();
		var email = $("#fm_email").val();
		var comments = $("#fm_message").val().trim();
		
		if (name.length === 0 || name == defaultNameVal) {
			alert(contactNameEmptyAlert);
			return false;
		}

		if (email.length === 0) {
			alert(validateNoEMail);
			return false;
		} else {
			if (!emailVal.test(email)) {
				alert(validateInvalidEmail);
				return false;				
			}
		}
		
		if (comments.length === 0 || comments == defaultCommentsVal) {
			alert(contactCommentsEmptyAlert);
			return false;
		}	
		showOverlay();
		
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=contactForm&name="+name+"&subject=Contact&email="+email+"&comments="+comments,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
					hideOverlay();
				},
				success: function(text){
					txt = text.split('|');
					if (txt[0] > 0) {
						hideOverlay();
						alert(txt[1]);
					}
				}
			});
	});	

	$("#formSubmit").live("click", function() {
		var emailVal = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var name = $("#formName").val().trim();
		var email = $("#formEmail").val();
		var subject = $("#formSubject").val().trim();
		var comments = $("#formComments").val().trim();
		var captcha = $("#formCaptcha").val();
		
		$("#formSubmitMsg").html('');
		if (captchaIsWrong(captcha)) {
			$("#formCaptchaMsg").html(contactWrongCaptcha);
			return false;
		} else {
			$("#formCaptchaMsg").html('');
		}
		
		if (name.length === 0) {
			$("#formNameMsg").html(contactNameEmpty);
			return false;
		} else {
			$("#formNameMsg").html('');
		}

		if (email.length === 0) {
			$("#formEmailMsg").html(validateNoEMail);
			return false;
		} else {
			if (!emailVal.test(email)) {
				$("#formEmailMsg").html(validateInvalidEmail);
				return false;				
			} else {
				$("#formEmailMsg").html('');
			}
		}	
		
		if (subject.length === 0) {
			$("#formSubjectMsg").html(contactSubjectEmpty);
			return false;
		} else {
			$("#formSubjectMsg").html('');
		}
		
		if (comments.length === 0) {
			$("#formCommentsMsg").html(contactCommentsEmpty);
			return false;
		} else {
			$("#formCommentsMsg").html('');
		}
		
		$("#formSubmitMsg").html("<img src=\""+prUrl+"/images/ajax-loader.gif\">");
		$.ajax({
			//url: prUrl+"/ajax/ajax.php",
			url: "http://www.webworks.gr/apps/goals.gr/contact.php",
			data: "&type=contactForm&name="+name+"&subject="+subject+"&email="+email+"&comments="+comments,
			type: "GET",
			dataType: "text",
			timeout: 15000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(res){
				//txt=res.responseText.split("|");
				$("#formSubmitMsg").html("Ευχαριστούμε! Σύντομα κάποιο μέλος της ομάδας μας θα επικοινωνήσει μαζί σας.");
				//if (txt[0]=="1") {
					$("#formName").val("");
					$("#formEmail").val("");
					$("#formSubject").val("");
					$("#formComments").val("");
					$("#formCaptcha").val("");						
				//}
			}
		});			
	});	

	$("#generateCode").live("click", function() {
		$("#codeGenMsg").html("<img src=\""+prUrl+"/images/ajax-loader.gif\">");
		var backgroundPicker = $("#backgroundPicker").val(); //$_GET['bg']
		var borderPicker = $("#borderPicker").val(); //$_GET['brd']
		var matchTeamsPicker = $("#matchTeamsPicker").val(); //$_GET['tms']
		var matchTimePicker = $("#matchTimePicker").val(); //$_GET['min']
		var matchScorePicker = $("#matchScorePicker").val(); //$_GET['scr']
		var matchTeamScorePicker = $("#matchTeamScorePicker").val(); //$_GET['gl']
		var tickerWidth = 100;//$("#sliderWidth").html(); //$_GET['width']
		var coupon = $("input[name='coupon']:checked").val(); //$_GET['cpn']
		var wId = $("#webmasterId").val(); //$_GET['cpn']

		$("#codeGenMsg").html(codeSuccessfullyGenerated);
		$("textarea#iframeCode").val('<iframe src="'+prUrl+'/ticker/ticker.php?wid='+wId+'&bg='+backgroundPicker+'&brd='+borderPicker+'&tms='+matchTeamsPicker+'&min='+matchTimePicker+'&scr='+matchScorePicker+'&gl='+matchTeamScorePicker+'&cpn='+coupon+'&width='+tickerWidth+'" width="100%" height="50" frameborder="0"></iframe>');
	});	

	$("#saveCode").live("click", function() {	
		$("#codeGenMsg").html("<img src=\""+prUrl+"/images/ajax-loader.gif\">");
		var backgroundPicker = $("#backgroundPicker").val(); //$_GET['bg']
		var borderPicker = $("#borderPicker").val(); //$_GET['brd']
		var matchTeamsPicker = $("#matchTeamsPicker").val(); //$_GET['tms']
		var matchTimePicker = $("#matchTimePicker").val(); //$_GET['min']
		var matchScorePicker = $("#matchScorePicker").val(); //$_GET['scr']
		var matchTeamScorePicker = $("#matchTeamScorePicker").val(); //$_GET['gl']
		var tickerWidth = 100;//$("#sliderWidth").html(); //$_GET['width']
		var coupon = $("input[name='coupon']:checked").val(); //$_GET['cpn']
		var wId = $("#webmasterId").val(); //$_GET['cpn']

			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: '&type=saveCode&wid='+wId+'&tickerBackgroundColor='+backgroundPicker+'&tickerBorderColor='+borderPicker+'&tickerTeamsColor='+matchTeamsPicker+'&tickerTimeColor='+matchTimePicker+'&tickerScoreColor='+matchScorePicker+'&tickerTeamScored='+matchTeamScorePicker+'&tickerCoupon='+coupon+'&tickerWidth='+tickerWidth,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					txt = text.split('|');
					$("#codeGenMsg").html(txt[1]);
					if (txt[0] > 0) {
						$("textarea#iframeCode").val('<iframe src="'+prUrl+'/ticker/ticker.php?wid='+wId+'&bg='+backgroundPicker+'&brd='+borderPicker+'&tms='+matchTeamsPicker+'&min='+matchTimePicker+'&scr='+matchScorePicker+'&gl='+matchTeamScorePicker+'&cpn='+coupon+'&width='+tickerWidth+'" width="100%" height="50" frameborder="0"></iframe>');
					}
				}
			});	
		
	});	
	
	
	$("#userAccount").live("click", function() {
		var userData = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=getUserData",
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;
		var cur = $("#accountForm").html();
		$(".infoContMain").html(cur);	
		var uD = userData.split('|');
		$("#accUsername").val(uD[0]);
		$("#accEmail").val(uD[1]);
		$("#accId").val(uD[3]);
		$("#accUsername").attr("disabled",true);
		if (uD[2] == 0) {
			$("#accType1").attr("checked",true);
		} else if (uD[2] == 9) {
			$("#accType2").attr("checked",true);
		} else if (uD[2] == 10) {
			$("#accType1").attr("checked",true);
			$("#accType2").attr("checked",true);
		}
		//disable user type for admins
		if (uD[2] == 1) {
			$("#accType1").attr("disabled",true);
			$("#accType2").attr("disabled",true);
			//$("#accTypes").html("Administrator");
		}
		
		var offset = $(this).offset();
		$(".infoCont").css("display","block");
		$(".infoCont").css("top",offset.top+12);
		$(".infoCont").css("left",offset.left-530);	
	});
	
	$("#userRegister").live("click", function() {
		var form = $("#registrationForm").html();
		var offset = $(this).offset();
		$(".infoCont").css("display","block");
		$(".infoCont").css("top",offset.top+12);
		$(".infoCont").css("left",offset.left-530);											  
		$(".infoContMain").html(form);			
	});	
	
	$("#userForgot").live("click", function() {	
		var form = $("#passwordForm").html();
		var offset = $(this).offset();
		$(".infoCont").css("display","block");
		$(".infoCont").css("top",offset.top+12);
		$(".infoCont").css("left",offset.left-530);											  
		$(".infoContMain").html(form);			
	});	
	
	$("#fSubmit").live("click", function() {
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var usr = 	$("#fUsername").val();
		var email = 	$("#fEmail").val();
		if (usr.length === 0) {
			$("#usernameMsgF").html(validateNoUsername);
			return false;
		} else {
			$("#usernameMsgF").html('');	
		}
		if (email.length === 0) {
			$("#emailMsgF").html(validateNoEMail);
			return false;
		} else {
			if (!emailReg.test(email)) {
				$("#emailMsgF").html(validateInvalidEmail);
				return false;				
			} else {
				$("#emailMsgF").html('');
			}
		}
		$("#submitMsgF").html("<img src=\""+prUrl+"/images/ajax-loader.gif\">");
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=passwordRecovery&username="+usr+"&email="+email,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					txt = text.split('|');
					$("#submitMsgF").html(txt[1]);
					if (txt[0] > 0) {
						$("#fSubmit").attr('disabled', true);
						$("#fUsername").attr('disabled', true);
						$("#fEmail").attr('disabled', true);
					}
				}
			});	
	});	
	
	$("#regSubmit").live("click", function() {
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var usr = 	$("#regUsername").val();		
		var pwd = 	$("#regPassword").val();		
		var pwd2 = 	$("#regPassword2").val();		
		var email =	$("#regEmail").val();		
		var tp1 = 	$("#regType1").attr("checked");		
		var tp2 = 	$("#regType2").attr("checked");
		$("#submitMsg").html('');
		if (usr.length === 0) {
			$("#usernameMsg").html(validateNoUsername);
			return false;
		} else {
			if (usr.length < 5 || usr.length > 16) {
				$("#usernameMsg").html(validateInvalidUsername);
				return false;
			} else if (/\W/g.test(usr)) {
				$("#usernameMsg").html('Special Chars not allowed');
				return false;				
			} else if (!usernameAvailable(usr)) {
				$("#usernameMsg").html(validateUsernameNotAvailable);
				return false;
			}
			$("#usernameMsg").html('');
		}
		if (pwd.length === 0) {
			$("#passwordMsg").html(validateNoPassword);
			return false;
		} else {
			if (pwd.length < 5 || pwd.length > 16) {
				$("#passwordMsg").html(validateInvalidPassword);
				return false;
			}
			$("#passwordMsg").html('');	
		}
		if (pwd!= pwd2) {
			$("#passwordMsg").html(validatePasswordsNotMatch);
			return false;
		} else {
			$("#passwordMsg").html('');
		}
		if (email.length === 0) {
			$("#emailMsg").html(validateNoEMail);
			return false;
		} else {
			if (!emailReg.test(email)) {
				$("#emailMsg").html(validateInvalidEmail);
				return false;				
			} else {
				$("#emailMsg").html('');
			}
		}
		if (tp1 === false && tp2 === false) {
			$("#typeMsg").html(validateNoUserType);
			return false;
		} else {
			$("#typeMsg").html('');
		}
		$("#submitMsg").html("<img src=\""+prUrl+"/images/ajax-loader.gif\">");
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=userRegistration&username="+usr+"&password="+pwd+"&email="+email+"&type1="+tp1+"&type2="+tp2,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					txt = text.split('|');
					$("#submitMsg").html(txt[1]);
					if (txt[0] > 0) {
						$("#regSubmit").attr('disabled', true);
						$("#regUsername").attr('disabled', true);
						$("#regPassword").attr('disabled', true);
						$("#regPassword2").attr('disabled', true);
						$("#regEmail").attr('disabled', true);
						$("#regType1").attr('disabled', true);
						$("#regType2").attr('disabled', true);
					}
				}
			});		
	});
	
	$("#unibetSubmit").live("click", function() {
		var uId = 	$("#accId").val();	
		var usr = 	$("#unibetUsername").val();	
		if (usr.length == 0) { 
			$("#unibetUsernameMsgAcc").html(validateNoUsername);
			$("#ubSubmitMsgAcc").html('');
			return false;
		} else {
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=unibetUsername&uid="+uId+"&username="+usr,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					txt = text.split('|');
					$("#unibetUsernameMsgAcc").html(txt[1]);
					$("#ubSubmitMsgAcc").html('');
					if (txt[0] > 0 && user != '') {
						$("#unibetUsername").attr('disabled', true);
						//$("#unibetSubmit").attr('disabled', true);
					}
				}
			});			
		}
	});	
		
	$("#accSubmit").live("click", function() {
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var uId = 	$("#accId").val();		
		var oldUsr = 	$("#oldUsername").val();
		var usr = 	$("#accUsername").val();		
		var pwd = 	$("#accPassword").val();		
		var pwd2 = 	$("#accPassword2").val();		
		var email =	$("#accEmail").val();			
		var fbNew = $("#fbNew").val();			
		var pwdExists = $("#pwdExists").val();
		var changeUsr = 0;
				
		$("#submitMsgAcc").html('');
		if (fbNew == 1 && (usr != oldUsr)) {
			
					if (/\W/g.test(usr)) {
						$("#usernameMsgAcc").html('Special Chars not allowed');
						return false;
					}
			var result = $.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=checkUsernameAvailability&username="+usr,
				type: "GET",
				dataType: "text",
				timeout: 15000,     
				async:false,
				cache: false
			 }).responseText;
			
			txt = result.split('|');
			$("#submitMsgAcc").html(txt[1]);
			if (txt[0] == 1) {
				var changeUsr = 1;
			} else {
				return false;
			}

			
		}
		
		
			var user = '';
			if (changeUsr == 1) {	
				if (usr.length > 0) {
					if (usr.length < 5 || usr.length > 16) {
						$("#usernameMsgAcc").html(validateInvalidUsername);
						return false;
					} 
					$("#usernameMsgAcc").html('');
					user = '&username='+usr;
				}
				if (pwd.length == 0) {					
					$("#passwordMsgAcc").html(validateNoPassword);
					return false;
				}
			}
			if (pwdExists == '' && pwd.length == 0) {				
				$("#passwordMsgAcc").html(validateNoPassword);
				return false;
				
			}
				if (pwd.length > 0) {
						if (pwd.length < 5 || pwd.length > 16) {
						$("#passwordMsgAcc").html(validateInvalidPassword);
						return false;
					}
					$("#passwordMsgAcc").html('');
						if (pwd!= pwd2) {
						$("#passwordMsgAcc").html(validatePasswordsNotMatch);
						return false;
					} else {
						$("#passwordMsgAcc").html('');
					}			
				}
				if (email.length === 0) {
					$("#emailMsgAcc").html(validateNoEMail);
					return false;
				} else {
					if (!emailReg.test(email)) {
						$("#emailMsgAcc").html(validateInvalidEmail);
						return false;				
					} else {
						$("#emailMsgAcc").html('');
					}
				}
				var types = '';
				if ($("#accType1").is(":disabled")) {
					var tp1 = 	'false';		
					var tp2 = 	'false';
				} else {
					var tp1 = 	$("#accType1").attr("checked");		
					var tp2 = 	$("#accType2").attr("checked");
					if (tp1 === false && tp2 === false) {
						$("#typeMsgAcc").html(validateNoUserType);
						return false;
					} else {
						$("#typeMsgAcc").html('');
					}
					//types = "&type1="+tp1+"&type2="+tp2;		
					types = '';
				}
				$("#submitMsgAcc").html("<img src=\""+prUrl+"/images/ajax-loader.gif\">");
					$.ajax({
						url: prUrl+"/ajax/ajax.php",
						data: "&type=userAccount&uid="+uId+"&password="+pwd+"&email="+email+types+user,
						type: "GET",
						dataType: "text",
						timeout: 15000,
						cache: false,
						error: function(){
							//alert("Error loading XML document");
						},
						success: function(text){
							txt = text.split('|');
							$("#submitMsgAcc").html(txt[1]);
							if (txt[0] > 0 && user != '') {
								$("#accUsername").attr('disabled', true);
							}
						}
					});	
						
		
	});	
	
	$("#doLogin").live("click", function() {
		showOverlay();
		var usr = 	$("#loginUsr").val();		
		var pwd = 	$("#loginPwd").val();
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=doLogin&username="+usr+"&password="+pwd,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					if (text == 0) {
						hideOverlay();
						$("#loginMsg").html(loginFailed);
					} else {
						location.reload();
						//$("#userArea").html(loginWelcome+' '+usr+ ' <span class="userLink" id="doLogout">['+linkLogout+']</span><div><span class="userLink" id="userAccount">['+linkMyAccount+']</span></div>');
					}
				}
			});
	});
	
	$('.npSlide').live("click", function() {
		if ($(this).hasClass('forwardNp')) {								 
			$('.infiniteCarousel').trigger('next');
		} else if ($(this).hasClass('backNp')) {								 
			$('.infiniteCarousel').trigger('previous');
		}
	});

	$('#loginUsr, #loginPwd').keypress(function(event) {
	  if (event.which == '13') {
		  $("#doLogin").trigger('click');
/*			var usr = 	$("#loginUsr").val();		
			var pwd = 	$("#loginPwd").val();
				$.ajax({
					url: prUrl+"/ajax/ajax.php",
					data: "&type=doLogin&username="+usr+"&password="+pwd,
					type: "GET",
					dataType: "text",
					timeout: 15000,
					cache: false,
					error: function(){
						//alert("Error loading XML document");
					},
					success: function(text){
						if (text == 0) {
							$("#loginMsg").html(loginFailed);
						} else {
							$("#userArea").html(loginWelcome+' '+usr+ ' <span class="userLink" id="doLogout">['+linkLogout+']</span><div><span class="userLink" id="userAccount">['+linkMyAccount+']</span></div>');
						}
					}
				});*/
	   }
	});	
	
	$("#doLogout").live("click", function() {
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=doLogout",
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					window.location = prUrl;
					//location.reload();
					//$("#userArea").html("<input type=\"text\" id=\"loginUsr\" value=\"username\" onfocus=\"if(this.value=='username') this.value='';\" onblur=\"if(this.value=='') this.value='username';\"<input type=\"password\" id=\"loginPwd\" value=\"password\" onfocus=\"if(this.value=='password') this.value='';\" onblur=\"if(this.value=='') this.value='password';\"> <span class=\"doLogin\">LOGIN</span>");
				}
			});
	});
	$(".homeWin, .draw, .awayWin, .over, .under").live("click", function() {
		$(".homeWin, .draw, .awayWin, .over, .under").css("background-image", "url(/images/odd_btn.gif)");
		if ($(this).hasClass("disabled")) {
			$('#popupMsg').html(voteSelectionExists);	
		} else if ($(this).hasClass("noOdds")) {	
			$('#popupMsg').html(voteNoOdds);

		} else {
/*			if ($('#stake').val().length == 0) {
				$('#popupMsg').html('Please enter stake');
			} else if (isNaN($('#stake').val())) {	
				$('#popupMsg').html('Not a number');
			} else {*/
				$(this).css("background-image", "url(/images/odd_btn_inactive.gif)");
				var user = $("#voteUserId").val();
				var curGame = $("#voteMatchId").val();
				var type = $(this).attr("type");
				var sel = $(this).attr("sel");
				var param = $(this).attr("param");
				var odd = $(this).attr("odd");
/*				var pick = $(this).attr("id");
				$("#finalPick").val(pick);
				$('#popupMsg').html(voteConfirmSelection+': <br><span id="placeBet">'+voteConfirmYes+'</span>/<span id="noBet">'+voteConfirmNo+'</span>');	*/
				$("#voteSelection").val(user+'|'+curGame+'|'+type+'|'+sel+'|'+param+'|'+odd);	
				$('#popupMsg').html('<div id="addToSlip" class="btn190">'+bsAddToSlip+'</div>');
			//}
		}
	});	
	
	
	$("#delCoupon").live("click", function() {
		var j=0;
		var toDelete = [];
		elements = $("#bettingSlip").find('input.inc');
		elements.each(function() { 
			elemId = $(this).parent('td').parent('tr').parent('tbody').parent('table').parent('div').parent('div').attr('id');
			if ($(this).is(':checked')) {
				++j; 
				toDelete[toDelete.length] = elemId;
			}
		});	
		
		if (j==0) {
			displayMsg(bsNothingSelected,'bgRed');
		} else {
			for(var i=0; i<toDelete.length; i++) {
				var value = toDelete[i];
				$.ajax({
					url: prUrl+"/ajax/ajax.php",
					data: "&type=deleteSlipRow&id="+value,
					type: "GET",
					dataType: "text",
					timeout: 5000,
					cache: false,
					error: function(){
						//alert("Error loading XML document");
					},
					success: function(text) {
						$('#'+text).remove();
						elements = $("#bettingSlip").find('input.inc');
						if (elements.length == 0) {
							$("#slipToolbar").css('display','none');
							$("#bsMsg").html("");	
							$("#bsMsg").css('display','none');
							var result = $.ajax({
								url: prUrl+"/ajax/ajax.php",
								data: "&type=radioChanged&sel=single",
								type: "GET",
								dataType: "text",
								timeout: 15000,     
								async:false,
								cache: false
							 }).responseText;
							$('#singleBet').attr("checked",true);
							$('#comboBet').attr("checked",false);
							$('.couponEmpty').css('display','block');
						} else if (elements.length == 1) {
							$("#comboRow").css('display','none');
							var result = $.ajax({
								url: prUrl+"/ajax/ajax.php",
								data: "&type=radioChanged&sel=single",
								type: "GET",
								dataType: "text",
								timeout: 15000,     
								async:false,
								cache: false
							 }).responseText;
							$('#singleBet').attr("checked",true);
							$('#comboBet').attr("checked",false);
						}
					}
				});					
			}
			calculateComboOdd();	
		}
	});	
	
	$("#bsMsg").live("click", function() {
		$("#bsMsg").css("display","none");	
		$("#bsMsg").html("");	
	});	
	
	$(".tp").live("click", function() {
			var result = $.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=radioChanged&sel="+$(this).attr('id'),
				type: "GET",
				dataType: "text",
				timeout: 15000,     
				async:false,
				cache: false
			 }).responseText;	

	});	
	
	$("#placeBet").live("click", function() {


			var j=0;
			var toAdd = [];
			elements = $("#bettingSlip").find('input.inc');
			elements.each(function() { 
				elemId = $(this).parent('td').parent('tr').parent('tbody').parent('table').parent('div').parent('div').attr('id');
				//alert(elemId);
				if ($(this).is(':checked')) {
					++j; 
					toAdd[toAdd.length] = elemId;
				}
				//alert($(this).parents().map(function () { return this.tagName; }).get().join(", "));
				//alert($(this).parent('td').parent('tr').parent('tbody').parent('table').parent('div').parent('div').attr('id'));
			});	
	
			//return false;
			if (j==0) {
				displayMsg(bsNothingSelected,'bgRed');
			} else {
				//alert(toAdd.length);
				var radioSelection = $('input[name=betType]:checked').val();
				var stake = $('#stake').val();
				if (radioSelection == 'combo') {
					if (toAdd.length > 3) {
						displayMsg(bsComboMaxLimit,'bgRed');
					} else if (toAdd.length == 1) {
						displayMsg(bsComboMinLimit,'bgRed');
					} else {
						if (isNaN(stake) || stake == '' || stake < 5 || stake > 50) {
							displayMsg(bsInvalidStakeAmount,'bgRed');
						} else {
							var totOdd = $('#totOdd').html();
							var ids = getSelectedPicks();
							var result = placeBets(ids,radioSelection,stake,totOdd);					
						}
					}
				} else {
					if (isNaN(stake) || stake == '' || stake < 5 || stake > 50) {
						displayMsg(bsInvalidStakeAmount,'bgRed');
					} else {
						var ids = getSelectedPicks();
						var result = placeBets(ids,radioSelection,stake,0);					
					}
				}
			}

	});	
	
	$(".inc").live("click", function() {
		var cbId = $(this).parent('td').parent('tr').parent('tbody').parent('table').parent('div').parent('div').attr('id');
		if ($(this).is(':checked')) {
			var result = $.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=pickCheckbox&checked=1&id="+cbId,
				type: "GET",
				dataType: "text",
				timeout: 15000,     
				async:false,
				cache: false
			 }).responseText;
		} else {
			var result = $.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=pickCheckbox&checked=0&id="+cbId,
				type: "GET",
				dataType: "text",
				timeout: 15000,     
				async:false,
				cache: false
			 }).responseText;
		}
		calculateComboOdd();				   
	});	
	$(".addToBS").live("click", function() {
		showOverlay();
		var user = $(this).parent().parent().attr('uid');
		var curGame = $(this).parent().attr('id');
		var type = $(this).attr('type');
		var sel = $(this).attr('sel');
		var param = $(this).attr('param');
		var odd = $(this).attr('odd');
		if (odd == 0) {
			alert(voteNoOdds);
			setTimeout('hideOverlay()',1000);
			return false;
		}
		var result = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=checkSession",
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;	
		if (result == 0) {
			alert(voteNotLoggedIn);
			setTimeout('hideOverlay()',1000);
			return false;
		}

		setTimeout('hideOverlay()',2500);
		addToBettingSlip(user,curGame,type,sel,param,odd);
		$('.couponEmpty').css('display','none');
   });
	
	$("#addToSlip").live("click", function() {
		showOverlay();
		var voteSelection = $("#voteSelection").val()
		var vals = voteSelection.split('|');
		$(".infoCont").css("display","none");
		$(".infoContMain").html("<img src=\""+prUrl+"/images/ajax-loader.gif\">");
		var user = vals[0];
		var curGame = vals[1];
		var type = vals[2];
		var sel = vals[3];
		var param = vals[4];
		var odd = vals[5];
		setTimeout('hideOverlay()',2500);
		addToBettingSlip(user,curGame,type,sel,param,odd);
	});	
	
	$("#emptyCoupon").live("click", function() {
		$.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=emptyBettingSlip",
			type: "GET",
			dataType: "text",
			timeout: 5000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text) {
				toolbar = $("#slipToolbar").clone();
				$("#bettingSlip").html('');
				$("#bettingSlip").append(toolbar);
				$("#slipToolbar").css('display','none');
				$("#bsMsg").html("");	
				$("#bsMsg").css('display','none');
				$(".couponEmpty").css('display','block');
			}
		});											 
	});	

	$("#noBet").live("click", function() {
		$(".homeWin, .draw, .awayWin, .over, .under").css("background-image", "url(/images/odd_btn.gif)");
		$("#voteSelection").val(0);
		$('#popupMsg').html('');			
	});
	
	$("#doComp").live("click", function() {
		var selected = new Array();
		for (var i=0;i<4;++i) {
			if ($('#uc'+i).val().length > 0) {
				selected[selected.length] = $('#uc'+i).val();
			}

		}
		if (selected.length < 2) {
			alert(compareSelectMinTwo);
			return false;
		}
		var sel = '';
		for (i=0;i<selected.length;++i) {
			//alert(selected[i]);
			sel = sel+''+selected[i]+'|';
		}
		if ($("#chartdiv").is(":hidden")) {
			$('#chartdiv').slideDown('fast');
		}
		setTimeout('updateChart("'+sel+'")',2500);
	
		
	});
	
	$(".compareUsers").live("click", function() {
		elements = $("#rankings").find('input.compareUsers:checked');

		if (elements.length > 4) {
			alert('max 4');
			return false;
		}
		userId = $(this).val();
		if ($(this).is(':checked')) {
			var result = $.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=compareUsers&checked=1&id="+userId,
				type: "GET",
				dataType: "text",
				timeout: 15000,     
				async:false,
				cache: false
			 }).responseText;			
		} else {
			var result = $.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=compareUsers&checked=0&id="+userId,
				type: "GET",
				dataType: "text",
				timeout: 15000,     
				async:false,
				cache: false
			 }).responseText;			
		}
		var res = result.split('|');
/*		for(var i in res)
		{
			//alert(res[i]);
			var user = res[i].split('-');
			$('#uc'+i).val(user[1]);
			$('#comp'+i).html(user[0]);
		}*/
		for (var i=0;i<4;++i) {
			//alert(array_key_exists(i, res));
			if (array_key_exists(i, res) === true) {
				var user = res[i].split('-');
				$('#uc'+i).val(user[1]);
				$('#comp'+i).html(user[0]);				
			} else {
				$('#uc'+i).val('');
				$('#comp'+i).html('');					
			}
		}
	});	
	
	$("#triggerRegistration").click(function () {
		$("#userRegister").trigger('click');
	});	

	$("#showFavs").live("click", function() {	
		var result = $.ajax({
			url: prUrl+"/ajax/ajax.php",
			data: "&type=getFavs",
			type: "GET",
			dataType: "text",
			timeout: 15000,     
			async:false,
			cache: false
		 }).responseText;	
		if (result == '' && $(this).attr('class') == 'favOff') {
			alert(favouritesEmpty);
		} else {
			if ($(this).attr('class') == 'favOn') {
				$(this).removeClass().addClass("favOff");
				//$(this).html('Show favourites');
				
				$(".loadHolder").css("display","block");
				$(".liveHolder").css("display","none");
				$(".liveHolder2").css("display","none");
				$("div.toolIconCont").css("display","none");
				$("div.tools").css("display","none");
				$.ajax({
					url: prUrl+"/ajax/livedatainit.php",
					data: "&coupon="+coupon+"&favsOnly=0",
					type: "GET",
					dataType: "text",
					timeout: 15000,
					cache: false,
					error: function(){
						//alert("Error loading XML document");
					},
					success: function(text){
						var liveData=text.split("|");
						$(".liveHolder").html(liveData[0]);
						$(".liveHolder2").html(liveData[2]);
						$(".loadHolder").css("display","none");
						$(".liveHolder").css("display","block");
						$(".liveHolder2").css("display","block");
					}
				});					
			} else {
				$(this).removeClass().addClass("favOn");
				//$(this).html('Show all');
				
				$(".loadHolder").css("display","block");
				$(".liveHolder").css("display","none");
				$(".liveHolder2").css("display","none");
				$("div.toolIconCont").css("display","none");
				$("div.tools").css("display","none");
				$.ajax({
					url: prUrl+"/ajax/livedatainit.php",
					data: "&coupon="+coupon+"&fav=&favsOnly=1",
					type: "GET",
					dataType: "text",
					timeout: 15000,
					cache: false,
					error: function(){
						//alert("Error loading XML document");
					},
					success: function(text){
						var liveData=text.split("|");
						$(".liveHolder").html(liveData[0]);
						$(".liveHolder2").html(liveData[2]);
						$(".loadHolder").css("display","none");
						$(".liveHolder").css("display","block");
						//$(".liveHolder2").css("display","block");
					}
				});	
			}
		}
	});	
	
/*	$("#placeBet").live("click", function() {	
		var vals = $("#voteSelection").val().split('|');
		var user = vals[0];
		var curGame = vals[1];
		var type = vals[2];
		var sel = vals[3];
		var param = vals[4];
			$.ajax({
				url: prUrl+"/ajax/placeBet.php",
				data: "&fixture="+curGame+"&type="+type+"&sel="+sel+"&param="+param+"&user="+user,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					var txt = text.split('|');
					$.ajax({
						url: prUrl+"/ajax/vote.php",
						data: "&id="+curGame,
						type: "GET",
						dataType: "text",
						timeout: 5000,
						cache: false,
						error: function(){
							//alert("Error loading XML document");
						},
						success: function(text2){
							$(".infoContMain").html(text2);
							$('#popupMsg').html(txt[0]);
						}
					});
				}
			});			
	});*/
	
	$(".game").live("mouseover", function() {
		var offset = $(this).offset();
		$.doTimeout( "tools" );
		$("div.tools").css("top",offset.top-1);
		$("div.tools").css("display","block");
		$("#curGame").val("tools"+$(this).attr("id"));
		if ( $("#"+$(this).attr("id")).css("margin-bottom") == "0px" ) {
			$("div.tools").removeClass("tOn");
			$("div.tools").addClass("tOff");
		} else {
			$("div.tools").removeClass("tOff");
			$("div.tools").addClass("tOn");
		}
	});
	$(".liveHolder").live("mouseout", function() {
		if ( $("div.toolIconCont").css("display") == "none" ) {
			$.doTimeout( "tools", 1000, function(){
				$("div.tools").css("display","none");
			});
		}
	});
	$("div.tools").mouseover(function(){
		$.doTimeout( "tools" );
	});
	$("div.tools").mouseout(function(){
		if ( $("div.toolIconCont").css("display") == "none" ) {
			$.doTimeout( "tools", 1000, function(){
				$("div.tools").css("display","none");
			});
		}
	});
	$("div.tools").click(function(){
		var curGame = $("#curGame").val().replace("tools","");
		$("#expGame").val(curGame);
		$("div.game").animate({
			marginBottom: "0px"
		}, 250 );
		$("div.toolIconCont").css("display","none");
		if ( $("#"+curGame).css("margin-bottom") == "0px" ) {
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=getSoundClass&matchId="+curGame,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					$("div#tSound").removeClass();
					$("div#tSound").addClass("toolIcon");
					$("div#tSound").addClass(text);
				}
			});
			
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=getFavClass&matchId="+curGame,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					$("div#tFav").removeClass();
					$("div#tFav").addClass("toolIcon");
					$("div#tFav").addClass(text);
				}
			});
			


			$("#"+curGame).animate({
				marginBottom: "34px"
			}, 250, function() {
				$("div.tools").removeClass("tOff");
				$("div.tools").addClass("tOn");
				var offset = $("#"+curGame).offset();
				$("div.toolIconCont").css("top",offset.top+20);
				$("div.toolIconCont").css("display","block");

				$("div.tools").animate({
					top: offset.top-1
				}, 250);
			});
		} else {
			$("div.tools").removeClass("tOn");
			$("div.tools").addClass("tOff");
		}
	});
	
	
	$("div#rBoxHot").click(function(){
		$('#rBoxHotCont').toggle();	
		if ($(this).hasClass("ron")) {
			$(this).removeClass("ron");
			$(this).addClass("roff");			
		} else {
			$(this).removeClass("roff");
			$(this).addClass("ron");			
		}
	})	
	$("div#rBoxStats").click(function(){
		$('#rBoxStatsCont').toggle();
		if ($(this).hasClass("ron")) {
			$(this).removeClass("ron");
			$(this).addClass("roff");			
		} else {
			$(this).removeClass("roff");
			$(this).addClass("ron");			
		}	
	})
	$("div#rBoxVotes").click(function(){
		$('#rBoxVotesCont').toggle();	
		if ($(this).hasClass("ron")) {
			$(this).removeClass("ron");
			$(this).addClass("roff");			
		} else {
			$(this).removeClass("roff");
			$(this).addClass("ron");			
		}
	})
	$("div#rBoxSlip").click(function(){
		$('#rBoxSlipCont').toggle();	
		if ($(this).hasClass("ron")) {
			$(this).removeClass("ron");
			$(this).addClass("roff");			
		} else {
			$(this).removeClass("roff");
			$(this).addClass("ron");			
		}
	})
	$("div#rBoxMenu").click(function(){
		$('#rBoxMenuCont').toggle();	
		if ($(this).hasClass("ron")) {
			$(this).removeClass("ron");
			$(this).addClass("roff");			
		} else {
			$(this).removeClass("roff");
			$(this).addClass("ron");			
		}
	})
	$("div#rBoxSeri").click(function(){
		$('#rBoxSeriCont').toggle();	
		if ($(this).hasClass("ron")) {
			$(this).removeClass("ron");
			$(this).addClass("roff");			
		} else {
			$(this).removeClass("roff");
			$(this).addClass("ron");			
		}
	})
	$("div#rBoxNp").click(function(){
		$('#rBoxNpCont').toggle();	
		if ($(this).hasClass("ron")) {
			$(this).removeClass("ron");
			$(this).addClass("roff");			
		} else {
			$(this).removeClass("roff");
			$(this).addClass("ron");			
		}
	})
/*	$("div.rBoxHeaderSwitch").click(function(){
		
		if ( $(this).hasClass("ron") ) {
			$(this).removeClass("ron").addClass("roff");
		} else {
			$(this).removeClass("roff").addClass("ron");
		}
	});*/


	//rest toolbar data in animated-menu.js
	$(".tFacebook").click(function(){	
		var curGame = $("#expGame").val();
		
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=getSharingData&fixture="+curGame,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					var txt = text.split('|'); 
					shareIt(txt[1],txt[0],prUrl+'/images/logo.png');
				}
			});		
		
	});	
	
	$(".tTwitter").click(function(){	
		var curGame = $("#expGame").val();
		
			$.ajax({
				url: prUrl+"/ajax/ajax.php",
				data: "&type=getSharingData&fixture="+curGame,
				type: "GET",
				dataType: "text",
				timeout: 15000,
				cache: false,
				error: function(){
					//alert("Error loading XML document");
				},
				success: function(text){
					var txt = text.split('|'); 
					window.open('http://twitter.com/share?url='+txt[0]+'&via=goalsgr&text='+txt[1]);
				}
			});		
		
	});	
});

function dateNavLinks(){	
	$("#prevDay, #nextDay").live('click', function() {
		var date = $(this).attr('date');
		$(".loadHolder").css("display","block");
		$(".liveHolder").css("display","none");
		$(".liveHolder2").css("display","none");
		$("div.toolIconCont").css("display","none");
		$("div.tools").css("display","none");
		$.ajax({
			url: prUrl+"/ajax/livedatainit.php",
			data: "&date="+date+"&coupon="+coupon,
			type: "GET",
			dataType: "text",
			timeout: 15000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				var liveData=text.split("|");
				$(".liveHolder").html(liveData[0]);
				//$(".headerDate").text(liveData[1]);
				$(".liveHolder2").html(liveData[2]);
				$(".loadHolder").css("display","none");
				$(".liveHolder").css("display","block");
				$(".liveHolder2").css("display","block");

				copyAdsToLivescore();				
			}
		});
	});	
	
/*	$('#datepicker').datepicker({
		showOn: 'button',
		buttonImage: '/images/calendar.png',
		buttonImageOnly: true,
		showButtonPanel: true,
		dateFormat: 'yy-mm-dd'
	});
	$('#datepicker').datepicker($.datepicker.regional['el']);	*/
}
