// Global attributes

var subFormURL = 'http://www.aktuellproduktion.se/wp-content/themes/AktuellProduktion/sub_form.php';
var NLFormURL = 'http://www.aktuellproduktion.se/wp-content/themes/AktuellProduktion/nl_form.php'

//returns Ajax requests and parses it to Shadowbox
//Acceptrs data object and displays it in 
function handleAjax(data) {
   DisplaySB(data,'Prenumeration', 550, 750);
}
//Displays Shadowbox 

function DisplaySB(html, title, width, height){
	Shadowbox.open({
        content:    html,
        player:     "html",
        title:      title,
        height:     height,
        width:      width
    });
}
//submits the subscription form using POST
function SubmitSubscribe(form){
	sendPOST(subFormURL,$('#sub_form').serialize());
	$('#sub_form').slideUp();
	$('#message_post').css('visibility','visible').slideDown();
	return false;
}
function SubmitNewsletter(form){
	sendPOST(NLFormURL,$('#newsletter_form').serialize());
	$("#newsletter_form").hide();
	$("#newsletter_thanks").css('visibility','visible');
	return false;
}
function sendPOST(url,data) {
	$.post(url,data);
}

function closeSB(){
	window.parent.Shadowbox.close();
}

$(function(){//slideshow
 	$('#lofslidecontent45').lofJSidernews( { interval:6000,
										 	easing:'easeInOutQuad',
											duration:200,
											auto:true } );
	//cufon
  	$("li.page_item").hover(function () {Cufon.refresh();});
  	
    $('.sub_signup').hide();	    
 
 	//popup for items
    $('.media_item .content a').attr('rel="shadowbox"');
 	//opens all epapers in new window 
    $('a[href*="epaper"]').attr("target","_blank");
    
    $('#pr_join').click(function(){
	    var data = $('.pr_join_popup').html();
		DisplaySB(data,'Aktuell Produktion Press Releaser', 350, 350);
		return false;
    });
    $('#archive-toggle').click(function(){
     	$('#archive-wrap').toggle('fast', function() {});
    	return false;
    });
    //hide google branding for translate
    $('.google_branding').hide();
    //
    $('.translate_translate').addClass('button').text('Translate').css("border","1px solid");
    			
	//add quotes to blockquotes
	$('blockquote').prepend("<span>&ldquo;</span>");
	//style submitform submit button
	$('#submit_button').addClass('button');
	$('#submit_button').val('skicka');
    $('#sub_btn').click(function(){
		$.get(subFormURL, handleAjax);
	});		
	$('.more_cat').click(function(){  $('.cat_split').toggle(); return false;});
	$('.more_cat').toggle(function (){
	    $(this).text("- mindre taggar")
	    .stop();
	}, function(){
	    $(this).text("+ mer taggar")
	    .stop();
	});
																	
	// Tabs 
	$(".tabs a").click(function () {

		if (!$(this).hasClass("active")) {
		// switch all tabs off
		$(".active").removeClass("active");
		// switch this tab on
		$(this).addClass("active");
		// slide all elements with the class 'content' up
		$("#tab_box .content").slideUp();
		// Slides down active title attribute
		var content_show = $(this).attr("title");
		$("#"+content_show).slideDown();
		}
		return false;		
	});
	
	 $('.nl_email').click(function(){ 
	 	$(this).val('');
	 });
	
	//enables the user to enter a new user for newsletter
	$('#newsletter_thanks a').click(function(){ $("#newsletter_thanks").css('visibility','hidden'); $("#newsletter_form").val('Email Adress').show(); return false; });
	
	//closes  Shadowbox
	$('.shadowclose').click(function(){ 
	//window.parent.Shadowbox.close(); 
	$('#sb-overlay').trigger('click');
	});
	
});


