/*
Description: New Site
Author: Barnum Design
*/	


jQuery.noConflict();
jQuery(document).ready(function($){
							
/////* Global variables */////
Loc=document.location.href;
breadcrumb=$('#catalog_crumb');
Dir0 = Loc.split('/')[3];
Dir1 = Loc.split('/')[4];
Dir2 = Loc.split('/')[5];
Dir3 = Loc.split('/')[6];
Uns1 = Loc.split('_')[1];
section="";
load_bg_body=false;
slide_tick="";

/////* Templates */////

if(Dir0!=""){ // all but the portal
$('a.Logo').addClass('sub');
$('#tabs').tabs();
}
if((Dir0=="work" && Dir2=="") || Dir0=="studio"){
load_bg_body=true;
//$('ul#slide-nav').fadeIn('slow');
/* Flash Bg */
var flashvars={};
var params={play:"true",loop:"false",scale:"noborder",quality:"high",wmode:"transparent",allowfullscreen:"false",allowscriptaccess:"always"};
var attributes={id:"bg_body",name:"bg_body"};
swfobject.embedSWF("/flash/bg_body.swf","bg_body","100%","100%","10","/flash/expressInstall.swf",flashvars,params,attributes);
}
if(Dir0.substring(0,17)=="CatalogueRetrieve" || Uns1=="product" || Uns1=="catalog" || Dir0.substring(0,15)=="OrderRetrievev2" || Dir0.substring(0,13)=="OrderRetrieve" || Dir0.substring(0,12)=="Default.aspx" || Dir0.substring(0,13)=="MemberProcess") {
$('#Wrap').addClass('catalog');
	if(Uns1=="catalog"){
	$('#Wrap').addClass('prod-small');
	}
	if(Uns1=="product"){
	$('#Wrap').addClass('prod-large');
	}
}
else if(Dir0==""){ // portal
$('a.Logo').addClass('home');


if(loggedin="1"){
	$('.Left_nav ul li.vault').show();
}

/*
if loggedin = "1"{
	$('.vault-content').show();
	$('.vault-login').hide();
}
if loggedin = "0"{
	$('.vault-login').show();
	$('.vault-content').hide();
}
*/

/* Flash Intro */
/*
var flashvars={};
var params={play:"true",loop:"false",scale:"noborder",quality:"high",wmode:"transparent",allowfullscreen:"false",allowscriptaccess:"always"};
var attributes={id:"bg_intro",name:"bg_intro"};
swfobject.embedSWF("/flash/bg_intro.swf","bg_intro","100%","100%","10","/flash/expressInstall.swf",flashvars,params,attributes);
*/
}
else if(Dir0=="work" && Dir1=="Ellman_Family_Vineyards" && Dir2==""){
section="EFV";
}
else if(Dir0=="work" && Dir1=="David_Kirsch_Wellness_Co" && Dir2==""){
section="DKWC";
}
else if(Dir0=="work" && Dir1=="Resolute_Racing_Shells" && Dir2==""){
section="RRS";
}
else if(Dir0=="work" && Dir1=="Sherle_Wagner_Architectural" && Dir2==""){
section="SWA";
}
else if(Dir0=="work" && Dir1=="Eileen_Fisher" && Dir2==""){
section="ELF";
}
else if(Dir0=="work" && Dir1=="General_Composites" && Dir2==""){
section="GCI";
}
else if(Dir0=="work" && Dir1=="PranaSleep" && Dir2==""){
section="PRS";
}
else if(Dir0=="work" && Dir1=="Roz_Goldfarb_Associates" && Dir2==""){
section="RGA";
}
else if(Dir0=="work" && Dir1=="Ted_Conference" && Dir2==""){
section="TED";
}
else if(Dir0=="work" && Dir1=="CET_Films" && Dir2==""){
section="CET";
}
else if(Dir0=="work" && Dir1=="R_Tape" && Dir2==""){
section="RTP";
}
else if(Dir0=="work" && Dir1=="Allied_Minds" && Dir2==""){
section="ALMD";
}
else if(Dir0=="work" && Dir1=="Logos" && Dir2==""){
section="LOGO";
}
else if(Dir0=="work" && Dir1=="Purtein" && Dir2==""){
section="PRT";
}
else if(Dir0=="studio" && Dir1==""){
section="STUDIO";
}

else{ 
}


///// BG Slider
if ($('#bg_slides').height()!=null){
	
	///// Bg Slider images load
	$('#bg_intro').html($('#bg_slides').html());
	setTimeout(function(){$('#bg_intro').animate({opacity:1},4000)},4000);
	
	///// Bg Slider fullscreen resize
	$("#bg_intro").ezBgResize();
	
	///// Bg Slideshow
	$('#bg_intro').innerfade({
	animationtype: 'fade',
	speed: 4000,
	timeout: 10000,
	type: 'sequence',
	containerheight: '900px'
	});

}

$('.sub-box button').click(function(){$(null).innerfade.next()});




///// Fancy Box 
$('a.ltbx').fancybox({'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':200,'overlayShow':true});
$('a.ltbx a').fancybox({'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':200,'overlayShow':true});
$('a.ltbx.win').fancybox({'width':600,'height':600,'autoDimensions':false});
$("a.ltbx.if").fancybox({'width':718,'height':286,'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe', 'scrolling': 'no', 'onClosed': function(){parent.location.reload(true)}});
$("a.ltbx.if-fpwd").fancybox({'width':310,'height':156,'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe', 'scrolling': 'no', 'onClosed': function(){parent.location.reload(true)}});


$('a.ltbx.allied').fancybox({'autoDimensions':true, 'onStart': function(){}, 'onClosed': function(){}});



///// Reisizr 
$(".resizr img").each(function(){$(this).cjObjectScaler({method:"fit",fade: 800});});

///// Nav
$('.s-nav a').each(function(){;
var SubA=$(this);
var SubL=this.href;
	if (SubL==Loc || (SubL.split('/')[3]==Loc.split('/')[3] && SubL.split('/')[4]=="") || SubA.html()==breadcrumb.html() || ($('#Account')!=null && (SubL.split('/')[3]=="Account" && SubL.split('/')[4]=="") || (Loc.split('/')[3].substring(0,12)=="CaseRetrieve" && SubL.split('/')[4]=="Case_History.htm") || (Loc.split('/')[3].substring(0,19) == "OrderSecureRetrieve" && SubL.split('/')[4] == "Order_History.htm")) || (SubL.split('/')[3]=="Store" && (Loc.split('_')[1]=="catalog" || Loc.split('_')[1]=="product" || Loc.split('/')[3].substring(0,13)=="OrderRetrieve" || Loc.split('/')[3].substring(0,17)=="CatalogueRetrieve")) || (SubL.split('/')[4]== "FAQs.htm" && (Loc.split('/')[3].substring(0,11)=="FAQRetrieve" || Loc.split('/')[3].substring(15,18)=="FAQ"))) {
	$(this).attr('class', 'active');
	$(this).parents('li').attr('class', 'selected')
	}
});

///// SZ Login Nav
if(loggedin==1){
$('.loggedIn').css('display', 'block'); 
}
else {
$('.loggedOut').css('display', 'block');
}

///// IE6 
if(typeof ie6!="undefined"){
//// Trans bg
$('.trans').each(function(){$(this).height($(this).parent().outerHeight());});
}

//// Google map
var map = null;	
var geocoder = null;	
function initialize() {	
	if (GBrowserIsCompatible()) {	
	map = new GMap2(document.getElementById("map_canvas"));	
	map.setCenter(new GLatLng(-30.4693, 150.0179), 13);	
	map.addControl(new GLargeMapControl());	
	map.addControl(new GMapTypeControl());	
	geocoder = new GClientGeocoder();	
	}}	
	function showAddress(address,title) {	
	if (geocoder) {	
	geocoder.getLatLng(	
	address,	
	function(point) {	
	if (!point) {	
	alert(address + " not found");	
	} else {	
	map.setCenter(point, 13);	
	var marker = new GMarker(point);	
	map.addOverlay(marker);	
	marker.openInfoWindowHtml(title+"<br />"+address);	
	}});}}

//// Google map - custom address targetting
if($('#gMap_addr').html()!=null){
var gMap_address=$("#gMap_addr").html();
var gMap_title=$("#gMap_title").html();
initialize();
showAddress(gMap_address,gMap_title);
$('#Wrap #map_canvas').parent().hide();
}

///// work sub-box slide
var subBox = $('.page-body.work .sub-box');
setTimeout(function(){subBox.animate({bottom:[15 - subBox.height()]+"px"},2000)},4000);
$('.page-body.work .sub-box h1').toggle(
function(){
	subBox.toggleClass("active");
	subBox.animate({bottom:"0px"},1000)
	},
function(){
	subBox.toggleClass("active");
	subBox.animate({bottom:[15 - subBox.height()]+"px"},1000)
	}
);

//// Work slide nav tick
$('ul#slide-nav li.plus').click(function(){
slide_tick="plus";							  
document['bg_body'].slideShow(slide_tick);
});
$('ul#slide-nav li.minus').click(function(){
slide_tick="minus";
document['bg_body'].slideShow(slide_tick);
});
});

/////* Flash bg call *//////
function slideInit(){
	document.getElementById('slide-nav').style.display="block";
}
function loadRequest(){
	if(load_bg_body==true){
	document['bg_body'].loadInit(section);
	}
}

