var remove1on=new Image();
remove1on.src="/wp-content/themes/westcoastnet/img/removeon.png";
var remove1off=new Image();
remove1off.src="/wp-content/themes/westcoastnet/img/removeoff.png";
var remove2on=new Image();
remove2on.src="/wp-content/themes/westcoastnet/img/removeon.png";
var remove2off=new Image();
remove2off.src="/wp-content/themes/westcoastnet/img/removeoff.png";
var remove3on=new Image();
remove3on.src="/wp-content/themes/westcoastnet/img/removeon.png";
var remove3off=new Image();
remove3off.src="/wp-content/themes/westcoastnet/img/removeoff.png";
var remove4on=new Image();
remove4on.src="/wp-content/themes/westcoastnet/img/removeon.png";
var remove4off=new Image();
remove4off.src="/wp-content/themes/westcoastnet/img/removeoff.png";
var remove5on=new Image();
remove5on.src="/wp-content/themes/westcoastnet/img/removeon.png";
var remove5off=new Image();
remove5off.src="/wp-content/themes/westcoastnet/img/removeoff.png";
var remove6on=new Image();
remove6on.src="/wp-content/themes/westcoastnet/img/removeon.png";
var remove6off=new Image();
remove6off.src="/wp-content/themes/westcoastnet/img/removeoff.png";

var removeddon=new Image();
removeddon.src="/wp-content/themes/westcoastnet/img/removeon.png";
var removeddoff=new Image();
removeddoff.src="/wp-content/themes/westcoastnet/img/removeoff.png";
var removepdon=new Image();
removepdon.src="/wp-content/themes/westcoastnet/img/removeon.png";
var removepdoff=new Image();
removepdoff.src="/wp-content/themes/westcoastnet/img/removeoff.png";

var removedcon=new Image();
removedcon.src="/wp-content/themes/westcoastnet/img/removeon.png";
var removedcoff=new Image();
removedcoff.src="/wp-content/themes/westcoastnet/img/removeoff.png";
var removepcon=new Image();
removepcon.src="/wp-content/themes/westcoastnet/img/removeon.png";
var removepcoff=new Image();
removepcoff.src="/wp-content/themes/westcoastnet/img/removeoff.png";

var listenon=new Image();
listenon.src="/wp-content/themes/westcoastnet/img/listenon.png";
var listenoff=new Image();
listenoff.src="/wp-content/themes/westcoastnet/img/listenoff.png";

var reloadon=new Image();
reloadon.src="/wp-content/themes/westcoastnet/img/reloadon.png";
var reloadoff=new Image();
reloadoff.src="/wp-content/themes/westcoastnet/img/reloadoff.png";




var oldsizemenu;
function allocateSidebarHeight(){
	var contentDom=document.getElementById("bodywrapper");
	var sidebarDom=document.getElementById("sidebar");
	var sliderDom=document.getElementById("slider");
	var newslider=eval(contentDom.offsetHeight+285);
	if((contentDom.offsetHeight)>=sidebarDom.offsetHeight)
	{
		sidebarDom.style.height=(newslider+"px");
		sliderDom.style.height=(newslider+"px");
	}
	contentDom.style.height=(newslider+"px");
}

function popitup(url){
	newwindow=window.open(url,'name','height=750,width=690,resizable=yes,scrollbars=yes, toolbar=no');
	if(window.focus){newwindow.focus()}
	return false;
}

function popitups(url){
	newwindow=window.open(url,'name','height=400,width=205,resizable=no,scrollbars=no, toolbar=no');
	if(window.focus){newwindow.focus()}
	return false;
}

function popitupl(url){
	newwindow=window.open(url,'name','height=680,width=1000,resizable=no,scrollbars=no, toolbar=no');
	if(window.focus){newwindow.focus()}
	return false;
}

function refbar(id,mytext){
	document.getElementById(id).innerHTML='<p><b>'+mytext+'</b></p>';
}

function lToggle(){
	var id=new Array();
	for(var i=0;i<lToggle.arguments.length;i++)
	{
		id[i]=lToggle.arguments[i];
		var textlighton='text'+id[i];
		var tabon='mylabel'+id[i]+'a';
		var taboff='mylabel'+id[i]+'b';
		if(i=='0')
		{
			toggle(textlighton,'open');toggle(tabon,'open');toggle(taboff,'close');
		}
		else
		{
			toggle(textlighton,'close');toggle(tabon,'close');toggle(taboff,'open');
		}
	}
}

function mToggle(){
	var id=new Array();
	for(var i=0;i<mToggle.arguments.length;i++)
	{
		id[i]=mToggle.arguments[i];
		var textlighton='text'+id[i];
		if(i=='0')
		{
			toggle(textlighton,'open');
		}
		else
		{
			toggle(textlighton,'close');
		}
	}
}

function fToggle(showid,max){
	for(var i=1;i<=max;i++)
	{
		var textlighton='faq'+i;
		if(textlighton==showid)
		{
			toggle(textlighton,'open');
		}
		else
		{
			toggle(textlighton,'close');
		}
	}
	return false;
}

function toggle(id,openclose){
	var ele1=document.getElementById(id);
	if(openclose=='open')
	{
		ele1.style.display="block";
	}
	else if(openclose=='close')
	{
		ele1.style.display="none";
	}
}

function myOn(myImgName){document[myImgName].src=eval(myImgName+'on').src;}
function myOut(myImgName){document[myImgName].src=eval(myImgName+'off').src;}





var digits="0123456789";
var phoneNumberDelimiters="()- ";
var validWorldPhoneChars=phoneNumberDelimiters+"+";
var minDigitsInIPhoneNumber=10;


function isInteger(s){

	var i;
	for(i=0;i<s.length;i++)
	{
		var c=s.charAt(i);if(((c<"0")||(c>"9")))return false;
	}
	return true;
}


function trim(s){
	var i;
	var returnString="";
	for(i=0;i<s.length;i++)
	{
		var c=s.charAt(i);
		if(c!=" ")returnString+=c;
	}
	return returnString;
}




function olddate(theyear,themonth,theday){
	var myDate=new Date();
	myDate.setFullYear(theyear,themonth,theday);
	var today=new Date();
	if(myDate>today)
	{
		return'OK';
	}
	else if(myDate<today)
	{
		return'TOO LATE';
	}
	else
	{
		return'TODAY';
	}
}

function myscroll(){
	var toobig=false;
	var myposition=1*getScrollXY();
	var contentsize=1*document.getElementById('thecontent').offsetHeight-130;
	var sizemenu=659;
	var maxoffset=contentsize-sizemenu+159;
	var maxscroll=maxoffset-130;
	var limitset=maxscroll+10;
	//document.getElementById('theposition').innerHTML=myposition;
	//document.getElementById('thesize').innerHTML=contentsize;
	//document.getElementById('themenusize').innerHTML=sizemenu;
	//document.getElementById('theoffset').innerHTML=maxoffset;
	//document.getElementById('thescroll').innerHTML=maxscroll;
	if((myposition>157)&&(myposition<maxscroll))
	{
		document.getElementById('topmenu').style.position='fixed';
		document.getElementById('topmenu').style.top='36px';
	}
	else if((myposition>157)&&(myposition>maxscroll))
	{
		document.getElementById('topmenu').style.position='absolute';
		document.getElementById('topmenu').style.top=limitset+'px';
	}
	else if(myposition<=157)
	{
		document.getElementById('topmenu').style.position='absolute';
		document.getElementById('topmenu').style.top='181px';
	}
	var currenttop=document.getElementById('topmenu').style.top;
	var currentbottom=document.getElementById('topmenu').style.bottom;
	//document.getElementById('thetop').innerHTML=currenttop;
	//document.getElementById('thebottom').innerHTML=currentbottom;
}

function getScrollXY(){
	var scrOfX=0,scrOfY=0;
	if(typeof(window.pageYOffset)=='number')
	{
		scrOfY=window.pageYOffset;
		scrOfX=window.pageXOffset;
	}
	else if(document.body&&(document.body.scrollLeft||document.body.scrollTop))
	{
		scrOfY=document.body.scrollTop;
		scrOfX=document.body.scrollLeft;
	}
	else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop))
	{
		scrOfY=document.documentElement.scrollTop;
		scrOfX=document.documentElement.scrollLeft;
	}
	return[scrOfY];
}
var $j = jQuery.noConflict();
$j(document).ready(function() {
				$j("#booking_form").submit(function() {
				var uname_val = $j("#realname").val();
				var email_val = $j("#realemail").val();
				var comment_val = $j("#comments").val();
				var country_val = $j("#thecountry").val();
				var therequest1_val = $j("#request1:checked").val();	
				var therequest2_val = $j("#request2:checked").val();	
				var live1_val = $j("#liveaboard1").val();
				var live2_val = $j("#liveaboard2").val();
				var live3_val = $j("#liveaboard3").val();
				var live4_val = $j("#liveaboard4").val();
				var live5_val = $j("#liveaboard5").val();
				var live6_val = $j("#liveaboard6").val();
				var live7_val = $j("#liveaboard7").val();
				var live8_val = $j("#liveaboard8").val();
				var live9_val = $j("#liveaboard9").val();
				var plive1_val = $j("#pax_liveaboard1").val();
				var plive2_val = $j("#pax_liveaboard2").val();
				var plive3_val = $j("#pax_liveaboard3").val();
				var plive4_val = $j("#pax_liveaboard4").val();
				var plive5_val = $j("#pax_liveaboard5").val();
				var plive6_val = $j("#pax_liveaboard6").val();
				var plive7_val = $j("#pax_liveaboard7").val();
				var plive8_val = $j("#pax_liveaboard8").val();
				var plive9_val = $j("#pax_liveaboard9").val();
				var day_val = $j("#daytrip").val();
				var date_day_val = $j("#date_daytrip").val();
				var pax_day_val = $j("#pax_daytrip").val();
				var padi_val = $j("#course").val();
				var date_padi_val = $j("#date_course").val();
				var pax_padi_val = $j("#pax_course").val();
				var verif2_val = $j("#verif").val();
				
				$j.post("thanks2.php", { 
				realname: uname_val,
				realemail: email_val,
				comments: comment_val,
				thecountry: country_val,
				request1: therequest1_val,
				request2: therequest2_val,
				liveaboard1: live1_val,
				liveaboard2: live2_val,
				liveaboard3: live3_val,
				liveaboard4: live4_val,
				liveaboard5: live5_val,
				liveaboard6: live6_val,
				liveaboard7: live7_val,
				liveaboard8: live8_val,
				liveaboard9: live9_val,
				pax_liveaboard1: plive1_val,
				pax_liveaboard2: plive2_val,
				pax_liveaboard3: plive3_val,
				pax_liveaboard4: plive4_val,
				pax_liveaboard5: plive5_val,
				pax_liveaboard6: plive6_val,
				pax_liveaboard7: plive7_val,
				pax_liveaboard8: plive8_val,
				pax_liveaboard9: plive9_val,
				daytrip: day_val,
				date_daytrip: date_day_val,
				pax_daytrip: pax_day_val,
				course: padi_val,
				date_course: date_padi_val,
				pax_course: pax_padi_val,
				verif2: verif2_val},
				function(data) {
					$j("#status3 p").html(data);
				});
				return false;
			});			
			
			$j("#comment_form").submit(function() {
				var uname_val = $j("#username").val();
				var email_val = $j("#email").val();
				var comment_val = $j("#comment").val();
				var verif_val = $j("#verif").val();
				var pid_val = $j("#pid").val();
				var thecountry_val = $j("#thecountry").val();
				$j.post("/wp-content/themes/westcoastnet/backend.php", { 
				username: uname_val,
				email: email_val,
				comment: comment_val,
				thecountry: thecountry_val,
				pid: pid_val,
				verif: verif_val},
				function(data) {
					$j("#status p").html(data);
				});
				return false;
			});
			
			
			
			
			
			
		});	
		
		// *** TO BE CUSTOMISED ***

var style_cookie_name = "style" ;
var style_cookie_duration = 30 ;

// *** END OF CUSTOMISABLE SECTION ***

function switch_style ( css_title )
{
// You may use this script on your site free of charge provided
// you do not remote this notice or the URL below. Script from
// http://www.thesitewizard.com/javascripts/change-style-sheets.shtml
  var i, link_tag ;
  for (i = 0, link_tag = document.getElementsByTagName("link") ;
    i < link_tag.length ; i++ ) {
    if ((link_tag[i].rel.indexOf( "stylesheet" ) != -1) &&
      link_tag[i].title) {
      link_tag[i].disabled = true ;
      if (link_tag[i].title == css_title) {
        link_tag[i].disabled = false ;
      }
    }
    set_cookie( style_cookie_name, css_title,
      style_cookie_duration );
  }
}
function set_style_from_cookie()
{
  var css_title = get_cookie( style_cookie_name );
  if (css_title.length) {
    switch_style( css_title );
  }
}
function set_cookie ( cookie_name, cookie_value,
    lifespan_in_days, valid_domain )
{
    // http://www.thesitewizard.com/javascripts/cookies.shtml
    var domain_string = valid_domain ?
                       ("; domain=" + valid_domain) : '' ;
    document.cookie = cookie_name +
                       "=" + encodeURIComponent( cookie_value ) +
                       "; max-age=" + 60 * 60 *
                       24 * lifespan_in_days +
                       "; path=/" + domain_string ;
}
function get_cookie ( cookie_name )
{
    // http://www.thesitewizard.com/javascripts/cookies.shtml
    var cookie_string = document.cookie ;
    if (cookie_string.length != 0) {
        var cookie_value = cookie_string.match (
                        '(^|;)[\s]*' +
                        cookie_name +
                        '=([^;]*)' );
        return decodeURIComponent ( cookie_value[2] ) ;
    }
    return '' ;
}
