active=0;
var blokjes="a";

jQuery(document).ready(function(){
	setTimeout ( function() {
		jQuery('.succesMessage').slideUp('slow');
	}, 10000 );
	
	jQuery('input[name=password_myssimply]').attr('disabled' , true);
	jQuery('input[name=password-repeat_myssimply]').attr('disabled' , true);
	jQuery('input[name=old-password-changepass_myssimply]').attr('disabled' , true);
	
	jQuery('input[name=email_myssimply]').attr('disabled' , true);
	jQuery('input[name=old-password_myssimply]').attr('disabled' , true);	
	
	jQuery('input[name=change-email_myssimply]').click( function(e) {
		if(jQuery('input[name=change-email_myssimply]').attr('checked')) {
			jQuery('input[name=email_myssimply]').attr('disabled' , false);
			jQuery('input[name=old-password_myssimply]').attr('disabled' , false);
		} else {
			jQuery('input[name=email_myssimply]').attr('disabled' , true);
			jQuery('input[name=old-password_myssimply]').attr('disabled' , true);		
			jQuery('input[name=old-password_myssimply]').val('');
		}
	});
	
	jQuery('input[name=changepassword_myssimply]').click( function(e) {
		if(jQuery('input[name=changepassword_myssimply]').attr('checked')) {
			jQuery('input[name=password_myssimply]').attr('disabled' , false);
			jQuery('input[name=old-password-changepass_myssimply]').attr('disabled' , false);
			jQuery('input[name=password-repeat_myssimply]').attr('disabled' , false);
		} else {
			jQuery('input[name=password_myssimply]').attr('disabled' , true);
			jQuery('input[name=password-repeat_myssimply]').attr('disabled' , true);	
			jQuery('input[name=old-password-changepass_myssimply]').attr('disabled' , true);
			jQuery('input[name=old-password-changepass_myssimply]').val('');
			jQuery('input[name=password_myssimply]').val('');
			jQuery('input[name=password-repeat_myssimply]').val('');
		}
	});
	
	jQuery("#cartbox").click(function(event){
		document.location = "/cart";
	});
	
	jQuery("#cartbox").hover( 
			function(eventObject) {
				jQuery("#cartbox").css("cursor", "pointer")	;	
			}		
			, function(eventObject){
				jQuery("#cartbox").css("cursor", "default")	;
			}
	);
});



function shuffleImages( linksa, linksb, url ) 
{ 

	blokjes = (blokjes == "a") ? "b" : "a";
	var locId = 1;
	var links = ['link_1','link_2','link_3','link_4','link_5','link_6','link_7','link_8','link_9'];
	var images = ['img_1','img_2','img_3','img_4','img_5','img_6','img_7','img_8','img_9'];
	var bigImages = ['img_big_1','img_big_2','img_big_3','img_big_4','img_big_5','img_big_6','img_big_7','img_big_8','img_big_9'];
	var img_url = url;	

	if (!document.images) return

	if ( blokjes == 'a')
	{ 
		for (var i=0; i<links.length; i++) 
		{
			$(links[i]).href = linksa[i];
			$(images[i]).src = img_url+langId+'_'+locId+'_picture.jpg';
			$(bigImages[i]).src = img_url+langId+'_'+locId+'_big.gif';
			locId++;
		}
	} else {
	
		for (var i=0; i<links.length; i++) 
		{
			$(links[i]).href = linksb[i];
			$(images[i]).src = img_url+langId+'_'+locId+'_text.gif';
			$(bigImages[i]).src = img_url+langId+'_'+locId+'_big2.gif';
			locId++;
		}
	}
	
	setTimeout(function() {shuffleImages(linksa,linksb,img_url)},4000);

}

function activateHomeImg(div) {
	
	document.getElementById(div).style.display = 'block';
	document.getElementById('div_home').style.display = 'none';

}

function deactivateHomeImg(div) {
	
	document.getElementById(div).style.display = 'none';
	document.getElementById('div_home').style.display = 'block';

}

function changeLanguage( id )
{
    new Ajax.Request('/translate/', {
                method: 'post',
                parameters: {id: id},
                onSuccess : function(response){
                	var sURL = unescape(window.location.pathname);
					window.location.replace( sURL );
                }
            }
        );
}

function updateProductamount( id ){

	var amount;
	amount = document.getElementById('product_' + id).value;
    new Ajax.Request('/cart/updateproductamount', {
                method: 'post',
                parameters: {id: id, amount: amount},
                onSuccess : function(response){
					var sURL = unescape(window.location.pathname);
					window.location.replace( sURL );
                }
            }
        );
}

function removeProduct( id ){

    new Ajax.Request('/cart/removeproduct', {
                method: 'post',
                parameters: {id: id},
                onSuccess : function(response){
                	//alert( response.responseText );
					var sURL = unescape(window.location.pathname);
					window.location.replace( sURL );
                }
            }
        );
}

function changeCountry( id, addressType  ){
	var updateId;
	if( addressType == 'delivery' ) {
	
		updateId = 'update_delivery_province';
		
	} else {
		
		updateId = 'update_province';
		
	}
	
    new Ajax.Request('/cart/changecountry', {
                method: 'post',
                parameters: {id: id, addressType: addressType},
                onSuccess : function(response){
					document.getElementById(updateId).innerHTML = response.responseText;
                }
            }
        );
}

function toggleVisibility( id ) {

	if(document.getElementById(id).style.display == 'block') {
		 document.getElementById(id).style.display = 'none';
	} else {
		document.getElementById(id).style.display = 'block';
	}
			
}

function selectGiftservice() {

	if(document.getElementById('add_gifts').style.display == 'block') {
		new Ajax.Request('/cart/removegiftservice', {
	                method: 'post',
	                parameters: {},
	                onSuccess : function(response){
	                	//alert( response.responseText );
						var sURL = unescape(window.location.pathname);
						window.location.replace( sURL );
	                }
	            }
	        );
		 document.getElementById('add_gifts').style.display = 'none';
		 document.getElementById('no_gifts').style.display = 'block';
	} else {
		document.getElementById('add_gifts').style.display = 'block';
		document.getElementById('no_gifts').style.display = 'none';
	}
	
}

function selectGiftserviceAmount() {
	
	document.getElementById('page').value = 'same';
	
}

function toggleLogin( id ) {

	if(id == 'loginform') {
		 document.getElementById('address').style.display = 'none';
		 document.getElementById('loginform').style.display = 'block';
	} else {
		document.getElementById('address').style.display = 'block';
		 document.getElementById('loginform').style.display = 'none';
	}
			
}

function toggleDelivery( id ) {

	if(id == 'different_delivery') {
		 document.getElementById('delivery_address_fields').style.display = 'block';
	} else {
		 document.getElementById('delivery_address_fields').style.display = 'none';
	}
			
}

function changePayment( id ) {
	
	var commentCustomer;
	commentCustomer = document.getElementById('commentCustomer').value;

    new Ajax.Request('/cart/changepayment', {
                method: 'post',
                parameters: {id: id, commentCustomer: commentCustomer},
                onSuccess : function(response){
					var sURL = unescape(window.location.pathname);
					window.location.replace( sURL );
                }
            }
        );	
}

function removeExpress() {
	
    new Ajax.Request('/cart/removeexpress', {
                method: 'post',
                parameters: {},
                onSuccess : function(response){
				var sURL = unescape(window.location.pathname);
					window.location.replace( sURL );
                }
            }
        );	
}

function addExpress() {
	
	var commentCustomer;
	commentCustomer = document.getElementById('commentCustomer').value;

    new Ajax.Request('/cart/addexpress', {
                method: 'post',
                parameters: {commentCustomer: commentCustomer},
                onSuccess : function(response){
				var sURL = unescape(window.location.pathname);
					window.location.replace( sURL );
                }
            }
        );	
}

function changeShipping( ship_id ) {

	var id;
	if ( !ship_id )
	{
		id = document.getElementById('shippingId').value;
	} else id = ship_id;

	var commentCustomer;
	commentCustomer = document.getElementById('commentCustomer').value;

    new Ajax.Request('/cart/changeshipping', {
                method: 'post',
                parameters: {id: id, commentCustomer: commentCustomer},
                onSuccess : function(response){
                    //alert( response.responseText );
					var sURL = unescape(window.location.pathname);
					window.location.replace( sURL );
                }
            }
        );	
}

function submitGiftcertificate() {

	var code;
	code = document.getElementById('gift_code').value;
	var commentCustomer;
	commentCustomer = document.getElementById('commentCustomer').value;
		
    new Ajax.Request('/cart/submitgiftcertificate', {
                method: 'post',
                parameters: {code: code, commentCustomer: commentCustomer},
                onSuccess : function(response){
                    //alert( response.responseText );
					var sURL = unescape(window.location.pathname);
					window.location.replace( sURL );
                }
            }
        );
}

