// JavaScript Document
//Global Variables
var timer,timer2,timerVal = 5000,timerVal2 = 8000, prevMouseobjId,careerOnLoadHt=0;
var clickObj;
/* 
 This is for toggling effect function Here we required 2 arguments 
 1. obj   :current click object
 2. divId :expand/collpase Div Id
 ex:onclick="siteMapExplore($(this),'siteMapSec')"
*/
function siteMapExplore(obj,divId) {
var $img = obj.find('img');
var imgSrc = $img.attr('src');

var imgPath = imgSrc.substr(0,imgSrc.lastIndexOf('/'));
if($img.attr('alt') == 'downArr'){

 $img.attr({'alt':"upArr",'src': imgPath+'/greyUpArrow.png'})
 $('.'+divId).slideUp('slow');          
 $('html, body').animate({scrollTop:85}, 500);
}else {
  $img.attr({'alt': "downArr",'src':imgPath+'/greyDownArrow.png'})
 $('.'+divId).slideDown('fast');    
 $('html, body').animate({scrollTop:$('#footernav').offset().top}, 500);
 }
}  

//for corp overview

function corpOverview(obj,divId) {
var $img = obj.find('img');
var imgSrc = $img.attr('src');

var imgPath = imgSrc.substr(0,imgSrc.lastIndexOf('/'));

if($img.attr('alt') == 'downArr'){	
 $img.attr({'alt':"upArr",'src': imgPath+'/sectionCollapse.png'})
 obj.attr("title",'click to expand')
 $('.'+divId).slideUp('slow');          
 //$('html, body').animate({scrollTop:85}, 500);
}else {
obj.attr("title",'click to close')
  $img.attr({'alt': "downArr",'src':imgPath+'/sectionExpand.png'})
 $('.'+divId).slideDown('fast');    
 //$('html, body').animate({scrollTop:$('#sectionContent').offset().top}, 500);
 }
}  

//All news related functions
/* 
This is for showing the next List by clicking on next arrow & it's a Cyclic show 
Here we required 2 arguments 
 1. objId       : main block id (section div Id) 
 2. findClass   : List Class inside of main block
ex:onclick="showNextBlock('newsEventSct','List');"
                
*/
function showNextBlock(objId, findClass) {
 var currvis = $('#'+objId).find('.'+findClass+':visible');
 if(currvis.next('.'+findClass).html()) {
 currvis.css('display','none');
  currvis.next('.'+findClass).fadeIn(100);  
 }else {
  currvis.css('display','none');
  $('#'+objId).find('.'+findClass+':eq(0)').fadeIn(100);
 }
}
/* 
This is for showing the previous List by clicking on next arrow & it's a Cyclic show 
 Here we required 2 arguments 
 1. objId       : main block id (section div Id) 
2. findClass   : List Class inside of main block
ex:onclick="showPrevBlock('newsEventSct','List');"
*/
function showPrevBlock(objId, findClass) {
  var currvis = $('#'+objId).find('.'+findClass+':visible');
  if(currvis.prev('.'+findClass).html()) {
  //currvis.fadeOut(0);
  currvis.css('display','none');
  currvis.prev('.'+findClass).fadeIn(100);  
  }else {
  currvis.css('display','none');
  $('#'+objId).find('.'+findClass+':last').fadeIn(100);
  }
}

/* this is for moving continous blocks for news section and Testimonial section Starts here */
function movingcontinous(objId,findClass,str) {
  var currvis = $('#'+objId).find('.'+findClass+':visible');
  if(currvis.next('.'+findClass).html()) {
      currvis.css('display','none').delay(5000).next('.'+findClass).fadeIn(100); 
  }else {
       currvis.css('display','none');
       $('#'+objId).find('.'+findClass+':eq(0)').fadeIn(100);        
        }
       moveBlock(str);
 //movingcontinous('testimonalSct','List');
}

function movingcontinous1(){
   movingcontinous('testimonalSct','List','first')
}
                
function movingcontinous2(){
	movingcontinous('newsEventSct','List','second')
}   

function moveBlock(string) {
	if(string == 'first') {
	clearTimeout(timer);
	timer = setTimeout(eval("movingcontinous1"), timerVal);
	}else {
	   clearTimeout(timer2);
	  timer2 = setTimeout(eval("movingcontinous2"), timerVal2);
	 }
}
/* Ends Here  */
// end of News related 
/* 
This is for showing the Relevant content for sub menu   
Here we required 3 arguments 
1. mainId       : main block id (section div Id) 
2. showId       : which block should be show that ID
3. currObj      : it's a tag object
ex:onmouseover="showConent('aboutBlk','companyview',$(this));"
*/           
function showContent(mainId,showId,currObj) {
                var ulObj = currObj.parents('ul');
                ulObj.find('a.active').removeClass('active');
                                currObj.addClass('active')
                $('#'+mainId+' .subMenuarticle').addClass('hide');
                $('#'+showId).removeClass('hide');
}
/* 
                This is for showing the Relevant content for Main menu */
function mainNavHoverFunc(objId) {
var obj,dummy;
if(!prevMouseobjId) {
    prevMouseobjId = objId;
    return false;
} 

if(prevMouseobjId == objId) {
    return false;
}
obj = $('#'+prevMouseobjId);
    obj.find('.subMenuarticle:eq(0)').removeClass('hide');
    obj.find('.subMenuarticle:gt(0)').addClass('hide');            
    obj.find('a.active').removeClass('active');
if(prevMouseobjId != objId) {
    prevMouseobjId = objId;
}
} 
/*Expan and collapse section*/
var speed = 350;
/*var collaspeCls = '.article h3[class="sectionHeaderCollaspe"]';
var expandCls = '.article h3[class="sectionHeaderExpand"]';*/
var secContentPanel = '.sectionContent';

$(document).ready(function() {
	//$('.article').find('.sectionHeaderExpand').next(secContentPanel).slideDown(10);
	$('.article').find('.sectionHeaderExpand').each(function(i) {
			if(i != 0){
				$(this).removeClass('sectionHeaderExpand').addClass('sectionHeaderCollaspe');												 	
				$(this).next(secContentPanel).css('display','none');												   
			}
			});
  $('.article h3').click(function(){
	var grhHT = $('.column').height();
	var initalHt = grhHT;
	var sectionVisible = $(secContentPanel+':visible').height();
//alert(sectionVisible)
	grhHT -= sectionVisible;
	
		if($(this).hasClass('sectionHeaderExpand')){
		/*	if($(this).prev().html()){
				$(this).removeClass('sectionHeaderExpand').addClass('sectionHeaderCollaspe');
				$(this).next(secContentPanel).slideUp(10);
				var $first =  $('.article h3:eq(0)');
				$first.removeClass('sectionHeaderCollaspe').addClass('sectionHeaderExpand');
				$first.next(secContentPanel).slideDown(10);
				$('.column').css('height',grhHT+$first.outerHeight()-9);
			}*/
			//var current = $first.next(secContentPanel);
		}
		else{
				$('.article').find('.sectionHeaderExpand').each(function(i) {
		
				$(this).removeClass('sectionHeaderExpand').addClass('sectionHeaderCollaspe');												 	
				$(this).next(secContentPanel).css('display','none');												   
																		 });
			$(this).removeClass('sectionHeaderCollaspe').addClass('sectionHeaderExpand');
			$(this).next(secContentPanel).slideDown(300);
			var current = $(this).next(secContentPanel);
			setTimeout(function() {
			$('.column').css('height', grhHT+current.height() )
								},20);
		} 
		
	});
	
	
	/*$('a[name="expandAll"]').click(function(){
		$(collaspeCls).removeClass('sectionHeaderCollaspe').addClass('sectionHeaderExpand');
		$(secContentPanel).slideDown(speed);
	});
	
	
	$('a[name="collaspeAll"]').click(function(){
		$(expandCls).removeClass('sectionHeaderExpand').addClass('sectionHeaderCollaspe');
		$(secContentPanel).slideUp(speed);
	});*/
	/*Fix for showing submenus in IE 6 Browser*/
	$('#nav ul:first li').hover(function() {
										 
		$(this).find('.subMenu').css('display','block');
			},function() {
				 $(this).find('.subMenu').css('display','none');		 
	});
	/*Fix for removal of dotted line on hover(outline) for < IE8 browsers*/
	$('a').bind('mousedown click focus',function() {
			this.blur();
	});
});

function equalHeight(group) {
   tallest = 0;
   group.each(function() {
      thisHeight = $(this).height();
	  //alert(thisHeight)
      if(thisHeight > tallest) {
         tallest = thisHeight;
      }
   });
   
   group.height(tallest);
  
  
}
$(document).ready(function() {
   equalHeight($(".column"));
});

function selfpageNav(index) {
var indexNo = index;

//if(indexNo){

	var grhHT = $('.column').height();
	var initalHt = grhHT;
	var sectionVisible = $(secContentPanel+':visible').height();
	$('.article').find('.sectionHeaderExpand').each(function(i) {
		
				$(this).removeClass('sectionHeaderExpand').addClass('sectionHeaderCollaspe');																																																													                $(this).next(secContentPanel).css('display','none');												   
	}
	);

		var $curr = $(".article:eq("+indexNo+") h3");
			$curr.removeClass('sectionHeaderCollaspe').addClass('sectionHeaderExpand');
			$curr.next(secContentPanel).css('display','block');
			var current = $curr.next(secContentPanel);
			$('.column').css('height', grhHT+current.height() )
			
//}

}
/* Applies to Insurance page*/

function showhide_insurance(theID) {
//alert(theID)
var idarray = new Array("defaultshow","ins1","ins2","ins3","ins4","ins5","ins6","ins7");
  for(var i=0; i < idarray.length; i++) {
    if (idarray[i] == theID) {if (document.getElementById(idarray[i]).style.display == "block") { document.getElementById(idarray[i]).style.display = "block" } else { document.getElementById(idarray[i]).style.display = "block" }
  } else {
    document.getElementById(idarray[i]).style.display = "none";
	}
  } // end for
 //alert(theID) 

if (theID == "defaultshow"){
 document.getElementById('keyachivement-title').style.display ="none";
 
 }
 else{
document.getElementById('keyachivement-title').style.display ="block";	

 }
makeequalheight();
}



function makeequalheight(idname){
	var displayObj = $('.innerContentSec:visible')
	var newHT = displayObj.outerHeight(true)+$('.breadCrumbs').outerHeight(true)+30;
	var tempHT =0;
	$(".infoSec div").each(function() {
		tempHT += $(this).outerHeight(true);						
	});
	
	newHT = (tempHT > newHT )?tempHT+40:newHT
	
	$('.column').css('height',newHT);
}


/* Applies to unified communiations page */

function showhide_communications(theID) {
//alert(theID)
var idarray = new Array("defaultshow","c1","c2");
  for(var i=0; i < idarray.length; i++) {
    if (idarray[i] == theID) {if (document.getElementById(idarray[i]).style.display == "block") { document.getElementById(idarray[i]).style.display = "block" } else { document.getElementById(idarray[i]).style.display = "block" }
  } else {
    document.getElementById(idarray[i]).style.display = "none";
	}
  } // end for
 //alert(theID) 
 makeequalheight();
}

function displayVals(obj) {
	/*$('.categorySection').css('display','none');*/
	$('.article').find('.sectionHeaderExpand').each(function(i) {
		$(this).removeClass('sectionHeaderExpand').addClass('sectionHeaderCollaspe');												 	
		$(this).next(secContentPanel).css('display','none');												   
	});
	var selectVal = $(obj).val();
	var currDiv = $(".categorySection[rel="+selectVal+"]");
	currDiv.css('display','block');
	$('.column').height(careerOnLoadHt +currDiv.outerHeight(true) )
}

function careersOnLoad() {
	$('.article').find('.sectionHeaderExpand').each(function(i) {
			
				$(this).removeClass('sectionHeaderExpand').addClass('sectionHeaderCollaspe');												 	
				$(this).next(secContentPanel).css('display','none');												   
															 });
	/*$('.categorySection').css('display','none');	*/
	careerOnLoadHt = $('.innerContentSec').outerHeight(true)+$('.breadCrumbs').outerHeight(true);
	$('.column').height($('.innerContentSec').outerHeight(true)+$('.breadCrumbs').outerHeight(true))

}


