/*	CUFON FONT RENDERING	--------------------------------------------------*/Cufon.replace(['h1, .Homepage h2, .GenericBoxContainer .Heading, .GenericBoxContainer .GeneralHeading, .Specials .Offer .Heading, .GlobalFooter ul.Destinations li .Heading, .GlobalFooter ul.Experiences li .Heading, .GlobalFooter ul.Links li .Heading, .GlobalHeader .Tagline'], { fontFamily: 'GaramondReg', hover: true });Cufon.replace(['.GlobalHeader .Tagline .Heading'], { fontFamily: 'GaramondBold', hover: true });Cufon.replace(['.GlobalNumber, .Banner .Overlay, #dropdown li a.Heading, .CallToAction h6, .SidebarHeading .Large, .SidebarHeading .Small'], { fontFamily: 'GillSans', hover: true });/*	TABS FUNCTION	--------------------------------------------------*/	$(function() {		// setup ul.tabs to work as tabs for each div directly under div.panes		$("ul.tabs").tabs("div.panes > div", { history: true });	});			/*	TWITTER FUNCTIONALITY FOR THE HOMEPAGE		REDUNDANT DUE TO CMS FUNCTIONALITY?--------------------------------------------------$(document).ready(function() {	// Call the Twitter API to retrieve the last 10 tweets in JSON format for the pcpro Twitter account	$.getJSON("http://twitter.com/statuses/user_timeline.json?screen_name=BenchAfrica&count=3&callback=?", function(tweetdata) {				// Grab a reference to the ul element which will display the tweets		var tl = $("#tweet-list");		// For each item returned in tweetdata		$.each(tweetdata, function(i,tweet) {			// Append the info in li tags to the ul, converting any links to HTML <a href=.. code and convert the tweeted date			// to a more readable Twitter format			tl.append("<li>&ldquo;" + urlToLink(tweet.text) + "&rdquo;&ndash; " + relTime(tweet.created_at) + "</li>");		});	});});*//*	CONVERT LINKS TO A HREF	REDUNDANT DUE TO CMS FUNCTIONALITY?	--------------------------------------------------// Converts any links in text to their HTML <a href=""> equivalentfunction urlToLink(text) {  var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;  return text.replace(exp,"<a href='$1'>$1</a>"); }*/// Takes a time value and converts it to "from now" and then returns a relevant text interpretation of itfunction relTime(time_value) {	time_value = time_value.replace(/(\+[0-9]{4}\s)/ig,"");	var parsed_date = Date.parse(time_value);	var relative_to = (arguments.length > 1) ? arguments[1] : new Date();	var timeago = parseInt((relative_to.getTime() - parsed_date) / 1000);				if (timeago < 60) return 'less than a minute ago';	else if(timeago < 120) return 'about a minute ago';	else if(timeago < (45*60)) return (parseInt(timeago / 60)).toString() + ' minutes ago';	else if(timeago < (90*60)) return 'about an hour ago';	else if(timeago < (24*60*60)) return 'about ' + (parseInt(timeago / 3600)).toString() + ' hours ago';	else if(timeago < (48*60*60)) return '1 day ago';	else return (parseInt(timeago / 86400)).toString() + ' days ago';}$(document).ready(function() {			/*	AJAX TEMPLATE LOADER		OFFERS AND REVIEWS PAGES				PASSES THE DESTINATION NAME VIA THE TYPE VAR		--------------------------------------------------*/		$('.ajax_location_select').change(function() { 		var id = $(this).val();		var type = $(this).attr('name');		var link = "/_ajax/" + type;		$('.ajax_div').html('<img src="/assets/images/icons/ajax-loader.gif" class="loading" />');		$.ajax({		  url: link,		  type: "POST",		  data: 'destination=' + id,		  success:( function(data){		  	$('.ajax_div').html(data);		  }),		  error:( function(data){		  	$('.ajax_div').html('There was an Error loading the data...');		  })		});			});			/*	AJAX TEMPLATE LOADER		EXPERIENCES PAGES					PASSES THE DESTINATION NAME VIA THE TYPE VAR		PASSES THE CATEGORY ID NUMBER VIA THE CAT VAR	--------------------------------------------------*/			$('.ajax_location_cat_select').change(function() { 		var id = $(this).val();		var type = $(this).attr('name');	// THE NAME ATTRIBUTE SHOULD CORRESPOND WITH THE EE TEMPLATE NAME IN /_AJAX/ TEMPLATE GROUP		var temp = $(this).attr('id');		// WE ARE STORING THE CATEGORY ID IN THE ID AS 'CAT_X'		var parts = temp.split('_');		// AN ID CAN'T BE A NIUMBER ONLY SO WE'RE SPLITTING THE ID VARIABLE (CAT_X) AT THE UNDERSCORE		var cat = parts[1];					// THEN WE'RE CHOOSING THE 2ND PART OF THE SPLIT TO PASS ALONG		var link = "/_ajax/" + type;		$('.ajax_div').html('<img src="/assets/images/icons/ajax-loader.gif" class="loading" />');		$.ajax({			url: link,			type: "POST",			data: {				destination: id,			// THE ID VARIABLE WILL BE POSTED AS DESTINATION				category: cat				// THE CAT VARIABLE WILL BE POSTED AS CATEGORY			},			success:( function(data){				$('.ajax_div').html(data);			}),			error:( function(data){				$('.ajax_div').html('There was an Error loading the data...');			})		});	});				/*	BANNER SLIDE LOADER (JQUERY CYCLE)		--------------------------------------------------*/		$('.Banner .items').cycle({pager: '#BannerNav',timeout:  8000});		/*	MAIN NAVIGATION DROP DOWN FUNCTION		--------------------------------------------------*/	function megaHoverOver(){		$(this).find(".sub").stop().fadeTo('fast', 1).show();					//Calculate width of all ul's		(function($) { 			jQuery.fn.calcSubWidth = function() {				rowWidth = 0;				//Calculate row				$(this).find("ul").each(function() {										rowWidth += $(this).width(); 				});				};		})(jQuery); 				if ( $(this).find(".row").length > 0 ) { //If row exists…			var biggestRow = 0;				//Calculate each row			$(this).find(".row").each(function() {							   				$(this).calcSubWidth();				//Find biggest row				if(rowWidth > biggestRow) {					biggestRow = rowWidth;				}			});			//Set width			$(this).find(".sub").css({'width' :biggestRow});			$(this).find(".row:last").css({'margin':'0'});					} else { //If row does not exist…						$(this).calcSubWidth();			//Set Width			$(this).find(".sub").css({'width' : rowWidth});					}	}		function megaHoverOut(){ 	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {		  $(this).hide(); 	  });	}	var config = {    		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    		 interval: 100, // number = milliseconds for onMouseOver polling interval    		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    		 timeout: 500, // number = milliseconds delay before onMouseOut    		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    	};	$("ul#dropdown li .sub").css({'opacity':'0'});	$("ul#dropdown li").hoverIntent(config);});	/*	IMAGE GALLERY		TEMPLATE: _CONTENT/_EXPERIENCE	--------------------------------------------------*/					$(function() {		$(".Gallery").scrollable();		$(".Gallery .items img").click(function() {						// see if same thumb is being clicked			if ($(this).hasClass("active")) { return; }					// calclulate large image's URL based on the thumbnail URL (flickr specific)			var url = $(this).attr("src").replace("_t", "");					// get handle to element that wraps the image and make it semi-transparent			var wrap = $("#image_wrap").fadeTo("medium", 0.9);					// the large image from www.flickr.com			var img = new Image();							// call this function after it's loaded			img.onload = function() {						// make wrapper fully visible				wrap.fadeTo("fast", 1);						// change the image				wrap.find("img").attr("src", url);					};					// begin loading the image from www.flickr.com			img.src = url;					// activate item			$(".items img").removeClass("active");			$(this).addClass("active");					// when page loads simulate a "click" on the first image		}).filter(":first").click();	});    $(document).ready(function() {						/*	ROTATING OFFERS BOX - HOME PAGE		TEMPLATE: _CONTENT/_HOME	--------------------------------------------------*/		$('.Specials .items').cycle({pager: '#SpecialsNav'});	/*	FORMS - VALIDATION 	    TEMPLATE: _FUNCTIONS/_FORM_REQUEST_BROCHURE	--------------------------------------------------*/ 		// validate signup form on keyup and submit		$("#RequestBrochureForm").validate({			rules: {				FirstName: "required",				LastName: "required",				Email: {					required: true,					email: true				},				Street: "required",				Suburb: "required",				State: "required",				Country: "required"			},			messages: {				FirstName: "<P>Please enter your first name",				LastName: "<P>Please enter your last name",				Email: "<P>Please enter a valid email address",				Street: "<P>Please enter your street name",				Suburb: "<P>Please enter your suburb",				State: "<P>Please enter your state",				Country: "<P>Please select a country"			}		});				                                 	/*	FORMS - VALIDATION 	    TEMPLATE: _FUNCTIONS/_FORM_REVIEWS_SUBMISSION	--------------------------------------------------*/     											// validate signup form on keyup and submit		$("#ReviewForm").validate({			rules: {				Destination: "required",				DepartureMonth: "required",				DepartureYear: "required",				FirstName: "required",				LastName: "required",				Email: {					required: true,					email: true				},				Review: "required"			},			messages: {				Destination: "<P>Please select a destination",				DepartureMonth: "<P>Please select the month you travelled",				DepartureYear: "<P>Please select the year you travelled",				FirstName: "<P>Please enter your first name",				LastName: "<P>Please enter your last name",				Email: "<P>Please enter a valid email address",				Review: "<P>Please enter your review"			}		});		 	                                	/*	FORMS - VALIDATION 	    TEMPLATE: _FUNCTIONS/_FORM_CONTACT_US	--------------------------------------------------*/ 									// validate signup form on keyup and submit			$("#ContactForm").validate({				rules: {					Destination: "required",					FirstName: "required",					LastName: "required",					Email: {						required: true,						email: true					},					Country: "required"				},				messages: {					Destination: "<P>Please select a destination",					FirstName: "<P>Please enter your first name",					LastName: "<P>Please enter your last name",					Email: "<P>Please enter a valid email address",					Country: "<P>Please select a country"				}			});			                    	/*	FORMS - VALIDATION 	    TEMPLATE: _FUNCTIONS/_FORM_SIGNUP	--------------------------------------------------*/				// validate signup form on keyup and submit		$("#SignUpForm").validate({			rules: {				FirstName: "required",				LastName: "required",				Email: {					required: true,					email: true				}			},			messages: {				FirstName: "<P>Please enter your first name",				LastName: "<P>Please enter your last name",				Email: "<P>Please enter a valid email address"			}		});		                     	/*	FORMS - VALIDATION 	    TEMPLATE: _FUNCTIONS/_FORM_DOWNLOAD_BROCHURE	--------------------------------------------------*/							// validate signup form on keyup and submit		$("#DownloadBrochureForm").validate({			rules: {				FirstName: "required",				LastName: "required",				Email: {					required: true,					email: true				}			},			messages: {				FirstName: "<P>Please enter your first name",				LastName: "<P>Please enter your last name",				Email: "<P>Please enter a valid email address"			}		});                                                          	/*  FAQ REVEAL	    TEMPLATE: _CONTENT/_FAQ	--------------------------------------------------*/                                		//hide the all of the element with class msg_body		$(".msg_body").hide();		//toggle the componenet with class msg_body		$(".msg_head").click(function(){			$(this).next(".msg_body").slideToggle(250);		});			});                	/*  SUBSCRIBER MERGE FIRST AND LAST NAME TO NAME	    TEMPLATE: _FUNCTIONS/_FORMS....	--------------------------------------------------*/ 	$(function(){		$('.Submit').click(function () {			var str1 = $('input[name="firstname"]').val();			var str2 = $('input[name="lastname"]').val();			var fullname = str1+" "+str2;			$('input[name="name"]').attr('value', fullname); 		});    	});  
