
/************************* Tab functionality *********************/

hsq(function () {
			var tabContainers = hsq('#mktIndex div.eachSection');
			tabContainers.hide().filter(':first').show();
			hsq('#mktIndex ul.tabList a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				hsq('#mktIndex ul.tabList a').removeClass('on');
				hsq(this).addClass('on');
				return false;
			}).filter(':first').click();
});


hsq(function () {
			var tabContainers1 = hsq('.tabContainers div.eachSection');
			tabContainers1.hide().filter(':first').show();
			
			hsq('.tabContainers ul.tabList a').click(function () {
				tabContainers1.hide();
				tabContainers1.filter(this.hash).show();
				hsq('.tabContainers ul.tabList a').removeClass('on');
				hsq(this).addClass('on');
				return false;
			}).filter(':first').click();
});




/*hsq(function () {
			var tabContainers = hsq('div#team > div');
			tabContainers.hide().filter(':first').show();
			
			hsq('div#team ul.teamBtns a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				hsq('div#team ul.teamBtns a').removeClass('on');
				hsq(this).addClass('on');
				return false;
			}).filter(':first').click();
});*/

/**************************** Directors page **************************/
  hsq(function () {  
        hsq('div.teamL div, div.director').css('display', 'none');
		hsq('div.box a img').fadeTo( 'fast', 0.4 ).click(function(event){
			
			var prabhat;
			
			if(event.target.id.length==3)
				{
					prabhat = (event.target.id.charAt(1)+event.target.id.charAt(2) - 1); 
				}
				else
					{
						prabhat = (event.target.id.charAt(1) - 1); 
					}
			
			//var prabhat = (event.target.id.charAt(1) - 1); 
			
			
			hsq('div.teamL div').css('display', 'none');
			hsq(hsq('div.teamL div')[prabhat]).fadeIn('slow');
			hsq('div.director').css('display', 'none').eq(prabhat).fadeIn('slow');
			hsq('div.box a img').fadeTo( 'slow', 0.4 ).removeClass('selected').eq(prabhat).fadeTo('slow', 1 ).addClass('selected');
		return false;	
		}).mouseover(function(event) {
		hsq(event.target).fadeTo('fast', 1 );
		}).mouseout(function(event) {
			if( !hsq(event.target).hasClass('selected') ) {
				hsq(event.target).fadeTo( 'fast', 0.4 );
			}
		});
		hsq('div.teamL div').eq(0).fadeIn( 'slow');
		hsq('div.box a img').eq(0).fadeTo( 'slow', 1 ).addClass('selected');
		hsq('div.director').eq(0).fadeIn( 'slow');
		
    });
		
		
		
		
		
		
/*=================================== AAA js START HERE =========================================*/
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

var selected = 'small';
var selectedClassName = 'selectedLink';
function _aaa(ele) {
	if ($hs.cookie('aaa')) {
		$hs(selected).removeClass(selectedClassName);
		$hs('body').css({'fontSize':$hs.cookie('aaa')});
	
		ele = ele ? $hs(ele).addClass(selectedClassName) :linkactive();    
	
	} else {
document.getElementById(selected).className=selectedClassName;
	
	}
}
function linkactive()
{
 //$hs($hs.cookie('aaaEle')).addClass(selectedClassName)
var $hsab=$hs.cookie('aaaEle');
document.getElementById($hsab).className=document.getElementById($hsab).className+" "+ selectedClassName;
 
}
function aaa(size, ele) {
	//$hs($hs.cookie('aaaEle')) ? $hs($hs.cookie('aaaEle')).removeClass(selectedClassName) : '';
	$hs('.selectedLink').removeClass(selectedClassName);
	$hs.cookie('aaa', size);
	$hs.cookie('aaaEle', ele.id);
	_aaa(ele);
}




jQuery(document).ready(function(){_aaa();});

/*=================================== AAA js END HERE =========================================*/	






/*=================================== COMMON js START HERE =========================================*/	

// hover images

function imgHov(e) {
if(e.src.match('_h.gif')) {

	e.src = e.src.replace(/_h.gif/i, ".gif");

	}  else {

		e.src = e.src.replace(/.gif/i, "_h.gif");

	}
}

// prevent to run blank serach box 


function setupSearch(button, text){
var default_message = "Search site";
	btn = document.getElementById(button);
	txt = document.getElementById(text);
	txt.value = default_message;

	txt.onclick = function(){
		if(this.value==default_message){
		this.value='';
		}
	}

	btn.onclick = function(){
		txt = document.getElementById(text);  
		var val = trim(txt.value, ' ');
		if(val==default_message|val==""){
			alert("Please enter a search text");
			txt.value = default_message;
			return false;
		}
	}
}
function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}




// Home page slider

$(document).ready(function() {

	//Set Default State of each portfolio piece
	$(".paging").hide();
	$(".paging a:first").addClass("active");
		
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageWidth = $(".window").width();
	var imageSum = $(".image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//Adjust the image reel to its new size
	$(".image_reel").css({'width' : (imageReelWidth/12) + 'em'});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = $active.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

		$(".paging a").removeClass('active'); //Remove all active class
		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
		//Slider Animation
		$(".image_reel").animate({ 
			left: -(image_reelPosition/12) + 'em'
		}, 500 );
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('.paging a.active').next();
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('.paging a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 17000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	
	//On Hover
	$(".image_reel a").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	
	
	//On Click
	$(".paging a").click(function() {	
		$active = $(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation
		return false; //Prevent browser jump to link anchor
	});	
	
});

/*=================================== COMMON js END HERE =========================================*/	



