

$().ready(function() {
	imageresize();
	alignSliderAtCenterOfPage();
	//$(window).resize(function() {
	//	alignSliderAtCenterOfPage(); 
	//});
});

function alignSliderAtCenterOfPage(){
	$(".slideImgwrapper").css("margin-left", (($(window).width() - $(".slideImgwrapper").outerWidth()) / 2) + $(window).scrollLeft()-160 + "px");
}

function showMoreContent(id){
	document.getElementById("showContent_"+id).style.display="block";
	document.getElementById("showContent_"+id).style.visibility="visible";
	document.getElementById("hideContent_"+id).style.display="none";
	document.getElementById("hideContent_"+id).style.visibility="hidden";
}

function hideMoreContent(id){
	document.getElementById("hideContent_"+id).style.display="block";
	document.getElementById("hideContent_"+id).style.visibility="visible";
	document.getElementById("showContent_"+id).style.display="none";
	document.getElementById("showContent_"+id).style.visibility="hidden";
}

$('#showMore').click(function() {
  $('#desc').animate({
    	display:'block',
		visibility:'visible'
  }, 5000, function() {
  });
});


function slideSwitch() {

    var $active = $('#slideshow DIV.active');
	if ( $active.length == 0 ) $active = $('#slideshow DIV:last');
	var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

      $active.addClass('slideDiv last-active');
    $('.slideDiv').css('display', 'none');
    $next.css({opacity: 0.0})
        .addClass('slideDiv active')
		.addClass('active').css('display', 'block')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');

        });
}

$(function() {
	 $('.slideDiv').css('display', 'none');
	 if($.browser.msie) {
		setInterval( "slideSwitch()", 6500);
	 }
	 else {
		setInterval( "slideSwitch()", 6000);
	 }
    
});

jQuery('body').ready(function() {
            if (jQuery('#cycleimages').length > 0) {
                jQuery('#cycleimages').cycle({ 
                    fx: 'scrollHorz',
                    speed: 750,
                    timeout: 12000, 
						randomizeEffects: false, 
						easing: 'easeOutCubic',
						next:   '.cyclenext', 
						prev:   '.cycleprev',
						 pager:  '#cyclewrapnav',
						cleartypeNoBg: true,
						width:'100%',
				 });
            }

});




function getWindowViewPortheight(){
 var viewportwidth;
 var viewportheight;
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
if(viewportwidth/viewportheight>1){
	 var bannerDiv = document.getElementById('outerDiv');

	 var bannerHeight = new Number(viewportheight) - new Number(205);
	 bannerDiv.style.height = bannerHeight + 'px';
	 bannerDiv.style.position = 'relative';
	 bannerDiv.style.overflow = 'visible';

	  /*var backgroundPublisherDiv = document.getElementById('background-publisher');
	  var mainSlideNavDiv = document.getElementById('main-slide-nav');
	  if(backgroundPublisherDiv != null && backgroundPublisherDiv != '' && backgroundPublisherDiv!= undefined && mainSlideNavDiv != null && mainSlideNavDiv != '' && mainSlideNavDiv!= undefined){
		 mainSlideNavDiv.style.top = backgroundPublisherDiv.offsetTop - 100;
	  }*/
}

}



 function imageresize() {
	 var contentheight = $(window).height();
	 var imageHeight = '';
	 var iwidth = ''
     var ah = getMidSectionHeight();
	 if(ah <= 420){
		$('#slideImage1').attr('src','/images/personalized-learning-3.png');
		$('#slideImage2').attr('src','/images/adaptive-learning-videos-3.png');
		$('#slideImage3').attr('src','/images/learning-on-the-go-3.png');
		/*$('#slideImage4').attr('src','/images/vertslider2_sm.png');
		$('#slideImage5').attr('src','/images/vertslider3_sm.png');*/
	     imageHeight = 420;
	 }
	 else if(ah > 420 && ah<= 550){
		 $('#slideImage1').attr('src','/images/personalized-learning-2.png');
		 $('#slideImage2').attr('src','/images/adaptive-learning-videos-2.png');
		 $('#slideImage3').attr('src','/images/learning-on-the-go-2.png');
	     /*$('#slideImage4').attr('src','/images/vertslider2_mid.png');
	     $('#slideImage5').attr('src','/images/vertslider3_mid.png');*/
	     imageHeight = 550;
	 }
	 else if(ah > 550) {
		 $('#slideImage1').attr('src','/images/personalized-learning-1.png');
		 $('#slideImage2').attr('src','/images/adaptive-learning-videos-1.png');
		$('#slideImage3').attr('src','/images/learning-on-the-go-1.png');
	    /*$('#slideImage4').attr('src','/images/home_carousel02.png');
	    $('#slideImage5').attr('src','/images/home_carousel03.png');*/
        imageHeight = 669;
		
	 }
	
	 if(imageHeight > ah){
		$('.slideImgwrapper').css('height',ah);
		 var imgWidth = (974 * ah)/imageHeight;
		 $('.slideImgwrapper').css('width',imgWidth);
         $('img.slideImg').imgscale({
			parent : '.slideImgwrapper',
			center : true,
			scale:'fit'
		  });
	}
	else {
		$('.slideImgwrapper').css('height',imageHeight);
		$('.slideImgwrapper').css('width','974px');
		alignSliderContentAtVerticallyCenter(imageHeight);
	}
 }



function alignSliderContentAtVerticallyCenter(imageHeight){
	var logSectionHeight = 80;
	var headerDivSection = document.getElementById("outer-div"); 
	var footerDivSection = document.getElementById("footer");
	var cyclewrapDivSection = document.getElementById("cyclewrap");
	var slideImgObj = document.getElementById("cycleimages");
	var contentheight = $(window).height();
	var headerSectionHt = '';
	var footerDivSectionHt = '';
	var cyclewrapDivSectionHt = '';
	if(headerDivSection != undefined && headerDivSection!= null && headerDivSection!= ''){
		headerSectionHt = headerDivSection.clientHeight;
	}
	if(footerDivSection != undefined && footerDivSection!= null && footerDivSection!= ''){
		footerDivSectionHt = footerDivSection.clientHeight;
	}
	if(cyclewrapDivSection != undefined && cyclewrapDivSection!= null && cyclewrapDivSection!= ''){
		cyclewrapDivSectionHt = cyclewrapDivSection.clientHeight;
	}
	var midSectionht = contentheight - (headerSectionHt + footerDivSectionHt);
	var remaingHt = midSectionht - imageHeight;
	slideImgObj.style.marginTop = (remaingHt/2) + 'px';
}

function getMidSectionHeight(){
	
	var headerDivSection = document.getElementById("outer-div"); 
	var footerDivSection = document.getElementById("footer");
	var cyclewrapDivSection = document.getElementById("cyclewrap");
	var slideImgObj = document.getElementById("cycleimages");
	var contentheight = $(window).height();
	var headerSectionHt = '';
	var footerDivSectionHt = '';
	var cyclewrapDivSectionHt = '';
	if(headerDivSection != undefined && headerDivSection!= null && headerDivSection!= ''){
		headerSectionHt = headerDivSection.clientHeight;
	}
	if(footerDivSection != undefined && footerDivSection!= null && footerDivSection!= ''){
		footerDivSectionHt = footerDivSection.clientHeight;
	}
	if(cyclewrapDivSection != undefined && cyclewrapDivSection!= null && cyclewrapDivSection!= ''){
		cyclewrapDivSectionHt = cyclewrapDivSection.clientHeight;
	}
	
	var midSectionht = contentheight - (headerSectionHt + footerDivSectionHt);
	return midSectionht;
}
