/*
 * $Id: js.js,v 1.00 2008/10/01 00:00:59 acatalano Exp $
 * Copyright(c) 2008, Amelia Timbang Catalano. All rights reserved
 */

/* AVOID $ CONFLICT */
var $J = jQuery.noConflict();


/* PAGE OBJECT */
Page = function(sectionNum){
	this.secNav = new Array;
	this.sections = new Array;
	this.mainClassName = "style" + sectionNum;
	this.init();
};

Page.prototype = {
	init : function() {
		this.secNav = $J("#secondaryHeader li");
		this.sections = $J("#content .section");
	
		this.setMainClass();
		this.setSecNavEvent();
		
	},
	setSecNavEvent : function() {
		try {
			for (var i = 0; i < this.secNav.length; i++) {
				$J(this.secNav[i]).bind("click",{navArray : this.secNav, sectionsArray : this.sections},this.activateItem); 
			}
		}
		catch(e) {}
	},
	setMainClass : function() {
		if (this.mainClassName) $J("#main").toggleClass(this.mainClassName);
	},
	activateItem : function(e) {
		for (var i = 0; i <e.data.navArray.length; i++) {
			if (e.data.navArray[i] == this) {
				$J(e.data.navArray[i]).addClass('current');
				$J(e.data.sectionsArray[i]).css('display','block');
			}
			else {
				$J(e.data.navArray[i]).removeClass('current');
				$J(e.data.sectionsArray[i]).css('display','none');
			}
		}	
	}
}


/* SCROLLING FOR GALLERY */
var Scroll = {
	step : 198,
	inScroll : false,
	maxLeft : null,
	maxRight : null,
	curSlideIndex : 0,
	maxSlideIndex : 3,
	init : function() {
		var c = $J("#slides li:first").offset();
		this.maxLeft = c.left;
		this.maxRight = this.maxLeft - ( this.step * 3 );
		$J("#right").bind( "click",{ temp : this }, this.scrollRight );
		$J("#left").bind( "click",{ temp : this }, this.scrollLeft );
	},
	scrollLeft : function(o) {
		var curOffset = $J("#slides li:first").offset();
		
		if ( curOffset.left < o.data.temp.maxLeft ) {
			if ( !o.data.temp.inScroll ) {
				o.data.temp.curSlideIndex--;
				o.data.temp.inScroll = true;
			
				$J("#slides").animate({
					left : "+=" + o.data.temp.step + "px"
					}, 500, o.data.temp.resetScroll);
    		}
		}
	},
	scrollRight : function(o) {
		var curOffset = $J("#slides li:first").offset();
		
		if ( curOffset.left >= o.data.temp.maxRight ) {
			if (!o.data.temp.inScroll) {
				o.data.temp.curSlideIndex++;
				o.data.temp.inScroll = true;
			
				$J("#slides").animate({
					left : "-=" + o.data.temp.step + "px"
					}, 500, o.data.temp.resetScroll);
    		}
		}
	},
	resetScroll : function() {
		Scroll.inScroll= false;
		
		if (Scroll.curSlideIndex > 0) {
			$J('#left').removeClass('inactive');
		
			if (Scroll.curSlideIndex > Scroll.maxSlideIndex) 			
				$J('#right').addClass('inactive');
			else
				$J('#right').removeClass('inactive');
		}
		else $J('#left').addClass('inactive');
	}
}


/* REMOVE (E) & (T) FROM WEB CRAWLER VIEW */
obfuscateInfo = function() {
	var e = "&#109;&#97;i&#108;t&#111;&#58;";
	var e2 = "&#97;&#109;&#101;&#108;&#105;&#97&#64;&#97;&#109;&#101;&#108;&#105;&#97c&#97;tal&#97n&#111;&#46;&#99;&#111;m";
		
	var p1 = "&#40;4&#49;&#53;&#41;&#32;";
	var p2 = "271&#45;";
	var p3 = "&#52;095";
	$J("#emailMe").append("e: <a href=\"" + e+e2+"\">" + e2 + "</a>");
	$J("#callMe").append("t: " + p1 + p2 + p3);
}


/* SET ONCLICK FOR HEADER ON ALL PAGES */
$J(document).ready(function(){
	$J("#header h1").bind("click",function(){
		document.location.href = "/";
	
	});

});
