// JavaScript Document
function accordianT(id, n) {
    for (i = 1; i <= n; i++) {
        if (i == id) {
            jQuery('#vTab' + i).next('div.productList').slideDown('slow');
            t = jQuery('#vTab' + i).find('img').attr("src");
            if (t.charAt(15) == 'f') {
                t = t.replace("Off", "On");
                jQuery('#vTab' + i).find('img').attr("src", t);
            } else {
                t = t.replace("On", "On");
                jQuery('#vTab' + i).find('img').attr("src", t);
            }
        } else {
            jQuery('#vTab' + i).next('div.productList').slideUp('slow');
            t = jQuery('#vTab' + i).find('img').attr("src");
            if (t.charAt(15) == 'n') {
                t = t.replace("On", "Off");
                jQuery('#vTab' + i).find('img').attr("src", t);
            } else {
                t = t.replace("Off", "Off");
                jQuery('#vTab' + i).find('img').attr("src", t);
            }
        }
    }
}

jQuery(document).ready(function () {
       var i = 1;
    var j = 1;
    var newHeight = 0;
    var newHeight1 = 0;
    var hght2 = 0;
    var maxItem;
    var scrollCount = 0;
	var imageIsOn=false;
    jQuery(".swapImg").hover(function () {
		jQuery(this).parent('a').css('z-index','10001');
		if(jQuery(this).attr('src').indexOf("Off")!=-1)
		{
		//alert('off');
		imageIsOn=false;
		
		temp = jQuery(this).attr("src");
       	temp = temp.replace("Off", "AltH");
        jQuery(this).attr("src", temp);
		}
		else{
		//alert('on');
		
		imageIsOn=true;
        temp = jQuery(this).attr("src");
        temp = temp.replace("On", "AltH");
        jQuery(this).attr("src", temp);
		}
	
    },
    function () {
		if(jQuery(this).attr('src').indexOf("AltH")!=-1)
		{
			if(imageIsOn==true)
			{
			//	alert('true')
			temp = jQuery(this).attr("src");
			temp = temp.replace("AltH", "On");
			jQuery(this).attr("src", temp);
			
			}
			else
			{
			//	alert('false')
			temp = jQuery(this).attr("src");
			temp = temp.replace("AltH", "Off");
			jQuery(this).attr("src", temp);
			
			}
		}
		else{
        temp = jQuery(this).attr("src");
        temp = temp.replace("AltH", "On");
        jQuery(this).attr("src", temp);
		}
		jQuery(this).parent('a').css('z-index','');
    });

    jQuery(".tabOuter").hover(function () {
        temp = jQuery(this).find(".tabHead img").attr("src");
        temp = temp.replace("Off", "On");
        jQuery(this).find(".tabHead img").attr("src", temp);
    },
    function () {
        temp = jQuery(this).find(".tabHead img").attr("src");
        temp = temp.replace("On", "Off");
        jQuery(this).find(".tabHead img").attr("src", temp);
    });

    jQuery("#down").click(function () {
        maxItem = jQuery(".homeTopRghtList ul").children('li').length;
        hght = jQuery("#newsListCont").height();
        if (scrollCount <= maxItem - 4) {
            scrollCount = scrollCount + 1;
            jQuery('#newsList').animate({
                top: '-' + scrollCount * (hght / 2) + 'px'
            },
            500);
        }
        i++;
    });

    jQuery("#up").click(function () {
        hght = jQuery("#newsListCont").height();
        if (scrollCount > 0) {
            scrollCount = scrollCount - 1;
            jQuery('#newsList').animate({
                top: '-' + scrollCount * (hght / 2) + 'px'
            },
            500);
        }
        j++;
    });

});



function accordianListT(id, n) {
    for (i = 1; i <= n; i++) {
        if (i == id) {
            jQuery('#ddHead' + i).next('div.ddcontent').slideDown('slow');
            jQuery('#ddHead' + i).children('a').attr('class', 'ddMenuOn');

        } else {
            jQuery('#ddHead' + i).next('div.ddcontent').slideUp('slow');
            jQuery('#ddHead' + i).children('a').attr('class', 'ddMenuOff');
        }
    }
}

jQuery(document).ready(function () {
    jQuery('.dropDownOutFram').hide();
    jQuery(".menu-sec ul li .mainHead").hover(function () {
		jQuery(this).parent().find('.dropDownOutFram').show();
		jQuery(this).css('z-index','10001');
		temp = jQuery(this).children("img").attr("src");
        temp = temp.replace("Off", "On");
        jQuery(this).find("img").attr("src", temp);
    },
    function () {
        jQuery(this).parent().find('.dropDownOutFram').hide();
		jQuery(this).css('z-index','');
		temp = jQuery(this).children("img").attr("src");
        temp = temp.replace("On", "Off");
        jQuery(this).find("img").attr("src", temp);
    });

    jQuery('.dropDownOutFram').hover(function () {
        jQuery(this).show();
		jQuery(this).prev().addClass('mainMenuOn');
		jQuery(this).prev().css('z-index','10001');
		temp = jQuery(this).prev().children("img").attr("src");
        temp = temp.replace("Off", "On");
        jQuery(this).prev().find("img").attr("src", temp);
    },
    function () {
        jQuery(this).hide();
		jQuery(this).prev().removeClass('mainMenuOn');
		jQuery(this).prev().css('z-index','');
		temp = jQuery(this).prev().children("img").attr("src");
        temp = temp.replace("On", "Off");
        jQuery(this).prev().find("img").attr("src", temp);
    });
});



jQuery(document).ready(function () {
initTabSecHeight = jQuery("#conlsLink1").height() + parseInt(jQuery("#conlsLink1").css("padding-top"), 10) + parseInt(jQuery("#conlsLink1").css("padding-bottom"), 10)
minHeight = jQuery('.tabs').height();
if(initTabSecHeight<minHeight){
jQuery(".tabContentSection").height(minHeight+20)}
else
{jQuery(".tabContentSection").height(initTabSecHeight)}
jQuery(".tabContentSection .tabCont").css('min-height',minHeight+'px');
jQuery(".tabs li").click(function () {
var sectionid = (this.id);
var tabHeight = jQuery(".tabs").height();
var consection = ("con" + sectionid)
var str = sectionid.replace("lsLink", "");
var sectionwidth = (jQuery('#con' + sectionid).width() + parseInt(jQuery('#con' + sectionid).css("padding-left"), 10) + parseInt(jQuery('#con' + sectionid).css("padding-right"), 10));
 var sectionHeight = (jQuery('#con' + sectionid).height() + parseInt(jQuery('#con' + sectionid).css("padding-top"), 10) + parseInt(jQuery('#con' + sectionid).css("padding-bottom"), 10)); 
	if( sectionHeight < tabHeight)
    {
		
		//jQuery(".tabContentSection").height();
		jQuery(".tabContentSection").animate( { height:(jQuery('.tabs').height()+20)+"px" }, { queue:false, duration:500 });
		
	}
	else
	{
		//jQuery(".tabContentSection").height(sectionHeight);*/
		jQuery(".tabContentSection").animate( { height:sectionHeight+"px" }, { queue:false, duration:500 });
	}

        for (i = 1; i <= jQuery(".tabs li").length; i++) {
			var src = jQuery(".tabs li").eq(i-1).children('img').attr('src');
            if (i == str) 
			{
				jQuery(this).children('img').attr('src',src.replace('Off','On'));
                jQuery("#con" + sectionid).css({marginLeft: -sectionwidth},500);
                jQuery("#con" + sectionid).css({display: "inline"},500);
                jQuery("#conlsLink" + i).stop().animate({marginLeft: "0px"},500);
				/*if( sectionHeight < tabHeight)
				{
				//alert(sectionHeight);
				jQuery(".tabContentSection").animate( { height:(jQuery('.tabs').height()+20)+"px" }, { queue:false, duration:500 });
				jQuery("#conlsLink" + i).height(jQuery('.tabs').height()+20);
					
				}
				else
				{
					//alert(sectionHeight);
					jQuery(".tabContentSection").animate( { height:sectionHeight+"px" }, { queue:false, duration:500 });
					jQuery("#conlsLink" + i).height(sectionHeight);
				}*/
            } 
			else {
				
				jQuery(".tabs li").eq(i-1).children('img').attr('src',src.replace('On','Off'));
                jQuery("#conlsLink" + i).stop().animate({marginLeft: sectionwidth},500);
            }
        }
    });
});

jQuery(document).ready(function () {
    jQuery(".tabs li").click(function () {
        jQuery(".tabs li").attr('class', 'tabOff');
		jQuery(this).attr('class', 'tabOn');
   });
})

function accordian(id, current, nextDiv, n) {
    for (i = 1; i <= n; i++) {
        if (i == current) {
            jQuery('#' + id + i).next('div.' + nextDiv).slideDown('slow');
            jQuery('#' + id + i).attr('class', 'accHeadOn');
            tempSrc = jQuery('#' + id + i).find('img').attr('src');
            tempSrc = tempSrc.replace("Off", "On");
            jQuery('#' + id + i).find('img').attr("src", tempSrc);
        } else {

            jQuery('#' + id + i).next('div.' + nextDiv).slideUp('slow');
            if (current == 2) {
                jQuery('#' + id + i).attr('class', 'accHead1Off');
            } else {
                jQuery('#' + id + i).attr('class', 'accHead2Off');
            }
            tempSrc = jQuery('#' + id + i).find('img').attr('src');
            tempSrc = tempSrc.replace("On", "Off");
            jQuery('#' + id + i).find('img').attr("src", tempSrc);
        }
    }
}



jQuery(document).ready(function () {
    jQuery(".exCoHead a").click(function () {
        jQuery(this).parents('.exCoHead').next().slideToggle('slow', function(){
               jQuery(this).prev().children().find('a').toggleClass('On');
				jQuery(this).prev().children().find('a').text(jQuery(this).prev().children().find('a').text() == 'Collapse' ? 'Expand' : 'Collapse');
        });
		
   });
})



jQuery(document).ready(function() {

	for(i=0;i<jQuery('#advThumbCont li').length;i++)
	{
		jQuery('#advThumbCont li').eq(i).addClass('directors_li'+i)
	}
	
	for(i=0;i<jQuery('#boardThumbCont li').length;i++)
	{
		jQuery('#boardThumbCont li').eq(i).addClass('advisory_li'+i)
	}
	
    var tabContainers = jQuery('div.expandCollapseTab > div.exCoTabContent');
	jQuery('#boardThumbCont').jCarouselLite({
        btnNext: ".boardNext",
        btnPrev: ".boardPrev",
	visible: 3,
	speed: 600,
	circular: true
		
    });
	jQuery('#advThumbCont').jCarouselLite({
        btnNext: ".advNext",
        btnPrev: ".advPrev",
	visible: 3,
	speed: 600,
	circular: true
		
    });
	tabContainers.css('display','none').filter(':first').css('display','block');
  	jQuery('div.exCoTabHead ul a').click(function() {
        tabContainers.css('display','none');
        tabContainers.filter(this.hash).css('display','block');
        jQuery('div.exCoTabHead ul li').removeClass('on');
      	jQuery(this).parents('li').addClass('on');
        return false;
    });
});

/* Partners and alliance  */
jQuery(document).ready(function() {
	jQuery('.docBlk').hide();							
	jQuery('.toggleShow').click(function() {
		jQuery(this).prev().slideToggle('slow');
		jQuery(this).text(jQuery(this).text() == 'More..' ? 'Hide..' : 'More..');
	});
});
jQuery(document).ready(function() {
jQuery('.profilePopUp').hide();
jQuery('.leadershipTBlk ul li a').click(function() {
	if(jQuery(this).parents('li').find('.profilePopUp').length==0)
	{	alert('hi')
		jQuery(this).parents('li').css('position','')
	}
	else{
	//jQuery(this).parents('li').css('position','relative')
	}
	jQuery(this).parents('li').children('.profilePopUp').show();
});
jQuery('.profilePopUpHead').click(function() {
	//alert('hi')
	jQuery(this).parents('li').find('.profilePopUp').hide();
	jQuery(this).parents('li').css('position','');
})

jQuery('.leadershipBlk ul li a').click(function() {
	if(jQuery(this).parents('li').find('.profilePopUp').length==0)
	{	//alert('hi')
		jQuery(this).parents('li').css('position','')
	}
	else{
	//jQuery(this).parents('li').css('position','relative')
	}
	jQuery(this).parents('li').children('.profilePopUp').show();
});

});


/* Next Step  */

jQuery(document).ready(function() {
	jQuery('.downloadsCont').hide();							
	jQuery('.downloadSlid').click(function() {
		jQuery('.downloadsCont').slideUp('slow');
		jQuery(this).next('.downloadsCont').slideDown('slow');
		jQuery(this).parents('.inBotTwoColCont').css('height','');
	});
});


/* Product slide column equal height */
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = jQuery(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
jQuery(document).ready(function() {
	
	equalHeight(jQuery(".inBotTwoColCont"));
	
});

jQuery(document).ready(function() {
		jQuery('#advThumbCont li').click(function() {
		jQuery('#advThumbCont li').find('h5').css('color','#666');
		jQuery('#advThumbCont li').find('span').css('color','#666');
		jQuery('#advThumbCont li').find('.thumbs img').css('border','1px solid #ccc');
		jQuery(this).find('h5').css('color','#990000');
		jQuery(this).find('span').css('color','#990000');
		jQuery(this).find('.thumbs img').css('border','1px solid #990000');
	})
	jQuery('#boardThumbCont li').click(function() {
		jQuery('#boardThumbCont li').find('h5').css('color','#666');
		jQuery('#boardThumbCont li').find('span').css('color','#666');
		jQuery('#boardThumbCont li').find('.thumbs img').css('border','1px solid #ccc');
		jQuery(this).find('h5').css('color','#990000');
		jQuery(this).find('span').css('color','#990000');
		jQuery(this).find('.thumbs img').css('border','1px solid #990000');
	})
	jQuery('#imgThumbCont').jCarouselLite({
        btnNext: ".advNext",
        btnPrev: ".advPrev",
		visible: 3,
		speed: 600,
	    circular: true
		
    	});
	jQuery(".searchToggle").click(function () {
        jQuery('.advSearch').slideToggle('slow', function(){
               jQuery(".searchToggle").find('a').toggleClass('On');
				jQuery(".searchToggle").find('a').text(jQuery(".searchToggle").find('a').text() == 'Advanced Search' ? 'Basic Search' : 'Advanced Search');
        });
		
   });
});



function jsScroller (o, w, h) {
	var self = this;
	var list = o.getElementsByTagName("div");
	for (var i = 0; i < list.length; i++) {
		if (list[i].className.indexOf("Scroller-Container") > -1) {
			o = list[i];
		}
	}
	
	//Private methods
	this._setPos = function (x, y) {
		if (x < this.viewableWidth - this.totalWidth) 
			x = this.viewableWidth - this.totalWidth;
		if (x > 0) x = 0;
		if (y < this.viewableHeight - this.totalHeight) 
			y = this.viewableHeight - this.totalHeight;
		if (y > 0) y = 0;
		this._x = x;
		this._y = y;
		with (o.style) {
			left = this._x +"px";
			top  = this._y +"px";
		}
	};
	
	//Public Methods
	this.reset = function () {
		this.content = o;
		this.totalHeight = o.offsetHeight;
		this.totalWidth	 = o.offsetWidth;
		this._x = 0;
		this._y = 0;
		with (o.style) {
			left = "0px";
			top  = "0px";
		}
	};
	this.scrollBy = function (x, y) {
		this._setPos(this._x + x, this._y + y);
	};
	this.scrollTo = function (x, y) {
		this._setPos(-x, -y);
	};
	this.stopScroll = function () {
		if (this.scrollTimer) window.clearInterval(this.scrollTimer);
	};
	this.startScroll = function (x, y) {
		this.stopScroll();
		this.scrollTimer = window.setInterval(
			function(){ self.scrollBy(x, y); }, 40
		);
	};
	this.swapContent = function (c, w, h) {
		o = c;
		var list = o.getElementsByTagName("div");
		for (var i = 0; i < list.length; i++) {
			if (list[i].className.indexOf("Scroller-Container") > -1) {
				o = list[i];
			}
		}
		if (w) this.viewableWidth  = w;
		if (h) this.viewableHeight = h;
		this.reset();
	};
	
	//variables
	this.content = o;
	this.viewableWidth  = w;
	this.viewableHeight = h;
	this.totalWidth	 = o.offsetWidth;
	this.totalHeight = o.offsetHeight;
	this.scrollTimer = null;
	this.reset();
};

jQuery(document).ready(function() {
jQuery('.map span,.map img').click(
  function () {
   jQuery('.mapLoc').slideToggle()
  });

});