// JavaScript Document
/***** load swf object randomly with array ***********************************************************************/
function loadswf(){
	var swf1 = ["/flash/birds_left.swf","800","480","top-left-corner"];
	var swf2 = ["/flash/birds_right.swf","800","480","top-right-corner"];
	var swf3 = ["/flash/hangliders_right.swf","500","250","top-right-corner"];
	var swf4 = ["/flash/runner_bottom.swf","900","300","bottom-left-corner"];
	var swf5 = ["/flash/scuba_right.swf","640","360","top-right-corner"];
	var swf6 = ["/flash/shark_left.swf","640","360","top-left-corner"];
	//var swf7 = ["/flash/sharks_with_laserbeams.swf","640","360","top-left-corner"];
	var swf8 = ["/flash/surfer_left.swf","900","300","bottom-left-corner"];
	var swf9 = ["/flash/hangliders_right_bottom.swf","800","400","bottom-right-corner"];
	var swf10 = ["/flash/birds_bottom_right.swf", "700","400","bottom-right-corner"];
	var swf11 = ["/flash/runner_bottom_right.swf", "900","150","bottom-right-corner"];
	var swf12 = ["/flash/scuba_bottom_left.swf", "640","360","bottom-left-corner"];
	var swf13 = ["/flash/Shark_bottom_right.swf", "640","360","bottom-right-corner"];
	var swf14 = ["/flash/surfer_bottom_left.swf", "640","360","bottom-left-corner"];

		
	var swfArray = [swf1,swf2,swf3,swf4,swf5,swf6,swf8,swf9,swf10,swf11,swf12,swf13,swf14];
	
	var randomnumber = Math.floor(Math.random()*swfArray.length);
	
	var selectedswf = swfArray[randomnumber];
	
	/*var swfpath =  "/flash/birds_left.swf";
	var swfwidth = "800";
	var swfheight = "480"*/;
			
	var flashvars = { };
	var params = {wmode: "transparent"};
	var attributes = { };
		
	$('#random-flash').html('');
			
	swfobject.embedSWF(selectedswf[0], "random-flash", selectedswf[1], selectedswf[2], "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);
				
	$('#background-flash').removeClass('top-right-corner').addClass(selectedswf[3]);
}

//set timeout
function init() { setTimeout('loadswf()',1000);}

/***** upper right contact box ***********************************************************************/
$(document).ready(function() {
    var contactInMotion = false;
    //swap box1
    $(".contact-link").hover(
      function() {
          if (!contactInMotion) {
              $('.contact-box').slideDown('fast', function() { });
          }
      },
	  function() { }
    );
    $(".contact-box").hover(
		function() { },
		function() {
		    if (!contactInMotion) {
		        contactInMotion = true;
		        $('.contact-box').slideUp('fast', function() { contactInMotion = false; });
		    }
		}
	);

    $(".cross-link").click(
        function() {
            $.scrollTo( '0px', 100 );
        }
    );

    var getquotedisplay = false;
    $(".get-quote-link").click(
      function() {
          if (getquotedisplay == false) {
              $('#get-quote-open').slideDown('fast');
              getquotedisplay = true;
          }
          else {
              $('#get-quote-open').slideUp('fast');
              getquotedisplay = false;
          }
      },
	  function() { }
    );

/***** Update CSS if Screen Size Width is 1024 or lower ***********************************************************************/

    if (screen.width <= 1280) {
        $('#nav').css('margin-right', '0px');
    }

/***** Inserting and Randomizing flash backgrounds from loadswf function at top of page***********************************************************************/

    init();
});


/***** basic show hide accordian for text blocks ***********************************************************************/

$(function(){	
	$(".detailsLink").each(function(){
		$(this).click(function(){
			if($(this).parent().next().is(':visible')){
				$(this).attr('href')
				$(this).parent().next().fadeOut();
				return false;
			}
			else{
				$(this).attr('href')
				$(this).parent().next().fadeIn();
				return false;
			}
		});
	});


	$(".expandTableFeatures").each(function(){
		$(this).click(function(){
			var relData = $(this).attr('rel');
			
			if($(this).prev().is(':visible')){
				$(this).html("[+] View MORE " + relData)
				$(this).prev("table.addBottBorder_Marg").fadeOut();
				return false;
			}
			else{
				$(this).html("[-] CLOSE Additional " + relData)
				$(this).prev("table.addBottBorder_Marg").fadeIn();
				return false;
			}
		});
	});
	
	$(".moreFeatures").hide();
});

/***** set cookie and show survey ***********************************************************************/
/*
$(document).ready(function(){
	//cookie variables
	var COOKIE_NAME = 'sitelab_cookie';
    var ADDITIONAL_COOKIE_NAME = 'additional';
    var options = { path: '/', expires: 10 };
	
	//toggle panel on with button
	$(".trigger").click(function(){
		$(".survey-panel").toggle("fast");
		$(this).toggleClass("active");
		return false;
	});
	
	//close panel with link in panel
	$(".trigger2").click(function(){
		$(".survey-panel").toggle("fast");
		$(".trigger").toggleClass("triggerclose");
		$.cookie(ADDITIONAL_COOKIE_NAME, 'survey2', options);
		return false;
	});
	
	//get cookie
	
	
	if ($.cookie(COOKIE_NAME)){
		$('.survey-panel2').css("display","none");
	}
	
	else {
		//set cookie
		$.cookie(COOKIE_NAME, 'survey', options);
		$('.survey-panel').css("display","none");
		$('.trigger').css("display","none");
		$('.survey-panel2').html('<p><span>Latt&eacute; for Your Thoughts?</span>Take our 6 question survey and you could win 1 of 20 $5 Starbucks&reg; Gift Cards</p><p><a href="http://www.surveymonkey.com/s/ZGMRM62" target="_blank"><img src="/gifs/btn-start-survey.gif" width="100" height="21" alt="Start Survey" /></a><br /><a href="#" class="trigger2">No Thanks</a></p>');	
		
	}
	
	//close panel with link in panel2
	$(".trigger3").click(function(){
		$('.survey-panel2').toggle("fast");
		$.cookie(ADDITIONAL_COOKIE_NAME, 'survey2', options);
		return false;
	});
	//set timer for panel 2
	
	
	if ($.cookie(ADDITIONAL_COOKIE_NAME)){
		$('.trigger').css("display","none");
		$('.survey-panel2').css("display","none");
		$('.survey-panel').css("display","none");
	}

	else
	$(".survey-panel2").oneTime("10s", function() {
		$(this).toggle('fast');
		$('.trigger').css("display","block");
	});	
});

/***** not labeled Rylan? ***********************************************************************/

/*function emptyInput(sender, args) {
    if (emptyInputCheck($('#txt_name')) && emptyInputCheck($('#txt_email'))) {
        alert("here");
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function emptyInputNoArgs(sender, args) {
    if (emptyInputCheck($('#txt_name')) && emptyInputCheck($('#txt_email'))) {
    }
    else {
    }
}

function emptyInputCheck(jObject) {
    if (jObject.val() == "") {
        jObject.addClass("inputError");
        return true;
    }
    else {
        jObject.removeClass("inputError");
    }
}*/
