var google_account_code = 'UA-18389643-1';

/* Regular expressions */
var telRegExp = /([0-9-]+){11}|([0-9]+){10}/; 
var timeRegExp = /^(\d{1,2}):(\d{2})$/;
var emailRegExp = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.([a-zA-Z]){2,4})$/;
var postcodeRegExp = /^([0-9]){4}([a-zA-Z]){2}$/;
var relpath = "http://www.poeziepaleis.nl";

function confirm_goto(question, url) {
	var cbox = confirm(question);
	if(cbox == true) {
		window.location = url;
	}
}

$(document).ready(function() {
	// contact form
	$("#contact_submit").click(function(){
		
		if($('#input_name').val() == ""){
			$('#contact_form_error span').html('Het veld naam is verplicht en mag niet leeg zijn');
			$('#contact_form_error').show();
		} else if($('#input_email').val() == ""){
			$('#contact_form_error span').html('Het veld email is verplicht en mag niet leeg zijn');
			$('#contact_form_error').show();
		} else if(!emailRegExp.test($('#input_email').val())){
			$('#contact_form_error span').html('Het veld email is onjuist');
			$('#contact_form_error').show();
		} else if($('#input_message').val() == ""){
			$('#contact_form_error span').html('Het veld bericht is verplicht en mag niet leeg zijn');
			$('#contact_form_error').show();
		} else {
			$('#contact_real_form').submit();
		}
		
    });
});	

function sign_up_newsletter(){

	$.ajax({
		type: "POST",
		url: relpath+"/newsletter_action.php",
		data: "email="+$("#newsletter_email").val(),
		success: function(msg){
			if(msg == "succes"){
				$("#newsletter_form").html("U bent succesvol aangemeld voor onze nieuwsbrief");
			} else if(msg == "error"){
				alert("U heeft een onjuist e-mail adres ingevuld");
			}
		}
	});

}

/* Winkelwagen functies */

shop_ajax = new AjaxHandler('shop');

function fill_cart_top(){
	fill_cart_top_items();
}
function fill_cart_top_price(){
	shop_ajax.setParser('cart');
	shop_ajax.setVar('cart_action','get_total');
	shop_ajax.setCallback('callback_fill_cart_top_price');
	shop_ajax.sendRequest();
}
function fill_cart_top_items(){
	shop_ajax.setParser('cart');
	// shop_ajax.setVar('cart_action','total_items');
	shop_ajax.setVar('cart_action','total_items_with_word');
	shop_ajax.setCallback('callback_fill_cart_top_items');
	shop_ajax.sendRequest();
}

function callback_fill_cart_top_price(content, type){
	document.getElementById('cart_total_inner').innerHTML = content;
}
function callback_fill_cart_top_items(content, type){
	document.getElementById('cart_items_inner').innerHTML = content;
	fill_cart_top_price();
}

function add_to_cart(cart_variant, cart_qty, callback_function) {
	
	shop_ajax.setParser('cart');
	shop_ajax.setVar('cart_action','add');
	shop_ajax.setVar('cart_variant', cart_variant);
	shop_ajax.setVar('cart_qty', cart_qty);
	if(callback_function != ""){
		shop_ajax.setCallback(callback_function);
	}
	shop_ajax.sendRequest();

}

function added_to_cart() {
	fill_cart_top();
	document.getElementById('added_to_cart').style.display = 'block';
}
function kassakoopje_added_to_cart() {
	fill_cart_top();
	document.getElementById('kassakoopje_to_cart').style.display = 'block';
}

function fill_login_as(customer){
	shop_ajax.setParser('customer');
	shop_ajax.setVar('customer_action','login_name');
	shop_ajax.setVar('customer_id', customer);
	shop_ajax.setCallback('callback_fill_login_as_continue_to_address');
	shop_ajax.sendRequest();	
}

function callback_fill_login_as_continue_to_address(content, type){
	document.getElementById('logged_in_as').innerHTML = content;
	$('#logged_in').addClass("active");
	continue_to_address();
}

function logout(){

	shop_ajax.setParser('customer');
	shop_ajax.setVar('customer_action','logout');
	shop_ajax.setCallback('callback_logout');
	shop_ajax.sendRequest();
}
function callback_logout(content, type){
	document.getElementById('logged_in_as').innerHTML = "";
	$('#logged_in').removeClass("active");
	window.location.reload();	
}
	
/* Jquery functions 
$(document).ready(function() {
	$('#menu div.menu_box_inner:not(.last, .active)').mouseover(function(){ 
		$(this).css('background-color', '#ffffff'); 
		$(this).animate({height: '120px'}, 'fast', function(){
			$(this).find('.menu_box_inner_box').stop().show();
		});
	});
	$('#menu div.menu_box_inner:not(.last, .active)').mouseleave(function(){ 
		if($(this).hasClass('active')){
			$(this).animate({height: '73px'}, 'fast', function(){
				$(this).find('.menu_box_inner_box').stop().hide();
			});
		} else {
			$(this).animate({height: '50px'}, 'fast', function(){
				$(this).find('.menu_box_inner_box').stop().hide();
				$(this).css('background-color', '#ebf2f7');
			});
		}
	});
	
	$('#menu div.menu_box_inner.last:not(.active)').mouseover(function(){ 
		$(this).css('background', '#ffffff'); 
		$(this).animate({height: '120px'}, 'fast', function(){
			$(this).find('.menu_box_inner_box').stop().show();
		});
	});
	$('#menu div.menu_box_inner.last:not(.active)').mouseleave(function(){ 
		if($(this).hasClass('active')){
			$(this).animate({height: '73px'}, 'fast', function(){
				$(this).find('.menu_box_inner_box').stop().hide();
			});
		} else {
			$(this).animate({height: '50px'}, 'fast', function(){
				$(this).find('.menu_box_inner_box').stop().hide();
				$(this).css('background', 'url('+relpath+'/skins/default/images/bg_contact_header.png) no-repeat right top');
			});
		}
	});	
	
	$("#slider").easySlider({
		continuous: true,
		auto:		true,
		pause:		8000,
		speed:		1000
	});
	
	//$(function() {
	$('#photo_album_photos .photo a').lightBox();
	//});	
	
	var content_height = ($("#content_container").height() - 90);
	$("#content_right_inner").css('min-height', content_height+'px');
	
});
*/


// Cufon
Cufon.replace('.preview_poem.arial', { fontFamily: 'Arial' });
Cufon.replace('.preview_poem.times_new_roman', { fontFamily: 'Times New Roman' });
Cufon.replace('.preview_poem.comic_sans_ms', { fontFamily: 'Comic Sans MS' });
Cufon.replace('.preview_poem.courier_new', { fontFamily: 'Courier New' });
Cufon.replace('.preview_poem.cooper_std_black', { fontFamily: 'Cooper Std' });



