/*
Description: All41CC
Author: Ebitienyefa Baralaye
*/	

var $j = jQuery.noConflict();
$j(document).ready(function(){
							
/////* Global variables */////
Loc=document.location.href;
breadcrumb=$j('#catalog_crumb');
Dir0 = Loc.split('/')[3];
Dir1 = Loc.split('/')[4];
Dir2 = Loc.split('/')[5];
Dir3 = Loc.split('/')[6];
Uns1 = Loc.split('_')[1];
section="";

/////* Templates */////
if(Dir1!="index.htm" && Dir1!=""){ // all but the portal
}
if(Uns1!="catalog" && Dir1!="");
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") {
$j('.Wrap').addClass('catalog');
	if(Uns1=="catalog"){
	$j('.Wrap').addClass('prod-small');
	}
	if(Uns1=="product"){
	$j('.Wrap').addClass('prod-large');
	}
}
else if(Dir1==""){
section="home";
// Flash embedd
/*
var flashvars={};
var params={play:"true",loop:"false",scale:"noscale",salign:"tl",quality:"high",wmode:"transparent",allowfullscreen:"true",allowscriptaccess:"always"};
var attributes={};
swfobject.embedSWF("/flash/banner.swf","intro_banner","675","250","9.0.0",false,flashvars,params,attributes);
*/
}
else if(Dir0.substring(0,20)=="AnnouncementRetrieve"){
section="Events";
}
else{ 
section="default";
}

///// Fancy Box 
$j('a.ltbx').fancybox({'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':200,'overlayShow':true});
$j('a.ltbx a').fancybox({'transitionIn':'elastic','transitionOut':'elastic','speedIn':600,'speedOut':200,'overlayShow':true});
$j('a.ltbx.win').fancybox({'width':600,'height':600,'autoDimensions':false});
$j("a.ltbx.if").fancybox({'width':'75%','height':'75%','autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});

///// Reisizr 
$j(".resizr img").each(function(){$j(this).cjObjectScaler({method:"fit",fade: 800});});

//// Nav
$j('.s-nav a').each(function(){;
var SubA=$j(this);
var SubL=this.href;
var sDir0 = SubL.split('/')[3];
var sDir1 = SubL.split('/')[4];
var sHsh = SubL.split('#')[1];
	if (SubL==Loc || (sDir0==Dir0 && sHsh==null) || SubA.html()==breadcrumb.html() || ($j('#Account')!=null && (sDir0=="Account" && sDir1=="") || (Dir0.substring(0,12)=="CaseRetrieve" && sDir1=="Case_History.htm") || (Dir0.substring(0,19) == "OrderSecureRetrieve" && sDir1 == "Order_History.htm")) || (sDir0=="Store" && (Uns1=="catalog" || Loc.split('_')[1]=="product" || Dir0.substring(0,13)=="OrderRetrieve" || Dir0.substring(0,17)=="CatalogueRetrieve")) || (sDir1== "FAQs.htm" && (Dir0.substring(0,11)=="FAQRetrieve" || Dir0.substring(15,18)=="FAQ"))) {
	$j(this).attr('class', 'active');
	$j(this).parents('li').attr('class', 'selected')
	}
});

///// SZ Login Nav
if(loggedin==1){
$j('.loggedIn').css('display', 'block'); 
}
else {
$j('.loggedOut').css('display', 'block');
}

///// TopNav
$j('#TopNav > div > ul > li ').mouseover(function(){
$j(this).siblings().removeClass('selected');
$j(this).addClass('selected');
 $j(this).mouseleave(function(){
 $j(this).removeClass('selected');
 });
});

///// IE6 
if(typeof ie6!=undefined){
//// Trans bg
$j('.trans').each(function(){$j(this).height($j(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($j('#gMap_addr').html()!=null){
var gMap_address=$j("#gMap_addr").html();
var gMap_title=$j("#gMap_title").html();
initialize();
showAddress(gMap_address,gMap_title);
$j('#Wrap #map_canvas').parent().hide();
}

});
