// JavaScript Document

// Target _blank fix
function externalLinks() 
{  
	if (!document.getElementsByTagName) 
		return;  
	var anchors = document.getElementsByTagName("a");  
	for (var i=0; i<anchors.length; i++) 
	{  
  		var anchor = anchors[i];  
  		if (anchor.getAttribute("href") &&  anchor.getAttribute("rel") == "external")  
    		anchor.target = "_blank";  
	}  
}  
window.onload = externalLinks;


// KUNDVAGN
$(document).ready(
function() 
{			
	$("#cart_trigger").click(function()
	{
		$("#cart_info_wrapper").slideDown('slow');	
		document.getElementById('cart_trigger').style.display='none';
		document.getElementById('cart_trigger_open').style.display='inline-block';
	});

	$("#cart_trigger_open").click(function()
	{
		$("#cart_info_wrapper").slideUp('slow');
		document.getElementById('cart_trigger').style.display='inline-block';
		document.getElementById('cart_trigger_open').style.display='none';
	});
	
	$("#cart_trigger_open_empty").click(function()
	{
		$("#cart_info_wrapper").slideUp('slow');
		document.getElementById('cart_trigger_open_empty').style.display='none';
	});

}
);

// SEARCH BOX
$(function() {
	swapValues = [];
	$(".swap_value").each(function(i){
		swapValues[i] = $(this).val();
		$(this).focus(function(){
			if ($(this).val() == swapValues[i]) {
				$(this).val("");
			}
		}).blur(function(){
			if ($.trim($(this).val()) == "") {
				$(this).val(swapValues[i]);
			}
		});
	});
});

// Open new window
function openNewWindow(URLtoOpen, windowName, windowFeatures) { newWindow=window.open(URLtoOpen, windowName, windowFeatures); }

function openWindowCenter(pageURL, title,w,h) {
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 


function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

			

function toggle_close()
{
	var e = document.getElementById('delbetalning');
	e.style.display = 'none';
}
			
function toggle_visibility() 
{
	var e = document.getElementById('delbetalning');
	if(e.style.display == 'none')
		e.style.display = 'block';
	else
		e.style.display = 'block';
}			

// Mediaplatta framsida
$(document).ready(function() {
		$('#media_content') 
		.after('<div id="nav">') 
        .cycle({ 
        fx:     'fade', 
		speed:  '1000',
        timeout: 5000, 
        pager:  '#nav',
		cleartype:  1
	    });
        });

// Mediaplatta Kampanj
$(document).ready(function() {

		//$("#myDiv").css("border","3px solid red");
//		$("#test1").show(2000);
//		$("#test1").hide("slow");
//		$("#test1").fadeOut(2000);
		$('#media_content_campaign') 
		.after('<div id="nav">') 
        .cycle({ 
        fx:     'fade', 
		speed:  '1000',
        timeout: 5000, 
        pager:  '#nav',
		delay:   -3000,
		cleartype:  1
	    });
        });

// LEVEL 2 MediaPlatta; INSPIRATION;
$(document).ready(function() {
	        $('#inspiration_content') 
	        .after('<div id="nav">') 
			.cycle({
	        fx:     'fade', 
	        speed:  '1000', 
	        timeout: 6000, 
	        pager:  '#nav',
			cleartype:  1
	        });
	        });

// LEVEL 3 MediaPlatta; // uterum / uterumspartier/wg25

 $(document).ready(function() {
        $('#mContent') 
        .after('<div id="nav">') 
        .cycle({ 
        fx:     'fade', 
        speed:  '1000', 
        timeout: 8000, 
        pager:  '#nav',
		cleartype:  1
        });
        });
 
 // LEVEL 2 MediaPlatta; // kompletta / Välj uterum efter säsong

 $(document).ready(function() {
        $('#season_content') 
        .after('<div id="nav2">') 
        .cycle({ 
        fx:     'fade', 
        speed:  '1000', 
        timeout: 20000, 
        pager:  '#nav2',
		cleartype:  1
        });
		
		
		
		var size = $('#nav2').children().size();
		for (a = 0; a < size; ++a) {
			var title = $('#season_content').children().eq(a).find('div img').attr('title');
			$('#nav2').children().eq(a).html('<em>'+ title +'</em>');
		}
		
		
        });
 
 // Mediaplatta thumbs

 

        