/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2008 George McGinley Smith
 * All rights reserved.
*/
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend( jQuery.easing,
{
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	}
});

/**
* Placeholder plugin for jQuery
* ---
* Copyright 2010, Daniel Stocks (http://webcloud.se)
* Released under the MIT, BSD, and GPL Licenses.
*/
(function(b){function d(a){this.input=a;a.attr("type")=="password"&&this.handlePassword();b(a[0].form).submit(function(){if(a.hasClass("placeholder")&&a[0].value==a.attr("placeholder"))a[0].value=""})}d.prototype={show:function(a){if(this.input[0].value===""||a&&this.valueIsPlaceholder()){if(this.isPassword)try{this.input[0].setAttribute("type","text")}catch(b){this.input.before(this.fakePassword.show()).hide()}this.input.addClass("placeholder");this.input[0].value=this.input.attr("placeholder")}},
hide:function(){if(this.valueIsPlaceholder()&&this.input.hasClass("placeholder")&&(this.input.removeClass("placeholder"),this.input[0].value="",this.isPassword)){try{this.input[0].setAttribute("type","password")}catch(a){}this.input.show();this.input[0].focus()}},valueIsPlaceholder:function(){return this.input[0].value==this.input.attr("placeholder")},handlePassword:function(){var a=this.input;a.attr("realType","password");this.isPassword=!0;if(b.browser.msie&&a[0].outerHTML){var c=b(a[0].outerHTML.replace(/type=(['"])?password\1/gi,
"type=$1text$1"));this.fakePassword=c.val(a.attr("placeholder")).addClass("placeholder").focus(function(){a.trigger("focus");b(this).hide()});b(a[0].form).submit(function(){c.remove();a.show()})}}};var e=!!("placeholder"in document.createElement("input"));b.fn.placeholder=function(){return e?this:this.each(function(){var a=b(this),c=new d(a);c.show(!0);a.focus(function(){c.hide()});a.blur(function(){c.show(!1)});b.browser.msie&&(b(window).load(function(){a.val()&&a.removeClass("placeholder");c.show(!0)}),
a.focus(function(){if(this.value==""){var a=this.createTextRange();a.collapse(!0);a.moveStart("character",0);a.select()}}))})}})(jQuery);

(function($){
	
	// Scroll Window
	$.fn.extend({scrollWindow:function(a){var b={duration:"slow",easing:"swing"};var a=$.extend(b,a);var c=function(b){$("html,body").animate({scrollTop:$(b).offset().top},a.duration,a.easing,function(){location.hash=b})};if(location.hash.length>1)c(location.hash);return this.each(function(){$(this).click(function(a){var b=$(this).attr("href").replace("^([^#]+)#","#");c(b);a.preventDefault()})})}})
		
    $(document).ready(function(){   
    	
    	//HTML5 Placeholders
		$('input[placeholder], textarea[placeholder]').placeholder();      
    
    	//Smooth scroll to element ID
		if($(".scrollTo").length)	$(".scrollTo").scrollWindow();
	    
    	//FAQ Slidedown
    	$('#faqs h3').click(function(e){
    		var tis = $(this);
    		
    		tis.toggleClass('active');
    		
    		var slider = tis.next();
    		if(slider.hasClass("active")){
    			slider.find(".wrapper").slideUp('2000', "easeInOutSine", function(){
    				slider.toggleClass("active");
    			});
    		}else {
    			slider.find(".wrapper").slideDown('2000', "easeInOutSine", function(){
    				slider.toggleClass("active");
    			});
    		}
    		
    		e.preventDefault();
    	});
    	
    	$('#faqs .answer').click(function(e){
    		var tis = $(this);
    		
    		if(tis.hasClass("active")){
    			tis.find(".wrapper").slideUp('2000', "easeInOutSine", function(){
    				tis.toggleClass("active");
    			});
    		}else {
    			tis.find(".wrapper").slideDown('2000', "easeInOutSine", function(){
    				tis.toggleClass("active");
    			});
    		}
    		
    		tis.prev().toggleClass("active");
    	});
                             
    });
})(jQuery);
	


function grayOut(vis, options, ImgNum, ShowKey) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');



	if(ImgNum < 5){
		NextNum = ImgNum+1;
	}else{
		NextNum = 1;
	}
	
	if(ImgNum > 1){
		PrevNum = ImgNum-1;
	}else{
		PrevNum = 5;
	}
	
	ImgURI = ShowKey +'-'+ ImgNum +'.jpg';
	




	var imgObject=document.getElementById('imgObject');
	
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.zIndex=zindex;        
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';

	//imgObject display stuff
	imgObject.style.width= pageWidth;
    imgObject.style.height= pageHeight;
	imgObject.style.display='block';
	//html for image div
	imgObject.innerHTML = '<div style="position:relative;border:1px solid #000000;width:600px;margin:auto;margin-top:100px;padding:15px;background-color:#FFFFFF;text-align:center;"><img src="images/slideshow/full/'+ ImgURI +'" /><div style="position:absolute;top:0px;right:0px;"><a href="javascript:grayOut(false,false,false)" style="font-size:12px;text-decoration:none;"><b>[X]</b></a></div><div style="position:absolute;bottom:0px;right:0px;"><a style="font-size:12px;text-decoration:none;" href="javascript:grayOut(true,\'\',' + NextNum + ',\'' + ShowKey + '\')"><b>Next &gt;</b></a></div><div style="position:absolute;bottom:0px;left:0px;"><a style="font-size:12px;text-decoration:none;" href="javascript:grayOut(true,\'\',' + PrevNum + ',\'' + ShowKey + '\')"><b>&lt; Previous</b></a></div></div>';
  } else {
	//hide divs
    dark.style.display='none';
	imgObject.style.display='none';
  }
}
