/*Copyright Bridgeline Software, Inc. An unpublished work created in 2007. All rights reserved. 
This software contains the confidential and trade secret information of Bridgeline Software, Inc. 
("Bridgeline").  Copying, distribution or disclosure without Bridgeline's express written permission is prohibited.*/

// Find Browser Dimention
// Copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
function pageWidth(){
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 
   
function pageHeight(){
	return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
} 

function posLeft(){
	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
} 

function posTop(){
    return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
} 

function posRight(){
    return posLeft()+pageWidth();
}

function posBottom(){
    return posTop()+pageHeight();
}

//Scroll Height and Width
function getPageHeightWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
	}else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
	}else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight + document.body.offsetTop;
  	}
	return yWithScroll;
}

function getPageWidthWithScroll(){
	if (window.innerWidth && window.scrollMaxX) {// Firefox
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		xWithScroll = document.body.offsetWidth + document.body.offsetLeft;
  	}
	return xWithScroll;
}

//Modal Window
function showModal(pageUrl) {
	var custompagesFolder="";
	
	// for IE
	var browser=navigator.appName;
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
    
	var tempIframe = document.createElement('iframe');
	tempIframe.width="1";
	tempIframe.height="1";
	tempIframe.id = "modal";
	tempIframe.name = "modal";
	tempIframe.frameBorder = "0";
	tempIframe.scrolling="no";
	tempIframe.style.overflow = "hidden";
	tempIframe.allowTransparency=true;
	document.body.appendChild(tempIframe);
	tempIframe.src = custompagesFolder+ pageUrl;
	
	return false;
}

function CenterModal(width,height){
	var elementId = "modal";
	var visibleHeight = pageHeight();
	var visibleWidth = pageWidth();
	element = document.getElementById(elementId);
	element.width = width;
	element.height = height;
	if(element.height > visibleHeight){
		element.style.top = "20px";
	}else{
		element.style.top = (visibleHeight-element.height)/2 + "px";
	}
	element.style.left = (visibleWidth-element.width)/2 + "px";
	
	var totalHeight = getPageHeightWithScroll();
	var totalWidth = getPageWidthWithScroll();
	var tempCoverDiv = document.createElement('div');
	tempCoverDiv.id = "coverLayer";
	tempCoverDiv.style.height=totalHeight+"px";
	tempCoverDiv.style.width=totalWidth+"px";
	document.body.appendChild(tempCoverDiv);
}

function closeModalWindow() {
	var tempIframe = document.getElementById('modal');
	var tempCoverDiv = document.getElementById('coverLayer');
	if(tempIframe) tempIframe.parentNode.removeChild(tempIframe);
	if(tempCoverDiv) tempCoverDiv.parentNode.removeChild(tempCoverDiv);
}

// Clear Text Field
function clearTextField(ElemID){
	var tempElem = document.getElementById(ElemID);
	if (tempElem){
		tempElem.value="";
	}
}

function checkSearchField(ElemID){
  var tempElem = document.getElementById(ElemID);
  if(tempElem && tempElem.value==""){
    tempElem.value="Search"    
    }
}

//Footer Add outbreak
function showdiv()
{
    document.getElementById("showObc").style.display = 'block';
}
function hideDiv()
{
    document.getElementById("showObc").style.display = 'none';
}

/*Rotator Script*/
function theRotator() {
	//Set the opacity of all images to 0
	$('#imageRotator ul li').css({opacity: 0.0});
	$('#textRotation ul li').css({opacity: 0.0});
	//Get the first image and display it (gets set to full opacity)
	$('#imageRotator ul li:first').css({opacity: 1.0});
	$('#textRotation ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',6000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('#imageRotator ul li.show')?  $('#imageRotator ul li.show') : $('#imageRotator ul li:first'));
	var textCurrent = ($('#textRotation ul li.show')?  $('#textRotation ul li.show') : $('#textRotation ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#imageRotator ul li:first') :current.next()) : $('#imageRotator ul li:first'));	
	var textNext = ((textCurrent.next().length) ? ((textCurrent.next().hasClass('show')) ? $('#textRotation ul li:first') :textCurrent.next()) : $('#textRotation ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
    
    textNext.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	textCurrent.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

$(document).ready(function() {		
	//Load the slideshow
	theRotator();
	
	//Clear Field
      $("#txtQuestion").bind('focus', function(e) 
            {         
               $(this).attr("value", "");
            });
           $("#txtEmail").bind("focus", function(e) 
            {            
               $(this).attr("value", "");
            });
	
	//Left Navigation
	$('ul.hasSub').hide();
     $('span.expand').click
        ( function()
            {
            var test = document.getElementById("checkExpandCondition").value;
          //  alert(test);
            
               var findNextUlEle = $(this).parent("li").children("ul").attr("class");
               $(this).toggleClass('expand1');
               $(this).parent("li").children("ul").slideToggle(300);
               return false;
            }
        );        
});

// Edit Mode Miscellaneous Functions
$(function(){
    if(document.getElementById('jsInclude')){
       $("div.home div.videoBlock div.column1").css('margin-right', '0px'); 
       $("div.contentRow2 div.column3").css('padding-left','10px');           
    }
});

// For search Enter button control.
function controlEnterButton (btnId, evt) 
{   
    btn = document.getElementById(btnId);
    if (btn)
    {
        if (evt.keyCode == 13)
        {
            evt.returnValue = false;
            evt.cancel = true;
            btn.click();
        } 
    } 
}



   

