function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function reseTcover() {
    $(".cover").css("top","-10px");
}
function seTcover() {
    $(".cover").css("top","140px");
}

jQuery(function( $ ){
	$('a.navi').click(function(){
	$('#menu li a').removeClass('active');
	var fragment = this.getAttribute('title');
	$('#menu a[title=' + fragment + ']').toggleClass('active');
	});
});



/************************************************************************/// // CAPTION ///************************************************************************/
		
		
$(document).ready(function(){



				//Caption Sliding (Partially Hidden to Visible)
				$('.boxgrid.caption').hover(function(){
				 var jestelist=getCookie('listing');
				if(jestelist!='list-listing'){
					$(".cover", this).stop().animate({top:'100px'},{queue:false,duration:160});}
					
				}, function() {
				var jestelist=getCookie('listing');
				if(jestelist!='list-listing'){
					$(".cover", this).stop().animate({top:'140px'},{queue:false,duration:160});}
		
				});
				
				
				
//Sources submenu
$('#menu li').hover(
		function () {$('ul', this).slideDown(500);}, 
		function () {$('ul', this).slideUp(250);}
	);
		



	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");
	
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});		
	
	
	
	
	
	$(".changelisting").switchstylesheet( { seperator:"listing"} );
	$(".changecolor").switchstylesheet( { seperator:"color"} );
	$(".changelayout").switchstylesheet( { seperator:"layout"} );
});

$(function(){

             $('.slide-out-div').tabSlideOut({
                 tabHandle: '.handle',                              //class of the element that will be your tab
                 pathToTabImage: null,          //path to the image for the tab (optionaly can be set using css)
                 tabLocation: 'left',                               //side of screen where tab lives, top, right, bottom, or left
                 speed: 500,                                        //speed of animation
                 action: 'click',                                   //options: 'click' or 'hover', action to trigger animation
                 topPos: '100px',                                   //position from the top
                 fixedPosition: true                               //options: true makes it stick(fixed position) on scroll
         });
			 
			 
			 
// Top Login Panel	 
			 
 $("#joincommunity").click(function() {
 $("#loginformdiv").addClass("displaynone");
 $("#registerformdiv").removeClass("displaynone");
   });
   
 $(".loginagain").click(function() {
 $("#loginformdiv").removeClass("displaynone");
 $("#registerformdiv").addClass("displaynone");
   });
   
    $(".lost-pwd").click(function() {
 $("#loginformdiv").addClass("displaynone");
 $("#lpformdiv").removeClass("displaynone");
   });
	
	
	// Search Form Small
   
   $(".sform").submit(function() {
		var squery = $("#stext").val();
		var urlsf = "search-" + squery + ".html";
		$(".sform").attr("action",urlsf);
	});		 


	$("#stext").focus(function() {
 var svalue = $("#stext").val();
 if(svalue=="Search here...") {
 $("#stext").val('');
 }
});


	$("#stext").focusout(function() {
 var svalue = $("#stext").val();
 if(svalue=="") {
 $("#stext").val("Search here...");
 }
});


		// Search Form Big

$("#searchform").submit(function() {
var sources  = new Array();						
$("input[@name='sources[]']:checked").each(function() {
sources.push($(this).val());
});								
var sq = $("#searchtext").val();
var ur = "search.php?search=" + sq + "&sources=" + sources;
$("#searchform").attr("action",ur);
});	

	
	$("#searchtext").focus(function() {
 var stvalue = $("#searchtext").val();
 if(stvalue=="Search here...") {
 $("#searchtext").val('');
 }
});

$("#searchtext").focusout(function() {
 var stvalue = $("#searchtext").val();
 if(stvalue=="") {
 $("#searchtext").val('Search here...');
 }
});



		// Search Form Big
$.fn.addbook = function(id,user) {
    var url = "includes/skybookmark.php";
	var rodja=$('#internalresponse');
	$(rodja).html("loading...");					   
	$.get(
	url,
	{utd:id,utser:user},
	function(response) { $(rodja).html(response); },
	"html");
	};
	
	
$.fn.removebook = function(id,user) {
    var url = "includes/skybookmark.php";
	var rodja=$('#internalresponse');
	$(rodja).html("loading...");	
	$.get(
	url,
	{utd:id,utser:user,what:"remove"},
	function(response) { $(rodja).html(response); },
	"html");
	};
		
 $("#unselect").click(function() {
	$('input:checkbox').each( function() {
     this.checked = !this.checked;
});
   });
   		
		// Search Form Chrome Fix
		
		
		$("#searchtext").focus(function() {
			$("#searchtext").css("-webkit-box-shadow","none");	});
		
		
		$(".pembed").hover(function() {
			$(".pembed").css("-webkit-box-shadow","none");	});
		
			$(".search-wrapper").css("-webkit-box-shadow","none");
			$(".search-field").css("-webkit-box-shadow","none");

		
		$("#searchtext").hover(function() {
			$(".advsrch").css("display","block").stop();	});	

		// Opera Fix
		
if (window.opera) {
   $('#toppanel').css('left','820px');
   $('.slide-out-div').css('width','180px');
   $('.button').css('background','black');
}


});
