// JavaScript Document


function openSeal(){
	mywin = window.open('https://seal.thawte.com/thawtesplash?form_file=fdf/thawtesplash.fdf&dn=WWW.CITYSIGHTSEEING.CO.ZA&lang=en','seal','width=500,height=600');
	mywin.focus();
}

loadedtool = 1;

$(function() {
	$('.tickettip').hover(
		function() {
		this.tip = this.title;
		$(this).append(
		'<div class="toolholder">'
		+'<div class="toolarrow"><img src="images/tooltip_arrow.png" width="9" height="21" /></div>'
		+'<div><img src="images/tooltip_top.png" width="292\ height="14" /></div>'
		+'<div class="toolcontent">'
		+this.tip
		+'</div><div><img src="images/tooltip_bot.png" width="292" height="12" /></div></div>'
		);
		if(loadedtool!=1){this.title = "";}else{}
		//this.width = $(this).width();
		//$(this).find('.toolholder').css({left:this.width-320})
		$('.toolholder').fadeIn(300);
	},
	function() {
		$('.toolholder').fadeOut(100);
		$('.toolholder').children().remove();
		if(loadedtool!=1){this.title = this.tip;}else{}
		loadedtool=2;			
		}
	);
});



// ----------------------------- jqery navnav script
	var isOver = 0;
	var navChange = 0;
	function roll(which){
	isOver=0;
	for(i=1;i<9;i++){
		$("#nav"+i).removeClass();
		$("#nav"+i).addClass("nav"+i);
	}
	if(which==1){}else{$("#navTours").slideUp('fast');}
	if(which==2){}else{$('#navPlans').slideUp('Fast');}
	if(which==8){}else{$("#navTrips").slideUp('fast');}
	switch(which){
	case 1:
	$("#nav1").removeClass();
	$("#nav1").addClass("nav1On");
	$('#navTours').slideDown('Fast');
	break;
	case 2:
	$("#nav2").removeClass();
	$("#nav2").addClass("nav2On");
	$('#navPlans').slideDown('Fast');
	break;	
	case 3:
	$("#nav3").removeClass();
	$("#nav3").addClass("nav3On");
	break;
	case 4:
	$("#nav4").removeClass();
	$("#nav4").addClass("nav4On");
	break;
	case 5:
	$("#nav5").removeClass();
	$("#nav5").addClass("nav5On");
	break;
	case 6:
	$("#nav6").removeClass();
	$("#nav6").addClass("nav6On");
	break;
	case 7:
	$("#nav7").removeClass();
	$("#nav7").addClass("nav7On");
	break;
	case 8:
	$("#nav8").removeClass();
	$("#nav8").addClass("nav8On");
	$("#navTrips").slideDown('fast');	
	break;
	}
	}
	
	function checkRoll(navChange){
	//alert("here")

	
	switch(navChange){
	case 1:	
	$("#navTours").mouseenter(function(){isOver=0});
	break;
	case 2:
	$("#navPlans").mouseenter(function(){isOver=0});
	break;	
	case 8:
	$("#navTrips").mouseenter(function(){isOver=0});
	break;
	}
	if(isOver!=0){
		switch(navChange){
			case 1:
			$("#navTours").slideUp('fast');			
			$("#nav1").removeClass();
			$("#nav1").addClass("nav1");
			break;
			case 2:	
			$("#navPlans").slideUp('fast');	
			$("#nav2").removeClass();
			$("#nav2").addClass("nav2");
			break;
			case 3:		
			$("#nav3").removeClass();
			$("#nav3").addClass("nav3");
			break;
			case 4:		
			$("#nav4").removeClass();
			$("#nav4").addClass("nav4");
			break;
			case 5:		
			$("#nav5").removeClass();
			$("#nav5").addClass("nav5");
			break;
			case 6:		
			$("#nav6").removeClass();
			$("#nav6").addClass("nav6");
			break;
			case 7:		
			$("#nav7").removeClass();
			$("#nav7").addClass("nav7");
			break;
			case 8:
			$("#navTrips").slideUp('fast');			
			$("#nav8").removeClass();
			$("#nav8").addClass("nav8");
			break;
			
		}
	}
	clearInterval(mycheck); 
	}
	
	
	function rollout(which){
	isOver=1;
	navChange = which;
	mycheck = setTimeout(checkRoll,1000,navChange);	
	}	
	
	
$(function(){  
	$("#navTours").mouseenter(function(){isOver=0});
	$("#navPlans").mouseenter(function(){isOver=0});
	$("#navTrips").mouseenter(function(){isOver=0});
	$("#nav1").mouseenter(function(){roll(1);});
	$("#nav1").mouseleave(function(){rollout(1);});
	$("#navTours").mouseleave(function(){rollout(1);});
	$("#nav2").mouseenter(function(){roll(2);});
	$("#nav2").mouseleave(function(){rollout(2);});	
	$("#navPlans").mouseleave(function(){rollout(2);});
	$("#nav3").mouseenter(function(){roll(3);});
	$("#nav3").mouseleave(function(){rollout(3);});
	$("#nav4").mouseenter(function(){roll(4);});
	$("#nav4").mouseleave(function(){rollout(4);});
	$("#nav5").mouseenter(function(){roll(5);});
	$("#nav5").mouseleave(function(){rollout(5);});
	$("#nav6").mouseenter(function(){roll(6);});
	$("#nav6").mouseleave(function(){rollout(6);});
	$("#nav7").mouseenter(function(){roll(7);});
	$("#nav7").mouseleave(function(){rollout(7);});
	$("#nav8").mouseenter(function(){roll(8);});
	$("#nav8").mouseleave(function(){rollout(8);});
	$("#navTrips").mouseleave(function(){rollout(8);});
	
});

// ------------------------ end jquery nav


//Input fields
function autoComplete(theTarget,searchText,setBack){
var checkItem = document.getElementById(theTarget).value;
if(checkItem == searchText){
 document.getElementById(theTarget).value = "";
}
if(setBack == 0){
if(checkItem == "" || checkItem == " "){
 document.getElementById(theTarget).value = searchText;
}
}
}


// page starts

$(document).ready(function() {
	if(document.getElementById('accordion')){					   
$("#accordion").accordion({
autoHeight: false,
collapsible: true,
header: "h3",
active: false
});
	}
});


function loadMaps() {
  var script = document.createElement("script");
// dev script.src = "http://www.google.com/jsapi?key=ABQIAAAA5G6De-EihxjwFRc48jaUTxQ3uqSPrdW5VMilBtMeZiheoP9TXhSCK315173bN_KjvFWEh2ACIFNk2g&callback=loadAPI";
//semi prod   script.src = "http://www.google.com/jsapi?key=ABQIAAAA5G6De-EihxjwFRc48jaUTxRkOCriIUYHlpvzFcYQm_GjWySFsxQIolJj-KaRUSiQ1ZKc7wStkfWgGQ&callback=loadAPI";
 script.src = "http://www.google.com/jsapi?key=ABQIAAAAemVpEJZszXSXIIIGFbOloRRgIbecDRx4qMo87KYHuDmMNGe_LxQlI3MxWaiIMVHFK-1R5GNZ5ngWSw&callback=loadAPI";
  script.type = "text/javascript";
  document.getElementsByTagName("head")[0].appendChild(script);
}


// page starts
var map=1;
function showmap(){
	if(map==1){
	$("#mapTag").html("<h3>Close Map ›</h3>Destination & Surrounds");
	//$("#map_canvas").slideDown("slow",initialize);
	//loadMaps();
	$("#map_canvas").slideDown("slow",loadMaps);
	$('html, body').animate({scrollTop: $("#map_canvas").offset().top}, 1000);
	map=0;
	} else {
	GUnload();	
	$("#map_canvas").slideUp("slow");
	$("#mapTag").html("<h3>Show Map ›</h3>Destination & Surrounds");
	$('html, body').animate({scrollTop: $(".headerBar").offset().top}, 1000);
	map=1;
	}

}

function goComment(){document.location.href="tour-write-a-comment.php";}

$(document).ready(function() {
	$("#mapTag").click(showmap);
	$(".button_writereview").click(goComment);
	});

function showTravel(o,p,q){
	mycheck = document.getElementById(o).style.display;
	//alert(mycheck);
	if(mycheck=="none" || mycheck==""){
	$("#"+o+"").slideDown("fast",function(){endTravel(o)});
	$("#"+p+"").html("Hide Details");
	document.getElementById(o).style.display = "block";
	$("#"+q+"").html("");
	} else {
	$("#"+o+"").slideUp("fast");
	$("#"+p+"").html("Show Details");
	$("#"+q+"").html("...");
	}
}

function endTravel(o){
	document.getElementById(o).style.display = "inline";
}



function setIt(which,theFile)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById(which).innerHTML=xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET",theFile,true);
  xmlHttp.send(null);
}


function setCart(form,theID){
setIt('writeCart','inc_cart.php')
}


function setWish(id,div,theparent,thetype){
//setIt(div,'ajax-wishlist.php?theid='+id+'&theparent='+theparent+'&thetype='+thetype)
	
$.get('ajax-wishlist.php?theid='+id+'&theparent='+theparent+'&thetype='+thetype, {  },
	function(data){	
	$("#"+div).html("<img src='images/but_added.png' />");
	$("#theWishes").html(data);
	if(data.indexOf("img")>0){alert("img");}
	
	});	
}

function setWish2(id,theparent,thetype){
$.get('ajax-wishlist.php?theid='+id+'&theparent='+theparent+'&thetype='+thetype, {  },
	function(data){	
	});	
}




function showStops(theID,theVal,theLink){
check = document.getElementById(theLink).innerHTML;
if(check=="See Stops"){
	
$.get('a_showstops.php?id='+theVal+'', {  },
	function(data){
	document.getElementById('cartHolder').style.display = "block";
	$('#'+theID).html(data);
	$("#"+theLink).html("Hide Stops");	
	});

} else {
$("#"+theID).html("");	
$("#"+theLink).html("See Stops");		
}
}


function calcPrice(ticket,extras){
	amt1element = 'list['+ticket+'][0]';
	amt2element = 'list['+ticket+'][1]';
	amt3element = 'list['+ticket+'][2]';
	amt4element = 'list['+ticket+'][3]';
	amt1 = eval(document.ticketForm[amt1element].value);
	amt2 = eval(document.ticketForm[amt2element].value);
	prc1 = eval(document.ticketForm[amt3element].value);
	prc2 = eval(document.ticketForm[amt4element].value);
	////
	amt5element = 'list['+ticket+'][7][0]';//price
	amt6element = 'list['+ticket+'][6][0]';//amt	
	amt7element = 'list['+ticket+'][8][0]';//name
	amt8element = 'list['+ticket+'][9][0]';//id
	prc3 = eval(document.ticketForm[amt5element].value);
	amt3 = eval(document.ticketForm[amt6element].value);
	if(amt3>amt1+amt2){amt3=amt1+amt2;}
	addon = prc3*amt3;
	addname = eval("document.ticketForm[amt7element].value");
	addid =  eval(document.ticketForm[amt8element].value);
	//	
	totalAdult = (amt1*prc1);
	totalKid = (amt2*prc2);	
	total = (totalAdult+totalKid+addon);	
	$('#r'+ticket).html(addon);
	$("#a"+ticket).html(totalAdult);
	$("#k"+ticket).html(totalKid);
	$("#t"+ticket).html(total);	
	if(extras==1){addBus(ticket,amt3);}
	
}

function addBus(ticket,amt3){
	addon = 'list['+ticket+'][6][0]';
	addonamt = eval(document.ticketForm[addon]);
	addonval = eval(document.ticketForm[addon].value);
	for(g=0;g<10;g++){
	addonamt.remove(g);
	}
	thetotal = amt1+amt2+1;
	for (g=0;g<thetotal;g++){
	addonamt.options[g] = new Option(g,g);
	}
	addonamt.value = amt3;
}



function updateTotals(){

}

function addcart(ticket){
	amt1element = 'list['+ticket+'][0]';
	amt2element = 'list['+ticket+'][1]';
	amt3element = 'list['+ticket+'][2]';
	amt4element = 'list['+ticket+'][3]';
	typer = 'list['+ticket+'][4]';
	id = 'list['+ticket+'][5]';
	amt1 = eval(document.ticketForm[amt1element].value);
	amt2 = eval(document.ticketForm[amt2element].value);
	prc1 = eval(document.ticketForm[amt3element].value);
	prc2 = eval(document.ticketForm[amt4element].value);
	typer = eval("document.ticketForm[typer].value");
	theid = eval(document.ticketForm[id].value);
	////
	amt5element = 'list['+ticket+'][7][0]';//price
	amt6element = 'list['+ticket+'][6][0]';//amt	
	amt7element = 'list['+ticket+'][8][0]';//name
	amt8element = 'list['+ticket+'][9][0]';//id
	prc3 = eval(document.ticketForm[amt5element].value);
	amt3 = eval(document.ticketForm[amt6element].value);
	addon = prc3*amt3;
	addname = eval("document.ticketForm[amt7element].value");
	addid =  eval(document.ticketForm[amt8element].value);
	//	
	theURL = "ajax-tickets.php?amt1="+amt1+"&amt2="+amt2+"&prc1="+prc1+"&prc2="+prc2+"&tickettype="+typer+"&id="+theid+"&amt3="+amt3+"&prc3="+prc3+"&typeadd="+addname+"&idadd="+addid+"";
	$.get(theURL, {  },
	function(data){
	document.getElementById('cartHolder').style.display = "block";
	$('#thecart').html(data);
	thelinkurl = "<a href='shop-cart.php'><img src=\"images/but_buytickets.gif\" width=\"111\" height=\"35\" alt=\"Buy & Print Tickets\" border=\"0\"/></a>";
	$('#theLink').html(thelinkurl);
	$('html, body').animate({scrollTop: $("#theTickets").offset().top}, 1000);
	});
}




//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="All images copyright City Sightseeing Cape Town";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")



//////////////////////////////////////n send password
function showPword(){
$('#pword').fadeIn('fast');	
$('html, body').animate({scrollTop: $("#pword").offset().top}, 1000);
}


function sendPword(){
//
theemail = document.pword['list[0]'].value;
if(theemail==""){theemail='44';}
$('#pword-message').fadeOut('fast',function(){$('#pword-message').html('Checking the email address...');});	
	$('#pword-message').fadeIn('fast');
$.get('ajax-password.php?email='+theemail, {  },
function(data){
	$('#pword-message').fadeOut('fast',function(){$('#pword-message').html(data);});	
	$('#pword-message').fadeIn('fast');
});
}







