var win = null;
function newWindow(mypage,myname,w,h,features) {
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += features;
	win = window.open(mypage,myname,settings);
	if (win == null) alert(popupmessage);
	else win.window.focus();
}

function HideCartButton(divId) {
    $(divId).style.display = "none";
}


function addItemToCart(guid){
	if (document.getElementById('basket_small').style.display == "") {
		Effect.BlindUp('basket_small', { duration: 0.5 });
		setTimeout("Effect.BlindDown('basket_small', { duration: 0.5 });",650)
	}	
	
	if (document.getElementById('basket_small').style.display == "none") {
		Effect.BlindDown('basket_small', { duration: 0.5 });
	}		
	
	var url = '/ajax/itemToCart.asp';
	var pars = 'itemGuid=' + guid;
	
	var myAjax = new Ajax.Updater(
		'basket_small', 
		url,
		{
			method: 'get', 
			parameters: pars
			//onSuccess: addItemToCartSuccess
		});
	
}

function addItemToRent(guid) {
	if (document.getElementById('rentList_small').style.display == "") {
		Effect.BlindUp('rentList_small', { duration: 0.5 });
		setTimeout("Effect.BlindDown('rentList_small', { duration: 0.5 });",650)
	}	
	
	if (document.getElementById('rentList_small').style.display == "none") {
		Effect.BlindDown('rentList_small', { duration: 0.5 });
	}    
	
	var url = '/ajax/itemToRent.asp';
    var pars = 'itemGuid=' + guid;

    var myAjax = new Ajax.Updater(
		'rentList_small',
		url,
		{
		    method: 'get',
		    parameters: pars
		    //onSuccess: addItemToCartSuccess
		});	

}

function EvaluateDiscountCode(discountCode) {
    var url = '/ajax/discount.asp';
    var pars = 'discountCode=' + discountCode;

    var myAjax = new Ajax.Updater(
		'divDiscountOutput',
		url,
		{
		    method: 'get',
		    parameters: pars
		    //onSuccess: addItemToCartSuccess
		});

}

//Maleri-visning (store knapper)
function show_AddTo_bubble(bubbleId, btnActive_A, btnActive_B, inactiveBtnId_A, inactiveBtnId_B){
	var btnPosition = Element.positionedOffset(btnActive_A);
	//alert(btnPosition.left)
	$(bubbleId).style.left = (btnPosition.left+30) + 'px';
	$(bubbleId).style.top = (btnPosition.top-90) + 'px';
	Effect.Appear(bubbleId, { duration: 0.1 });
	//Effect.BlindDown(bubbleId, { scaleX:true, duration: 0.1  });
	setTimeout("Effect.Fade('"+bubbleId+"', { duration: 1.0 });",2000)
	$(btnActive_A).style.display = "none";
	$(btnActive_B).style.display = "none";
	$(inactiveBtnId_A).style.display = "block";
	$(inactiveBtnId_B).style.display = "block";
}

//Maleri-liste (små kanpper - ikoner)
function show_AddTo_bubble_list(bubbleId, btnActive_A, btnActive_B, inactiveBtnId_A, inactiveBtnId_B){
	var btnPosition = Element.positionedOffset(btnActive_A);
	//alert(btnPosition.left)
	$(bubbleId).style.left = (btnPosition.left-6) + 'px';
	$(bubbleId).style.top = (btnPosition.top-90) + 'px';
	Effect.Appear(bubbleId, { duration: 0.1 });
	//Effect.BlindDown(bubbleId, { scaleX:true, duration: 0.1  });
	setTimeout("Effect.Fade('"+bubbleId+"', { duration: 1.0 });",2000)
	$(btnActive_A).style.display = "none";
	$(btnActive_B).style.display = "none";
	$(inactiveBtnId_A).style.display = "block";
	$(inactiveBtnId_B).style.display = "block";
}

//Highslide popup-vindue
function popupAddToBasket(btnActive_B, btnActive_A, inactiveBtnId_B, inactiveBtnId_A){
	$(btnActive_B).style.display = "none";
	$(btnActive_A).style.display = "none";
	$(inactiveBtnId_B).style.display = "block";
	$(inactiveBtnId_A).style.display = "block";
}

//Highslide popup-vindue - forside
function popupAddToBasket_frontpage(btnActive_B, inactiveBtnId_B){
	$(btnActive_B).style.display = "none";
	$(inactiveBtnId_B).style.display = "block";
}

//Kvittering - efter sendt kommentar for rabatkode
function receiptToggle(divId_a, divId_b){
	Effect.BlindUp(divId_a, { duration: 0.7 });
	setTimeout("Effect.BlindDown('"+divId_b+"', { scaleY:true, duration: 0.7  });",700)
}

function toggle(id){
	if (document.getElementById(id).style.display == "none") {
		Effect.BlindDown(id, { duration: 0.5 });
	}
	else {
		Effect.BlindUp(id, { duration: 0.5 });
	}
}

//Funktionen virker ikke når den blot kaldes toogle - derfor denne kopi
function toggle_new(id){
	if (document.getElementById(id).style.display == "none") {
		Effect.BlindDown(id, { duration: 0.5 });
	}
	else {
		Effect.BlindUp(id, { duration: 0.5 });
	}
}

function toggle_three(id_a, id_b, id_c){
	if (document.getElementById(id_a).style.display == "none") {
		Effect.BlindDown(id_a, { duration: 0.5 });
	}
	else {
		Effect.BlindUp(id_a, { duration: 0.5 });
	}
	
	if (document.getElementById(id_b).style.display == "none") {
		Effect.BlindDown(id_b, { duration: 0.5 });
	}
	else {
		Effect.BlindUp(id_b, { duration: 0.5 });
	}
	
	if (document.getElementById(id_c).style.display == "none") {
		Effect.BlindDown(id_c, { duration: 0.5 });
	}
	else {
		Effect.BlindUp(id_c, { duration: 0.5 });
	}	
}

/* Samme som ovenstående funktion - blot med fade */
function toggle_three_fade(id_a, id_b, id_c){
	if (document.getElementById(id_a).style.display == "none") {
		setTimeout("Effect.Appear('"+id_a+"', { duration: 0.3  });",300)
	}
	else {
		Effect.Fade(id_a, { duration: 0.3 });
	}
	
	if (document.getElementById(id_b).style.display == "none") {
		setTimeout("Effect.Appear('"+id_b+"', { duration: 0.3  });",300)
	}
	else {
		Effect.Fade(id_b, { duration: 0.3 });
	}
	
	if (document.getElementById(id_c).style.display == "none") {
		Effect.BlindDown(id_c, { duration: 0.5 });
	}
	else {
		Effect.BlindUp(id_c, { duration: 0.5 });
	}	
}

function fpBuyOrRent(id_a, id_b, id_c){
	if (document.getElementById(id_a).style.display == "none") {
		Effect.BlindDown(id_a, { duration: 0.5 });
	}
	else {
		Effect.BlindUp(id_a, { duration: 0.5 });
	}
	
	Effect.BlindUp(id_b, { duration: 0.5 });
	Effect.BlindUp(id_c, { duration: 0.5 });
}

function HideItem(id) {
	if (document.getElementById(id).style.display == "") {
		Effect.BlindUp(id, { duration: 0.5 });
	}	
}

function adress_alt_delivery(show) {
	if(show)
	{
		document.getElementById('customerPickup').checked=false;
		
		if (document.getElementById('otherAdrToggle').style.display == "none") {
			Effect.BlindDown('otherAdrToggle', { duration: 0.5 });
		}
		else {
			Effect.BlindUp('otherAdrToggle', { duration: 0.5 });
		}											
	}
	
	else
	{
		document.getElementById('otherDeliveryAddress').checked=false;
		
		if (document.getElementById('otherAdrToggle').style.display == "") {
			Effect.BlindUp('otherAdrToggle', { duration: 0.5 });
		}											
	}
}

function sendMail(){
var mailText = $('discountComment').value;
var customerName = $('customerName').value;
var customerEmail = $('customerEmail').value;
	var url = '/ajax/receipt_sendCommentMail.asp';
	var pars = 'mailText='+ mailText + '&customerName='+ customerName + '&customerEmail='+ customerEmail;
	var myAjax = new Ajax.Request(
		url,
		{
			method: 'get', 
			parameters: pars
		});
}


// Opdaterer med parametre
function updateFAQ(id, divId, bulletId){
	var url = '/ajax/update_faq.asp';
	var pars = 'id='+ id;
	var myAjax = new Ajax.Updater(
		divId, //Id på div som skal opdateres 
		url,
		{
			method: 'get', 
			parameters: pars,
			onComplete: function() {hs.htmlExpand($(bulletId));}
		});
}



/*
// Opdaterer med parametre
function sendMail2(){
mailText = $('discountComment').value
customName = $('customName').value
	var url = '/ajax/receipt_sendCommentMail.asp';
	var pars = 'mailText='+ mailText + '&customName='+ customName;
	var myAjax = new Ajax.Updater(
		'testDiv', //Id på div som skal opdateres 
		url,
		{
			method: 'get', 
			parameters: pars
		});
}
*/


/*
// Opdaterer blot indhold
function sendMail3(){
	var url = '/ajax/receipt_sendCommentMail.asp';
	var myAjax = new Ajax.Updater(
		'testDiv', 
		url,
		{
			method: 'get', 
		});	
}
*/

// Slide imellem serier på forsiden - 3 mest populære serier
var currentFp
var i_1 = 0
var i_2 = 0
var i_3 = 0

var fpCount_1 = 3
var fpCount_2 = 3
var fpCount_3 = 3

var fp_1 = new Array();
var fp_2 = new Array();
var fp_3 = new Array();

fp_1[0] = 'cFade1';
fp_1[1] = 'cFade2';
fp_1[2] = 'cFade3';

fp_2[0] = 'cFade4';
fp_2[1] = 'cFade5';
fp_2[2] = 'cFade6';

fp_3[0] = 'cFade7';
fp_3[1] = 'cFade8';
fp_3[2] = 'cFade9';

var playTween_1 = true
var playTween_2 = true
var playTween_3 = true

restartType = 0
delay = 7000

function restartTween_1() {
	if (playTween_1 == false && restartType_1 == 1) {
		playTween_1 = true;
		tween_1();
	} else if (playTween_1 == false && restartType_1 == 2) {
		playTween_1 = true;
		opacityTween_1.start();
	}
}

function restartTween_2() {
	if (playTween_2 == false && restartType_2 == 1) {
		playTween_2 = true;
		tween_2();
	} else if (playTween_2 == false && restartType_2 == 2) {
		playTween_2 = true;
		opacityTween_2.start();
	}
}

function restartTween_3() {
	if (playTween_3 == false && restartType_3 == 1) {
		playTween_3 = true;
		tween_3();
	} else if (playTween_3 == false && restartType_3 == 2) {
		playTween_3 = true;
		opacityTween_3.start();
	}
}

function tween() {
	tween_1();
	tween_2();
	tween_3();
}

function tween_1() {
	if (i_1 == fpCount_1) {
		i_1 = 0
	}

	opacityTween_1 = new OpacityTween(document.getElementById(fp_1[i_1]), Tween.strongEaseOut, 100, 0, 0.5);
	opacityTween_1.onMotionFinished = function() {
		document.getElementById(fp_1[i_1]).style.display = "none";
		i_1++;
		if (i_1 == fpCount_1) {
			i_1 = 0
		}
		opacityTween_1 = new OpacityTween(document.getElementById(fp_1[i_1]), Tween.strongEaseIn, 0, 100, 0.5);
		opacityTween_1.onMotionFinished = function() {
			if (playTween_1 == true) {
				setTimeout('tween_1()', delay);
			} else {
				restartType_1 = 1
			}
		}
		document.getElementById(fp_1[i_1]).style.display = "block";
		opacityTween_1.start();
	};
	if (playTween_1 == true) {
		opacityTween_1.start();
	} else {
		restartType_1 = 2
	}
}

function tween_2() {
	if (i_2 == fpCount_2) {
		i_2 = 0
	}

	opacityTween_2 = new OpacityTween(document.getElementById(fp_2[i_2]), Tween.strongEaseOut, 100, 0, 0.5);
	opacityTween_2.onMotionFinished = function() {
		document.getElementById(fp_2[i_2]).style.display = "none";
		i_2++;
		if (i_2 == fpCount_2) {
			i_2 = 0
		}
		opacityTween_2 = new OpacityTween(document.getElementById(fp_2[i_2]), Tween.strongEaseIn, 0, 100, 0.5);
		opacityTween_2.onMotionFinished = function() {
			if (playTween_2 == true) {
				setTimeout('tween_2()', delay);
			} else {
				restartType_2 = 1
			}
		}
		document.getElementById(fp_2[i_2]).style.display = "block";
		opacityTween_2.start();
	};
	if (playTween_2 == true) {
		opacityTween_2.start();
	} else {
		restartType_2 = 2
	}
}

function tween_3() {
	if (i_3 == fpCount_3) {
		i_3 = 0
	}

	opacityTween_3 = new OpacityTween(document.getElementById(fp_3[i_3]), Tween.strongEaseOut, 100, 0, 0.5);
	opacityTween_3.onMotionFinished = function() {
		document.getElementById(fp_3[i_3]).style.display = "none";
		i_3++;
		if (i_3 == fpCount_3) {
			i_3 = 0
		}
		opacityTween_3 = new OpacityTween(document.getElementById(fp_3[i_3]), Tween.strongEaseIn, 0, 100, 0.5);
		opacityTween_3.onMotionFinished = function() {
			if (playTween_3 == true) {
				setTimeout('tween_3()', delay);
			} else {
				restartType_3 = 1
			}
		}
		document.getElementById(fp_3[i_3]).style.display = "block";
		opacityTween_3.start();
	};
	if (playTween_3 == true) {
		opacityTween_3.start();
	} else {
		restartType_3 = 2
	}
}

