$(document).ready(function() {

if (document.getElementById("emailbox")) document.getElementById("emailbox").style.left = document.body.clientWidth/2-251 + "px";

document.getElementById("GX_workercv").style.left = document.body.clientWidth/2-420 + "px";
if (document.getElementById("GX_regBox")) { document.getElementById("GX_regBox").style.left = document.body.clientWidth/2-251 + "px"; }
if (document.getElementById("loading")) { 
$("#loading").css("position", "absolute");
document.getElementById("loading").style.left = document.body.clientWidth/2-20 + "px"; 

var YTop = document.body.offsetTop/2 + 500+ "px";

		$("#loading")	.ajaxStart(function(){
		//alert(YTop);
			$("#loading").show();

			$(document).mousemove(function(e) {
				$("#loading").css({
				top: e.pageY,
				left: e.pageX
				});
			});
			
		}).ajaxComplete(function(){
			$("#loading").hide();
		});
		
}
		
if (document.getElementById("GX_message")) { document.getElementById("GX_message").style.left = document.body.clientWidth/2-251 + "px"; }


$("#GX_message").draggable();
$("#GX_regBox").draggable();

$("#SendEmail").click(function() {
	$("#emailbox").show("explode").draggable();
});

if (document.getElementById("AU_Scroller")) {
	$("#AU_Scroller #AU_SC_item").cycle({
	fx: 'scrollUp',
	speed: 300,
	timeout: 2000
	}).mousewheel();

}

/*$('input.special').example(function() {
	return $(this).attr('title');
});*/

  $("#GX_RightRegbutton").click(function() {
	var api = $("#GX_regBox").expose({api: true}).load();
	});  

	$("#GX_RegButton").click(function() {
	 katt();
	}); 
	
	LoadLogin();

	$("#GX_MenuNav li").hover(
				function(){ $("ul", this).fadeIn("fast"); }, 
				function() { } 
			);
			
	  	if (document.all) {
				$("#GX_MenuNav li").hoverClass ("sfHover");
			} 
			
	$("* input").addClass("ui-state-highlight ui-corner-all");

		
		$("#job-types-c").click(function() {
			$("#GX_centerSelector .joblist").slideToggle("slow");
		});

	$("#job-types ul.joblist").sortable({
									connectWith: '#job-types ul.joblist',
									cursor: 'move', 
									Start: function() {
									  // none
									}
									}).accordion({ tabs: 'li h2' });



	$(".fg-button").hover(
	function(){ 
		$(this).addClass("ui-state-hover"); 
	},
	function(){ 
		$(this).removeClass("ui-state-hover"); 
	});


	$("#education-c").click(function() {
				$("#educationNews").slideToggle("slow");
		});
		
	$("#new-jobs-c").click(function() {
				$("#NewJobs").toggle("slow");
		});
		
				
		$("#tabs").tabs({ fx: { opacity: 'toggle' } });
		
}); 

		
	$(function() {

		//run the currently selected effect
		function runEffect(){
		//get effect type from 
			var selectedEffect = 'clip';
			
	//most effect types need no options passed by default
			var options = {};
		

//check if it's scale, transfer, or size - they need options explicitly set
			if(selectedEffect == 'scale'){  options = {percent: 100}; }
			
		//run the effect
			$("#GX_regBox").show(selectedEffect,options,500, callback);
			
		};
		
		//callback function to bring a hidden box back
		function callback(){
		document.getElementById("GX_regBox").style.display="block";
		document.getElementById("GX_regBox").style.visibility="visible";	
		};
		
		//set effect from select menu value
	$("#GX_RegButton").click(function() {
		runEffect();
		return false;
	});


	$("#GX_closeRegbox").click(function() {
	$("#GX_regBox").hide("explode");	
	var api = $("#GX_regBox").expose({api: true}).close();
	});
	
	
	var Opts = [{size:48, distance:54, fadeIn:1000}];
			
		$('#dock').jqDock(Opts[0]);
		$('#comp_dock').jqDock(Opts[0]);
				
		$('#dock').css("opacity", ".80");
		$('#comp_dock').css("opacity", ".80");

	});


function LoadLogin() {
		$("#GXHeadLogin").hide();

		$("#HeadLoginBtn").click(function() {
			$("#logIcon").toggleClass("ui-icon-circle-arrow-n");
		});
		
		$("span#HeadLoginBtn").click(function(){
			$("#GXHeadLogin").slideToggle("slow,");
		});
	}
				
	$.fn.hoverClass = function(c) {
			return this.each(function(){
				$(this).hover( 
					function() { $(this).addClass(c);  },
					function() { $(this).removeClass(c); }
				);
			});
		};	  	
		
$(function () { 
	// Stack initialize
	var openspeed = 300;
	var closespeed = 300;
	$('.stack>img').toggle(function(){
		var vertical = 0;
		var horizontal = 0;
		var $el=$(this);
		$el.next().children().each(function(){
			$(this).animate({top: '-' + vertical + 'px', left: horizontal + 'px'}, openspeed);
			vertical = vertical + 55;
			horizontal = (horizontal+.75)*2;
		});
		$el.next().animate({top: '-50px', left: '10px'}, openspeed).addClass('openStack')
		   .find('li a>img').animate({width: '50px', marginLeft: '9px'}, openspeed);
		$el.animate({paddingTop: '0'});
	}, function(){
		//reverse above
		var $el=$(this);
		$el.next().removeClass('openStack').children('li').animate({top: '55px', left: '-10px'}, closespeed);
		$el.next().find('li a>img').animate({width: '79px', marginLeft: '0'}, closespeed);
		$el.animate({paddingTop: '35px'});
	});
	
	// Stacks additional animation
	$('.stack li a').hover(function(){
		$("img",this).animate({width: '56px'}, 100);
		$("span",this).animate({marginRight: '30px'});
	},function(){
		$("img",this).animate({width: '50px'}, 100);
		$("span",this).animate({marginRight: '0'});
	});
	
});

