// JavaScript Document


var current_menu = "";
var li = '';
function show_menu(menu)
{
	if(current_menu!=menu)
		hide_menu()
	$("#"+menu).fadeIn(200)
	current_menu = menu;	
	$("."+menu).addClass("selected");
}

function hide_menu()
{
	if(current_menu!='')
	{
		$("#"+current_menu).hide(); 
		$("."+current_menu).removeClass("selected");
		return true;
	}
}

var current_host = "";
function show_host(host)
{
	if(current_host!=host)
	hide_host()
	$("#"+host).fadeIn(300)
	current_host = host;	
	$("."+host).addClass("selected");
}

function hide_host()
{
	if(current_host!='')
	{
		$("#"+current_host).hide() 
		$("."+current_host).removeClass("selected");
		return true;
	}
}


function default_value(text,Obj)
{
	if($(Obj).val()=='')
		$(Obj).attr('value',text)
}

function toggle_button(id)
{
	if($(id).css("background-position") !='0px -18px')
	{
		$(id).css("background-position","0px -18px");
		$(id).css("color","#09c");
	}else{
		$(id).css("background-position","0px 0px");
		$(id).css("color","#333");
	}	
}

function toggle_social() {
	
	$(".hide_social").click(					 
		function() {
			$('.hide_social').css( { 'display' : 'none' });
			$('.show_social').css( { 'display' : 'block' });
			$('#social_icons').stop().animate( { right: "-37px" }, 600);
			$.cookie("status","hidden");
	});
	
	$(".show_social").click(					 
		function() {
			$('.hide_social').css( { 'display' : 'block' });
			$('.show_social').css( { 'display' : 'none' });
			$('#social_icons').stop().animate( { right: "0" }, 600,"easeOutBounce");
			$.cookie("status","shown");
	});	
	
	var state = $.cookie('status');
	
	if( state == 'hidden') {
		$('.hide_social').css( { 'display' : 'none' });
		$('.show_social').css( { 'display' : 'block' });
		$('#social_icons').css( {'right' : '-37px'} )
	}
}

function big_img(src)
{
	$("#big_thumb").attr('src',src);
}

function check_download(id)
{
	var page=baseurl+'/check_download.php';
	$.post(page,
		   {
			   id : id
		   },
		   function(data)
		   {
				if(data)
				{
					window.location = data.dlink;
				}else
				{
					// load the contact form using ajax
					$.get(baseurl+"js/ajax/contact.php?id="+id, function(data){
					// create a modal dialog with the data
					$(data).modal({
					closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
					position: ["15%",],
					overlayId: 'contact-overlay',
					containerId: 'contact-container',
					onOpen: contact.open,
					onShow: contact.show,
					onClose: contact.close
					});
					});
					
					
					// preload images
					var img = ['cancel.png', 'form_bottom.gif', 'form_top.gif', 'loading.gif', 'send.png'];
					$(img).each(function () {
					var i = new Image();
						i.src = imageurl+'contact/' + this;
					});
				}
		   },
		   "json"
		   );
}