/* initiate jquery functions */
jQuery.noConflict();jQuery(document).ready(function($){
$(function() {   
 $('#slideshow').cycle({
  prev:   '#prev',
  next:   '#next',
  timeout: 0,
  speed:250,
  before: onBefore
  });
  function onBefore() {
  $('#caption').html(this.rel);
  }
 });
 
$(function() {   
 $('#slideshow_tour').cycle({
  prev:   '#prev',
  next:   '#next',
  timeout: 0,
  speed:250,
  before: onBefore
  });
  function onBefore() {
  $('#caption_tour').html(this.alt);
  }
 });

$("a#addlink").click(function(event) {
if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; }
var thisThing = $(this);
var parent = $(this).parent();
parent.html('<a>&hearts; Adding to Travel&hellip;</a>');
$.ajax({type: "POST",url: "travel-planner.htm",data: "pid="+ parent.attr('id').replace('add-',''),
beforeSend: function(){parent.animate({'color':'#000'},300);},
success: function(){parent.animate({'backgroundColor':'#e7e6df'},300);parent.html('<a href="travel-planner.htm" title="View your Travel Planner and Send an Enquiry" style="color:#666 !important">&hearts; Added to Travel Planner<\/a>');
var currentValue = parseInt($("#item_count").text());
var newValue = parseInt(currentValue) + 1;
$("#item_count").text(newValue);
var productName = thisThing.attr('title').replace('Add ','');
var productName = productName.replace(' to your Travel Planner','');
var productID = parent.attr('id').replace('add-','');
$("#jquery_add_product").prepend('<div class="tp_record clearfix" id="record-'+ productID +'"><a href="http://www.namibia-tours-safaris.com/index.php?id='+ productID +'" title="'+ productName +'" class="tp_list_heading">&middot; '+ productName +'</a></div>');
$("#tp_empty").html('');}});});

$('a.delete').click(function(event) {
if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; }
var parent = $(this).closest('div');
$.ajax({
type: "POST",
url: "travel-planner.htm",
data: 'ajax=1&delete=' + parent.attr('id').replace('record-',''),
beforeSend: function() {
parent.animate({'backgroundColor':'#d3d3d3'},200);
},
success: function() {
parent.slideUp(200,function() {
parent.remove();
var currentValue = parseInt($("#item_count").text());
var newValue = parseInt(currentValue) - 1;
$("#item_count").text(newValue);
var currentValue = parseInt($("#item_count_extra").text());
var newValue = parseInt(currentValue) - 1;
$("#item_count_extra").text(newValue);});}});});

$(function(){$("a[rel='makebigger']").colorbox();});
$(function(){$("ul.tabs").tabs("div.panes > div.clearfix",{effect:"fade"});});
$(function(){$(".toggle_content").hide(),$("h3.trigger").click(function(){$(this).toggleClass("active").next().slideToggle("fast");});});});
/* help user enter their info correctly */
function validate_required(field,alerttxt){with (field){if(value==null||value==""){alert(alerttxt);return false}else {return true}}}
function validate_email(field,alerttxt){with (field){apos=value.indexOf("@");dotpos=value.lastIndexOf(".");if(apos<1||dotpos-apos<2){alert(alerttxt);return false}else{return true}}}
function validate_form(thisform){with (thisform){if (validate_required(name,"Please provide your NAME")==false){name.focus();return false}if(validate_email(email,"Please provide a valid EMAIL address")==false){email.focus();return false}if(validate_required(enquiry,"Please write a short message.")==false){enquiry.focus();return false}}}
//analytics code
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-2615575-3']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();