// JavaScript Document
jQuery.fn.center = function(params) {

		var options = {

			vertical: true,
			horizontal: true

		}
		op = jQuery.extend(options, params);

   return this.each(function(){

		//initializing variables
		var $self = jQuery(this);
		//get the dimensions using dimensions plugin
		var width = $self.width();
		var height = $self.height();
		//get the paddings
		var paddingTop = parseInt($self.css("padding-top"));
		var paddingBottom = parseInt($self.css("padding-bottom"));
		//get the borders
		var borderTop = parseInt($self.css("border-top-width"));
		var borderBottom = parseInt($self.css("border-bottom-width"));
		//get the media of padding and borders
		var mediaBorder = (borderTop+borderBottom)/2;
		var mediaPadding = (paddingTop+paddingBottom)/2;
		//get the type of positioning
		var positionType = $self.parent().css("position");
		// get the half minus of width and height
		var halfWidth = (width/2)*(-1);
		var halfHeight = ((height/2)*(-1))-mediaPadding-mediaBorder;
		// initializing the css properties
		var cssProp = {
			position: 'absolute'
		};

		if(op.vertical) {
			cssProp.height = height;
			cssProp.top = '100%';
			cssProp.marginTop = halfHeight - 40;
		}
		if(op.horizontal) {
			cssProp.width = width;
			cssProp.left = '50%';
			cssProp.marginLeft = halfWidth;
		}
		//check the current position
		if(positionType == 'static') {
			$self.parent().css("position","relative");
		}
		//aplying the css
		$self.css(cssProp);


   });

};


	function resized() {
			w = $(window).width();
			if(w < 900){w = 900;}
			if(w >=1200){	w = 1200;}
			h = $("html").height();
			
		$(".wrapper").animate({width:w -100});
		//$(".footer").animate({width:w});
	
		};
	function makeTargets(){
		$("body").prepend("<div class=\"target top\"></div><div class=\"target bottom\"></div>");
		$(".navwrapper").prepend("<div class=\"target right\"></div>").append("<div class=\"target left\"></div>");
		$(".nav a.btn").wrap("<div class=\"btnwrap\"></div>").before("<div class=\"l\"></div>").after("<div class=\"r\"></div>");
		$(".pop").prepend("<div class=\"target popright\"></div>").append("<div class=\"target popleft\"></div><div class=\"target popbottom\"></div>");
		}
	var resizeTimer = null;
	$(window).bind('resize', function() {
			if (resizeTimer) clearTimeout(resizeTimer);
			resizeTimer = setTimeout(resized, 500);
		}); 
	
	function onOut(){
		$(".on").fadeOut("slow").removeClass("on");
	}
	
	function ovOut(){
		$("#ov").fadeOut("fast");
		$("a.btn.home").fadeOut("slow");
		//$("html").css({overflow:"auto"});
		onOut();
		
	
	}
	function ovOver(){
				$("#ov").fadeIn("fast");
				$("a.btn.home").fadeIn("slow");
				//$("html").css({overflow:"hidden"});

		}

 


$(document).ready(function() {
		
		
		resized();
		makeTargets();
		$(".target").mouseover(ovOut);
		$(".pop").hide();
		$("#ov").hide();
		$(".nav").mouseover(ovOver);
		$(".nav a.btn").mouseover(function(){
																		z =	$("#"+this.rel+"Pop").css("z-index");
																		z = z+10;
																	 $("#"+this.rel+"Pop").fadeIn("slow").addClass("on").css("z-index",z);
					});
		$(".subPubSearch").click(function(){$(".subPubSearch").addClass("open").animate({height:"60px",backgroundPosition:"0px -27px"});});
		$(".subCat").click(function(){$(".subCat").addClass("open").animate({height:"300px",backgroundPosition:"0px -27px"});});

		$(".r").mouseover(function(){$(".on").fadeOut("slow");});
		$(".l").mouseover(function(){$(".on").fadeOut("slow");});

		$("#ov").click(ovOut);
		$(".searchText").focus(function(){$(".searchText").animate({backgroundColor:"white"})});
 		
		 $(document).ready(function(){
    
    $(".content form input").focus(function(){$(this).css('backgroundColor','#eee');});
		$(".content form input").blur(function(){$(this).css('backgroundColor','#fff');});
		
		$("input.searchText").focus(function(){$(this).css('backgroundColor','#fff');});
		$("input.searchText").blur(function(){$(this).css('backgroundColor','#dd0404');});


  });


});




/* -- junk
$(".footer").mouseover(function(){ovOut();});
		$(".logo").mouseover(function(){ovOut();});
$(".right").animate({left:w - 900});
		$(".left").animate({right:w -240});
  	$(".footerLeft").animate({right:w -550});
		$(".pop").animate({left:w - 888});




$("li").hover(
      function () {
        $(this).append($("<span> ***</span>"));
      }, 
      function () {
        $(this).find("span:last").remove();
      }
    );




$(document).ready(function() {
   $(window).bind('resize', function() {
			$(window)															 
																		 
			alert('hey!');
													 
													 
	});

});
$(".nav").animate({left:"50px"});			
$(window).bind('resize', function() {


});

function move() {
   	$(".nav").animate({left:"50px"});
};

*/