var browserName=navigator.appName; 
var browserVer=parseInt(navigator.appVersion); 

	function FnListOn(ul) {
		if (browserName=="Microsoft Internet Explorer" && browserVer>=4) {
			document.getElementById(ul).style.marginLeft = "0";
		}
	}
	
	function FnListOff(ul) {
		if (browserName=="Microsoft Internet Explorer" && browserVer>=4) {
			document.getElementById(ul).style.marginLeft = "-1000em";
		}
	}

	/* script to change tabs on sponsor */
	function FnSponsorDescOn(on,off1,tabon,taboff1) {
		document.getElementById(on).className = "tab_content on";
		document.getElementById(off1).className = "tab_content off";
		document.getElementById(tabon).className = "tabon";
		document.getElementById(taboff1).className = "taboff";
	}

	/* script to change tabs on cdwow */
	function FnDescOn(on,off1,off2,tabon,taboff1,taboff2,colour) {
		document.getElementById(on).className = "tab_content " + colour + " on";
		document.getElementById(off1).className = "tab_content " + colour + " off";
		document.getElementById(off2).className = "tab_content " + colour + " off";
		document.getElementById(tabon).className = "tab_" + colour + "_t tabon";
		document.getElementById(taboff1).className = "tab_" + colour + "_t taboff_" + colour;
		document.getElementById(taboff2).className = "tab_" + colour + "_t taboff_" + colour;
	}
	
	/* script to change tabs on reward details pages */
	function FnRewardTabOn(on,off1,off2,tabon,taboff1,taboff2) {
		document.getElementById(on).className = "tab_content_on";
		document.getElementById(off1).className = "tab_content_off";
		document.getElementById(off2).className = "tab_content_off";
		document.getElementById(tabon).className = "tabon";
		document.getElementById(taboff1).className = "taboff";
		document.getElementById(taboff2).className = "taboff";
	}

	function fnRedeemGift(form) {
		if(form.giftIndicator.checked) {
			document.getElementById('redeem_giftad').style.display = "block";
		}
		
		if(!form.giftIndicator.checked) {
			document.getElementById('redeem_giftad').style.display = "none";
		}
		
		fnEnableGift(document.Redemption);    
		}

	/* cse search bar featured on collect on online page - cse form val */
	function fnValSearch(field){
		if (document.getElementById(field).value === '') {
			alert("Please enter a search term");
			return false;
		}
	}

	/* jquery scripts */
	jQuery(document).ready(function() {
	
		
		// travelclub
		function goCarousel() {
			$('.maincarousel').jcarousel({
        		 visible: 1,
				 scroll: 1,
				 wrap: 'both',
				 auto: 0,
				 animation: 'slow'
	   		 });
		}	
		if ($('.maincarousel').length > 0 ) goCarousel(); 
		
 
		// jcarousel treats
		function jcarTreatsFunc() {
			$("#jcarouseltreats").removeClass("treatscar");
			jQuery('#jcarouseltreats').jcarousel({
	        visible: 2,
					scroll: 2,
					wrap: "both",
					animation: "slow"
	    });
		}
		if ($("#jcarouseltreats").length > 0 ) jcarTreatsFunc(); 
		
		//jecarousel toptips
		function jcarTipsFunc() {
			if ($.browser.safari) {
				//$("#jcarouseltips").removeClass("toptips");
				//jQuery('#jcarouseltips').jcarousel({
		    //    visible: 1,
				//		scroll: 1,
				//		start: 100,
				//		wrap: "both",
				//		auto: 10,
				//		animation: "slow"
		    //});
			} else {
				$("#jcarouseltips").removeClass("toptips");
				jQuery('#jcarouseltips').jcarousel({
		        visible: 1,
						scroll: 1,
						start: 0,
						wrap: "both",
						auto: 10,
						animation: "slow"
		    });
			}
		}
		if ($("#jcarouseltips").length > 0 ) jcarTipsFunc(); 
		
		//testimonials ajax test
		function testimonialsFunc() {
				$.ajax({
			    url: '/contents/html/load/testimonials.htm',
			    type: 'POST',
			    dataType: 'html',
					timeout: 5000,
			    error: function(){
			        alert('Error loading list');
			    },
			    success: function(html){
			      var intTest = 0;
						$(html).find("li").each(function(){
							intTest = intTest + 1;
						});
						var intTest = Math.floor(Math.random() * intTest);
						var strTest = [ $(html).find("li").eq(intTest).text() ]; 
						
						$(".testimonials_txt").replaceWith("<p>" + strTest + "</p>");
						
			    }
				});
		}
		if ($(".testimonials_txt").length > 0 ) testimonialsFunc();


		// terms and conditions show and hide

		function setupTermsandconditionsDisplay() {
			$('.termsandconditions_display h3').siblings().hide();
			$('.termsandconditions_display h3').css({'border-bottom' : '1px dotted #E54A00',	'color' : '#E54A00', 'cursor' : 'pointer', 'display' : 'inline', 'font-size' : '1em', 'font-weight' : 'normal', 'line-height' : '2em'});
			$('.termsandconditions_display h3').text( $('.termsandconditions_display h3').text() + " >");
			$('.termsandconditions_display h3').click(function() {
				$(this).siblings().css({'color' : '#888888', 'font-size' : '80%'});
				$(this).siblings().toggle();
			});
		}
		if ($('.termsandconditions_display').length > 0 ) setupTermsandconditionsDisplay(); 
	
		
		// all sponsors striping
		
		if ($('#collect_home_list')){
			$('#collect_home_list tr:even td').addClass('odd');
		}

		//listgallery view on search
		if ($('#listview')){
			$("#listview").click(function(){
				$("#resultsview").removeClass("galleryviewlayout").addClass("listviewlayout");
				$("#listview").css("background-position","-16px 0px");
				$("#galleryview").css("background-position","0px -16px"); 
 				$.cookie("spendsearchview", "listview");
			});
	
			$("#galleryview").click(function(){
				$("#resultsview").removeClass("listviewlayout").addClass("galleryviewlayout");
				$("#listview").css("background-position","0px 0px");
				$("#galleryview").css("background-position","-16px -16px");
				$.cookie("spendsearchview", "galleryview");
			});
	
       			var view = $.cookie('spendsearchview');

       			if (view == "listview" || view == null) {$("#resultsview").addClass("listviewlayout").removeClass("galleryviewlayout");};
       			if (view == "listview" || view == null) {$("#listview").css("background-position","-16px 0px");};
       			if (view == "galleryview") {$("#resultsview").addClass("galleryviewlayout").removeClass("listviewlayout");};
       			if (view == "galleryview") {$("#galleryview").css("background-position","-16px -16px");};
		}
	
		
});

 
		
	