// JavaScript Document

$(document).ready(function(){
							   
	// PRETTY PHOTO
	if($("a[rel^='prettyPhoto']").size() > 0){
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal', /* fast/slow/normal */
			padding: 40, /* padding for each side of the picture */
			opacity: 0.35, /* Value betwee 0 and 1 */
			showTitle: true, /* true/false */
			allowresize: true, /* true/false */
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
			autoplay: false,
			overlay_gallery: false,
			deeplinking: false,
			social_tools: false
		});
	}
	
	// TABBED PAGES
	if(document.getElementById('tabs')){
		
		// ADD TAB FUNCTIONALITY
		var e, i = 0;
		while (e = document.getElementById('tabs').getElementsByTagName('DIV')[i++]) {
			if (e.className == 'tabs-on' || e.className == 'tabs-off') {
				e.onclick = function () {
					
					// STOP THE VIDEO IF ITS PLAYING
					try{
						var player = document.getElementById('swf_video');
						player.sendEvent('STOP');
					}catch(e){}
					
					// CLOSE ALL TABS AND PANELS
					var getEls = document.getElementsByTagName('DIV');
						for (var z=0; z<getEls.length; z++) {
							getEls[z].className = getEls[z].className.replace('tabs-show', 'tabs-hide');
							getEls[z].className = getEls[z].className.replace('tabs-on', 'tabs-off');
						}
						
					// OPEN THIS TAB AND PANEL
					this.className = 'tabs-on';
					var max = this.getAttribute('title');
					if(document.getElementById(max))
						document.getElementById(max).className = "tabs-show";
				}
			}
		}
	}
	
			
});
