
// Font rules
Cufon.replace( '.sitemap h1, #Navigation a, h1.page_head' );


$(document).ready( function() {

// validate signup form on keyup and submit
	$("#forumTopicFrm").validate({
		rules: {
			forumEmail: {
				required: true,
				emailnew: true
			},
			firstName: {
				required: true,
				minLength: 2,
				maxLength: 20
			},
			forumDesc: {
				required: true,
				minLength: 0,
				maxLength: 250
			},
			securecode: {
				required: true,
				remote: "http://www.vakantieservicebureauterschelling.nl/process.php"
			}
		},
		messages: {
			firstName: {
				required: "<font style='color:#ff0000'>Vul uw naam in.</font>"
				
			},
			forumDesc: {
				required: "<font style='color:#ff0000'>Vul een bericht in.</font>"
			},
			forumEmail: {
				required: "<font style='color:#ff0000'>Vul uw e-mailadres in.</font>",
				emailnew: "<font style='color:#ff0000'>Vul een correct e-mailadres in.</font>"
			},
			securecode: "Vul hier de juiste beveiligingscode in."	
		}
	});

	$("#forumTopicFrmNew").validate({
		rules: {
			email: {
				required: true,
				emailnew: true
			},
			name: {
				required: true,
				minLength: 2,
				maxLength: 20
			},
			phone: {
				required: true,
				minLength: 2,
				maxLength: 20
			},
						subject: {
				required: true,
				minLength: 2,
				maxLength: 20
			},
						message: {
				required: true,
				minLength: 0,
				maxLength: 250
			},
			securecode: {
				required: true,
				remote: "http://www.vakantieservicebureauterschelling.nl/process.php"
			}
		},
		messages: {
			name: {
				required: "<font style='color:#ff0000'>Vul uw naam in.</font>"
			},
			phone: {
				required: "<font style='color:#ff0000'>Vul uw telefoonnummer in.</font>"
			},
			subject: {
				required: "<font style='color:#ff0000'>Vul een onderwerp in.</font>"
			},
			message: {
				required: "<font style='color:#ff0000'>Vul een bericht in.</font>"
			},
			email: {
				required: "<font style='color:#ff0000'>Vul uw e-mailadres in.</font>",
				emailnew: "<font style='color:#ff0000'>Vul een correct e-mailadres in.</font>"
			},
			securecode: "Vul hier de juiste beveiligingscode in."	
		}
	});



  // Target _blank hack
  $('.external').attr( 'target', '_blank' );
  // Main navigation dropdown
	$(".nav li").hover(function()	{
		$(this).find("ul").stop(true, true).fadeIn();
	}, function() {
		$(this).find("ul").stop(true, true).fadeOut();
	});
  
  // Simple Category Dropdown
  $(".category li a").click(function()  {
    if($(this).parent().find("ul").length > 0)  {
        $(this).parent().find("ul").slideToggle('slow');
      return false;      
    }
  });
  
  $("#catactive").parent().parent().css('display', 'block');

  // Category drop-down
  $(".FlessenpostContent a").click(function() {
    if($(this).parent().find("ul").length > 0)  {
      $(this).parent().find("ul").slideToggle();
      return false;
    }
  });
});
  var img=false;





function trim12 (str) {
var	str = str.replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
function ajax_shopping_cart(url)
{
var rel='pdtcount';
$.get(url+'&'+Math.random()*100000, function(data){ alert(data);
$.get('http://www.vakantieservicebureauterschelling.nl/ajax_productcount.php?time='+Math.random()*100000, function(data){
$("#"+rel).html(trim12(data)+' items'); $();
});

});
}

function top_count()
{
$.get('http://www.vakantieservicebureauterschelling.nl/ajax_productcount.php?time='+Math.random()*100000, function(data){
$("#pdtcount").html(trim12(data)+' items'); $();
});
}

function general_fn()
{
$(".edit_qty_clas").click(function () {   var tit=this.id;

$("#div_"+tit).show();
$("#"+tit).hide();
});

$(".del_class").click(function (){
if(confirm('Weet u zeker dat u de producten wil verwijderen?'))
{
var id=this.id;
$.get("http://www.vakantieservicebureauterschelling.nl/ajax_update_pdt.php?id="+id+"&action=delprod&random="+Math.random()*100000,function(data){ var res=data.split(","); if(res[0] == 'success'){ $.get("../ajax_right_table.php?time="+Math.random()*100000,function(data){  $("#right_table").html(data); top_count(); general_fn();  }) }

});
}
});

}
function newsform()
{
if($('#newsname').val()=='Naam.')
{
$('#newsname').val('');
}
if($('#newsmail').val()=='E-mail adres.')
{
$('#newsmail').val('');
}
if($('#newsname').val()=='')
{
alert('Vul een naam in aub.');
$('#newsname').focus();
return false;
}
if($('#newsname').val().length<2)
{
alert('Vul minimaal 2 karakters in.');
$('#newsname').focus();
return false;
}
if($('#newsname').val().length>20)
{
alert('Vul maximaal 20 karakters in.');
$('#newsname').focus();
return false;
}
if($('#newsmail').val()=='')
{
alert('Vul een e-mailadres in aub.');
$('#newsmail').focus();
return false;
}
if(!/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,4}(?:\.[a-z]{2})?)$/i.test($('#newsmail').val()))
{
alert('Het door u ingevuld e-mailadres is niet correct.');
$('#newsmail').focus();
return false;
}

var arg= $("input[@type=text]").serialize();
var html = $.ajax({url: "http://www.vakantieservicebureauterschelling.nl/ajax_newsletter.php?"+arg, async: false}).responseText;
//alert(html);
if(html == "success")
{
alert('U bent succesvol geregistreerd.');
$("#newsname").val('');
$("#newsmail").val('');
}
else
{
alert('Het opgegeven e-mail adres bestaat al.');
}

return false;

}
