$(document).ready(function() {
	alignWebsite();
	initHash();
	
	$(window).bind('resize', function() {
		alignWebsite();
	});
	
	$('#content').fadeTo(600,0.83);
	$('#ad').fadeTo(600,0.90);	
	$('#sidebar iframe').fadeTo(600,0.80);	




	$("a[href*='#']:not([href*='#!'])").live("click",function(){

		var oldlink = $(this).attr("href"); 
		var oldlink_plain = oldlink.split('#');
		var newlink = "/deeplink.php?link=" + oldlink_plain[1];

		if($('#ContentFrame').length == 0){
			$('#content').html('<iframe id="ContentFrame" name="main" frameborder="0" bgcolor="#13368d" style="background-color:#13368d;" src="/index.php?load=Profile"></iframe>');
			$('#ContentFrame').attr("src",newlink); 
			
		}else{
			$('#ContentFrame').attr("src",newlink); 
		}

		return false;
	});

	
	$('#pmerk').live("click",function(){
		if($(this).attr('checked') == "checked"){	
			show_notice_close();
		}
	});
	
	$('.creategaynews').live("click",function(){
			gaynews_notice_show();
			return false;
			
	});
	
	
	
	$("a[href*='#!']").live("click",function(){
	  var oldlink = $(this).attr("href"); 
	  var oldlink_plain = oldlink.split('#!');
	  var newlink = "/ajax.php?" + oldlink_plain[1];
		$('#content').load(newlink);			
		return false;
	});


});

function alignWebsite(){
	var windowHeight = $(window).height();
	var headerHeight = $('#header').height();
	var barHeight = $('#bar').height();
	var subHeight = 1;
	var middleHeight = windowHeight - headerHeight - barHeight - subHeight;
	$('.dynheight').css('height', middleHeight);		
}

function initHash(){
	if(window.location.hash){
	  var oldlink = window.location.hash; 
	  var oldlink_plain = oldlink.split('#');
	  var newlink = "/deeplink.php?link=" + oldlink_plain[1];
	  $('#ContentFrame').attr('src',newlink);
	}
}

function login_notice_close(){
	$("#layer8743").hide();
	$(".layerbg").hide();
}

function show_notice_close(){
	$(".layerbg").show();
	$("#layer8743").show();

}

function gaynews_notice_close(){
	$("#layer8744").hide();
	$(".layerbg").hide();
}

function gaynews_notice_show(){
	$(".layerbg").show();
	$("#layer8744").show();

}


