
function positionMain(){
	if($(window).height()>631){
		$('#container').css('top',(($(window).height()-630)/2)+"px");
												
	}else{
		$('#container').css('top','0px');
	}
	
}



$(window).resize(function(){
	positionMain();
});

$(document).ready(function(){
						   
	positionMain();
	
	$.get("/proxy.php?url=http://pipes.yahoo.com/pipes/pipe.run?_id=AvN6Vu4p3hGwN_kpwjSbTQ&_render=rss", function(data){
				var theText = $(data).find("a").eq(0).text();
				$("#title .box").text(theText);
																							
	});
	
	
	
	$("div#menu a").each(function(){
								  if(getLinkID("id", $(this).attr("href")) ==pageID){
									  $(this).addClass("active");
									  
								  }
								  
								  });
	
	$("div#menu a[class!=active]").bind("mouseenter", function(){
	  $(this).stop();
	 
	  $(this).animate({ 
        top: "0px"
      },  {duration:100 , queue:false } );
											});
	
	
	$("div#menu a[class!=active]").bind("mouseleave", function(){
	  $(this).stop();
	  $(this).animate({ 
        top: "10px"
      }, {duration:100 ,complete:moveMenuBG, queue:false });
												});
	
	
	
	$("div#moonform input.email").attr("value", "your email here").attr("dvalue", "your email here");
	$("div#moonform input.check").attr("value", "? , e.g. \"6\"").attr("dvalue", "? , e.g. \"6\"");
	
	$("input.text").focus(function(){
							 $(this).attr("value", "");
							  });
	
	$("input.text").blur(function(){
							 if ($(this).attr("value") == "" || $(this).attr("value") == undefined ||$(this).attr("value") == null){
														  $(this).attr("value", $(this).attr("dvalue"));
														  
														}
							  });
	/*
	
	
	$("div#cam img").attr("size", "small").click(function(){
		if($(this).attr("size") == "small"){
			$(this).attr("size", "big").width(320).height(240);
		}else{
			$(this).attr("size", "small").width(64).height(48);
		}
	});
	*/
	
	/*
	$("div#moonform textarea").attr("value", "type your message here").attr("dvalue", "type your message here");
	
	$("div$moonform input").focus(function(){alert("hey");
														  //$(this).attr("value", "");
														  });
	
	$("div$moonform input[type=text]").blur(function(){
														if ($(this).attr("value") == ""){
														  $(this).attr("value", $(this).attr("dvalue"));
														  
														}
														  });
	*/
	$("embed").attr("wmode", "opaque");
	$(".lightbox").lightbox();
	 $('.scroll-pane').jScrollPane();
	$("a.mainNav").corner("top");
	$(".roundtop").corner("top");
	//blinkStar();
	flyUFO();
	setInterval( "flyUFO()", 20000);
	
});


function flyUFO(){
	
	var destY = Math.ceil(Math.random()*($(window).height()-100))+"px";
	$("#ufo").stop().css("top", Math.ceil(Math.random()*($(window).height()-100))+"px").css("left", "-300px").animate({ 
        left: "100%", top: destY
      },  {duration:6000 , queue:false } );
}



function getLinkID( name ,string)
{
 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
 var regexS = "[\\?&]"+name+"=([^&#]*)";
 var regex = new RegExp( regexS );
 var results = regex.exec(string);
 if( results == null )
 return "";
 else
 return results[1];
}
function getURLID( name )
{
 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
 var regexS = "[\\?&]"+name+"=([^&#]*)";
 var regex = new RegExp( regexS );
 var results = regex.exec( window.location.href );
 if( results == null )
 return "";
 else
 return results[1];
}

function moveMenuBG()
{
//$(this).css("backgroundPosition", "0 8px");	
}
 
 function loadPage(urlstring){
	 
	 
	  $.ajax({
	  url: urlstring,
	  cache: false,
	  success: function(html){
		$("#results").append(html);
	  }
	});
 }
 
function fbCallback(data){
	alert(data);
	};
	
function blinkStar(){
	$("#moonstar").fadeOut(1000, function(){
							$("#moonstar").fadeIn(1000, function(){
																blinkStar();  
																  });
										   });
}
