$(document).ready(function(){

	//City Scroller
	var ScrollLength = 104;
	$(".ScrollDown").click(function() {
	var position = $("#Scroller > #Items > #ItemsScroll").css("margin-top").replace("px", "")-ScrollLength;
	var height = $("#Scroller > #Items > #ItemsScroll").height();
		if(position>-height){
			$("#Scroller > #Items > #ItemsScroll").animate({
				marginTop:position + "px"
			}, 800);
		}
	});
	$(".ScrollUp").click(function() {
	var position = parseInt($("#Scroller > #Items > #ItemsScroll").css("margin-top").replace("px", ""))+ScrollLength;
		if(position<ScrollLength){
			$("#Scroller > #Items > #ItemsScroll").animate({
				marginTop:position + "px"
			}, 800);
		}
	});
		
	//Add TipAFriend
	 $(".TipAFriendMaster").clone().prependTo(".TipAFriend");
	 
	 //Home Link
	 if(location.href.indexOf("ShowInvitation=true")>=0) showVideo();
});


//Equal Coloumns - function called from flash
/*function CityScrollLoaded() {
	var rightcol = $("#RightColumnParent").height();
	var leftcol = $("#LeftColumn").height()-rightcol;
	alert("L: "+rightcol+" | R:"+rightcol);
	$("#CityScroll").css("height",leftcol-rightcol);
}*/

function CityScrollLoaded2() {
	var heightHeaderBox=153;
	var greyBox3=null;
	if($(".GreyBox").length==3) greyBox3 = 298;
	var sumHeightGreyBox=410 + greyBox3;
	sumHeightRightColumn = sumHeightGreyBox + heightHeaderBox;

	switch(parseInt($("#LeftColumn .CityBox").length)){
		case 2:
			sumHeightRightColumn-=10;
			break;
		case 3:
			sumHeightRightColumn-=30;
			break;
		case 4:
			sumHeightRightColumn-=50;
			break;
		case 5:
			sumHeightRightColumn-=70;
			break;
		case 6:
			sumHeightRightColumn-=90;
			break;
		case 7:
			sumHeightRightColumn-=110;
			break;
		case 8:
			sumHeightRightColumn-=130;
			break;
		case 9:
			sumHeightRightColumn-=150;
			break;
		case 10:
			sumHeightRightColumn-=170;
			break;
		case 11:
			sumHeightRightColumn-=190;
			break;
		case 12:
			sumHeightRightColumn-=210;
			break;
		case 13:
			sumHeightRightColumn-=230;
			break;
		case 14:
			sumHeightRightColumn-=250;
			break;
		case 15:
			sumHeightRightColumn-=270;
			break;
		case 16:
			sumHeightRightColumn-=290;
			break;
		case 17:
			sumHeightRightColumn-=310;
			break;
	}
		
	if(sumHeightRightColumn<sumHeightLeftColumn){
		if(NZAreaID==52||NZAreaID==48){
			$("#CityScroll").css("height","2100px");
		}
		else
		{
			$("#CityScroll").css("height",(sumHeightLeftColumn-sumHeightRightColumn));//+parseInt($("#LeftColumn .CityBox").length)*15);
		}
	}
	else
	{
		//alert("Grrr!!!");
	}
}

var sumHeightLeftColumn;
$(document).ready(
	function(){
		var sumHeightCityBox=0;
		$("#LeftColumn .CityBox").each(
			function(n){
				sumHeightCityBox += parseInt($(this).height());
			}
		)
		sumHeightLeftColumn = sumHeightCityBox + parseInt($(".HeaderBox").height()) + parseInt($(".ScrollerBox").height());
});

function GoHome(){
	location.href = location.href.slice(0,location.href.lastIndexOf('/')) + "/?AreaID=" + NZAreaID;
}

//function GoHome(){
//	switch(NZAreaID){
//		case 36://Global
//			document.location.href="/?id=178";
//			break;
//	}
//}


function showVideo() {
	
	var flashvars = {
		//languageISO: DwLang
	};	
	var params = {
		scale: "noScale",
		AllowScriptAccess: "always",
		wmode: "transparent"
	};
	swfobject.embedSWF("/Files/System/BoConcept/Flash/VideoPlayer/VideoPlayer.swf", "VideoPlayer", "610", "352", "9.0.0", "/Files/System/BoConcept/JS/sefobject/expressInstall.swf", flashvars, params);
	
	$.blockUI({
		message: $('#VideoPlayer'),
		css: {
			backgroundColor: '',
			border:'',
			width:'60%',
			top:'15%',
			left:'20%'
		},
		overlayCSS: {
			backgroundColor: '#000',
			opacity: '0.85',
			cursor: ''
		},
		allowBodyStretch: true
	});
}

function closeVideo() {
	$.unblockUI();
}