/* popup window */

var forcedRefresh = true;
var alreadyopen = new Array();
var newwin = new Array();

function openCenteredWindow(theURL, winName, features, w, h){
  var winl = parseInt((screen.width - w - 10) / 2);
  var wint = parseInt((screen.height - h - 29) / 2);
  var retval = openWindow(theURL, winName, features + ',height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl);
  if(!theURL) return retval;
}

function openWindow(theURL, winName, features){
  if(forcedRefresh == false && alreadyopen[winName] && !newwin[winName].closed){
    newwin[winName].focus();
  }
  else{
    alreadyopen[winName] = 1;	 
    newwin[winName] = window.open(theURL, winName, features);
    newwin[winName].focus();
  }
  if(!theURL) return newwin[winName];
}

function chatImageRollover(currentImage){ 
    currentImage= new Image(); 
    currentImage.src= eval(currentImage.src);
    alert(currentImage.src);
  }
function openWindowMenu(selObj){ 
  if (selObj.value != ""){
    eval(window.open(selObj.value, "_blank"));
  }
}
function underlineme(selObj){
        selObj.style.className = 'underlinethis'
}
/* show hide drop down menus */

var old_menu = null, hide = null;
function hide_menu(id){
	if(id == null) return;
	obj = document.getElementById('dropnav-' + id);
	if(obj) obj.style.visibility = 'hidden';
	clear_timeout();
}

function show_menu(id){
	if(old_menu) hide_menu(old_menu);
	obj = document.getElementById('dropnav-' + id);
	if(obj){
		obj.style.visibility = 'visible';
			obj.className = 'menu_navigation';
	}
	old_menu = id;
	clear_timeout();
}

function set_timeout(){
	hide = setTimeout("hide_menu('" + old_menu + "')",700);
}

function clear_timeout(){
	clearTimeout(hide);
}

/* flash resize */

function setFlashWidth(movieId, newW){
	document.getElementById(movieId).style.width = newW+"px";
}

function setFlashHeight(movieId, newH){
	document.getElementById(movieId).style.height = newH+"px";		
}

function setFlashSize(movieId, newW, newH){
	setFlashWidth(movieId, newW);
	setFlashHeight(movieId, newH);
}


function jumpMenu(selObj){
  if (selObj.value != ""){
	if(selObj.value.indexOf("online") != -1)
	{
	    window.open(selObj.value);
	}
	else
	{
	    location.href= selObj.value;
	}
  }
}

function jumpMenuPopup(selObj, winName, features, w, h){
  if (selObj.value != ""){
    openCenteredWindow(selObj.value, winName, features, w, h);
  }
}

function openTipSheet(url) {
	openCenteredWindow(url,'tipsheet','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no','409','550');
}
function openTestimonialMoviePopup(url) {
	openCenteredWindow(url,'Testimonials','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no','410','305');
}

function setClassname(id, classname){ document.getElementById(id).className = classname; }
function getClassname(id){ return document.getElementById(id).className; }
function replaceClassname(id, find, replace){ setClassname(id, getClassname(id).replace(new RegExp(find), replace)); }

/* show hide content */

var currentTab = null;

function openTab(newTab) {
	if(currentTab != null) {
		showTab('tab' + currentTab);
		hideTab('tab' + currentTab + 'content');	
	}
	
	hideTab('tab' + newTab);
	showTab('tab' + newTab + 'content');
	
	currentTab = newTab;
}

function closeTab(tab) {
	showTab('tab' + tab);
	hideTab('tab' + tab + 'content');
}

function showTab(tab) {
	setClassname(tab, 'feature_box');
}

function hideTab(tab) {
	setClassname(tab, 'invisible');
}

function showHideElement(elementId){
	var el = document.getElementById(elementId);
	var el_arrow = document.getElementById(elementId + "_arrow");
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
		el_arrow.src = "/img/arrow_green_right.gif";
	}
	else 
	{
		el.style.display = '';
		el_arrow.src = "/img/arrow_green_down.gif";
	}
}

/* show/hide form dropdowns */

function hideSelects(action) {
  version = 0;

  if (navigator.appVersion.indexOf("MSIE") != -1) {
    temp = navigator.appVersion.split("MSIE");
    version = parseFloat(temp[1]);
  }
	
  if (version == 6.0) {
    for (var S = 0; S < document.forms.length; S++) {
      for (var R = 0; R < document.forms[S].length; R++) {
        if (document.forms[S].elements[R].options) {
          document.forms[S].elements[R].style.visibility = action;
        }
      }
    }	
  }
}


function firemodalInqDaemon(modalname){
    try
    {
        $find(modalname).show();
        document.cookie = "daemonpopup=false;path=/";
        return false;
    }
    catch(e)
    {
        
    }
} 

function ExpandItem(divID, imgID)
{
    var textArea = document.getElementById(divID);
    var imgArrow = document.getElementById(imgID);
    if(textArea.style.display == 'block')
    {
        textArea.style.display = 'none';
        imgArrow.src = '/Images/AbandonPopup/arrow.gif';
    }
    else
    { 
        textArea.style.display = 'block';
        imgArrow.src = '/Images/AbandonPopup/arrowup.gif';
        
    }
}
