/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$(function(){
	//tabs
	$('#tabs ul').tabs( { fx: { opacity: 'toggle' } } ).tabs( '' ).tabs('disabled.tabs', []);
	$('#tabs2 ul').tabs( { fx: { opacity: 'toggle' } } ).tabs( '' ).tabs('disabled.tabs', []);
	$('#tabs3 ul').tabs( { fx: { opacity: 'toggle' } } ).tabs( '' ).tabs('disabled.tabs', []);
     
});

function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr('rel')));
        return false;
    });
}

jQuery(document).ready(function() {
	
    jQuery("#mycarousel").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });


	/*$('div.tabholder').children('div').hide();
	$('div.tabholder').children('div').eq(0).show();
	
	$('a.tabswitch').click( function(){
		var containerName = $(this).attr('rel');
		var childName = $(this).attr('href');
		var selectedElement = $(containerName).find(childName);
		$(containerName).children('div').not(selectedElement).hide();
		selectedElement.show();
		return false;
	});*/
	
    $('#menu ul li span a').click( function(){
		var wasSelected = ( $(this).hasClass('selected') );
		$('#menu ul li span a.selected').removeClass('selected');
		$('#menu ul li ul').hide('fast');
		if ( wasSelected == false ) {
			$(this).parent().next('ul').show('fast');
			$(this).addClass('selected');
		}
	});
	
	$('#booking a').click(function() {
    	$('#booking_form').show('fast');
		return false;
  	});
	
	$('#close a').click(function() {
    	$('#booking_form').hide('fast');
		return false;
  	});
	
	$('#reg a').click(function() {
		$('#reg_form').show('fast');
		return false;
	});
	
	$('#reg_close a').click(function() {
		$('#reg_form').hide('fast');
		return false;
	});
	
	$("#currencies").change(onSelectChange);
	//$(document).getElementById("output").innerHTML = "LOADING";
	
});

function onSelectChange(){
    var dropdown = document.getElementById("virtual_dd");
	var index = dropdown.selectedIndex;
	var ddVal = dropdown.options[index].value;
	var ddText = dropdown.options[index].text;
    
	if(ddVal != 0) {
		document.getElementById("virtual_tour").innerHTML = "LOADING" ;
		alert(ddVal);
		//output = $.get("/currency/get/" + ddText, exchange_rate, setValue);
		$.get(ddVal, { },
	  function(data){
		document.getElementById("virtual_tour").innerHTML = "ZAR " + data ;
	  });
	}
}
function onSelectChange(){
	var dropdown = document.getElementById("currencies");
	var index = dropdown.selectedIndex;
	var ddVal = dropdown.options[index].value;
	var ddText = dropdown.options[index].text;

	if(ddVal != 0) {
		document.getElementById("currency").innerHTML = "LOADING" ;
		//alert(ddVal);
		//output = $.get("/currency/get/" + ddText, exchange_rate, setValue);
		$.get("/currency/get/" + ddVal, { },
	  function(data){
		document.getElementById("currency").innerHTML = "ZAR " + data ;
	  });

	}
}
$(function() {
        $('.gallery_thumb_row a').not('.press_download').lightBox();
});
function subCatJump(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

