/*
=========================================================
=========================================================
Javascript Document 
Powered by Dynamic Site Design - ken@dynamicsitedesign.com
=========================================================
=========================================================*/

function showDiv(id) {
	document.getElementById(id).style.visibility='visible';
	document.getElementById(id).style.display='block';
}
function hideDiv(id) {
	document.getElementById(id).style.visibility='hidden';
	document.getElementById(id).style.display='none';
}
function toggleDiv(id) {
	if (document.getElementById(id).style.visibility !='visible'){
	document.getElementById(id).style.visibility='visible';
	document.getElementById(id).style.display='block';
	}
	else {
	document.getElementById(id).style.visibility='hidden';
	document.getElementById(id).style.display='none';
	}
}

function expandNotification() {
	document.getElementById('NotificationList').style.height="auto"
	hideDiv('plus');showDiv('minus');
}

function collapseNotification() {
	document.getElementById('NotificationList').style.height="75px"
	hideDiv('minus');showDiv('plus');
}

function expandHistory() {
	document.getElementById('historyList').style.height="auto"
	hideDiv('plus2');showDiv('minus2');
}

function collapseHistory() {
	document.getElementById('historyList').style.height="75px"
	hideDiv('minus2');showDiv('plus2');
}

function expandBookmarks() {
	document.getElementById('bookmarkList').style.height="auto"
	hideDiv('plus3');showDiv('minus3');
}

function collapseBookmarks() {
	document.getElementById('bookmarkList').style.height="75px"
	hideDiv('minus3');showDiv('plus3');
}

function expandSearch() {
var _search = document.getElementById('advSearch');
var expandSearchIMG = document.getElementById('advSearchExpand');
var colapseSearchIMG = document.getElementById('advSearchColapse');

	_search.style.visibility='visible';
	_search.style.display='block';
	colapseSearchIMG.style.visibility='visible';
	colapseSearchIMG.style.display='block';
	expandSearchIMG.style.visibility='hidden';
	expandSearchIMG.style.display='none';

}
function colapseSearch() {
var _search = document.getElementById('advSearch');
var expandSearchIMG = document.getElementById('advSearchExpand');
var colapseSearchIMG = document.getElementById('advSearchColapse');

	_search.style.visibility='hidden';
	_search.style.display='none';
	colapseSearchIMG.style.visibility='hidden';
	colapseSearchIMG.style.display='none';
	expandSearchIMG.style.visibility='visible';
	expandSearchIMG.style.display='block';

}

function expandProjectSearch() {
var _projectSearch = document.getElementById('advProjectSearch');
var expandSearchIMG2 = document.getElementById('advProjectSearchExpand');
var colapseSearchIMG2 = document.getElementById('advProjectSearchColapse');

	_projectSearch.style.visibility='visible';
	_projectSearch.style.display='block';
	colapseSearchIMG2.style.visibility='visible';
	colapseSearchIMG2.style.display='block';
	expandSearchIMG2.style.visibility='hidden';
	expandSearchIMG2.style.display='none';

}
function colapseProjectSearch() {
var _projectSearch = document.getElementById('advProjectSearch');
var expandSearchIMG2 = document.getElementById('advProjectSearchExpand');
var colapseSearchIMG2 = document.getElementById('advProjectSearchColapse');

	_projectSearch.style.visibility='hidden';
	_projectSearch.style.display='none';
	colapseSearchIMG2.style.visibility='hidden';
	colapseSearchIMG2.style.display='none';
	expandSearchIMG2.style.visibility='visible';
	expandSearchIMG2.style.display='block';

}

// Begin checkbox functions 
function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      	if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  	theForm[z].checked = theElement.checked;
	  	}
	}
}
// End checkbox functions 

//start function to change image rollovers//
if (document.images) {

	arw01 = new Image
	arw01_ro = new Image
	arw01.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/page_arrowL.png"
	arw01_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/page_arrowL_hover.png"
	
	arw02 = new Image
	arw02_ro = new Image
	arw02.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/page_arrowR.png"
	arw02_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/page_arrowR_hover.png"

	arw03 = new Image
	arw03_ro = new Image
	arw03.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/page_arrowL.png"
	arw03_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/page_arrowL_hover.png"
	
	arw04 = new Image
	arw04_ro = new Image
	arw04.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/page_arrowR.png"
	arw04_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/page_arrowR_hover.png"
	
	plus = new Image
	plus_ro = new Image
	plus.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/plus_v2.gif"
	plus_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/plus_v2_hover.gif"
	
	minus = new Image
	minus_ro = new Image
	minus.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/minus_v2.gif"
	minus_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/minus_v2_hover.gif"
	
	plus2 = new Image
	plus2_ro = new Image
	plus2.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/plus_v2.gif"
	plus2_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/plus_v2_hover.gif"
	
	minus2 = new Image
	minus2_ro = new Image
	minus2.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/minus_v2.gif"
	minus2_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/minus_v2_hover.gif"
	
	plus3 = new Image
	plus3_ro = new Image
	plus3.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/plus_v2.gif"
	plus3_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/plus_v2_hover.gif"
	
	minus3 = new Image
	minus3_ro = new Image
	minus3.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/minus_v2.gif"
	minus3_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/minus_v2_hover.gif"
	
	expand = new Image
	expand_ro = new Image
	expand.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/plus_v1.gif"
	expand_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/plus_v1_hover.gif"
	
	collapse = new Image
	collapse_ro = new Image
	collapse.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/minus_v1.gif"
	collapse_ro.src = "/ecs_project_collaboration/themes/sematree_ECS_v1/images/buttons/minus_v1_hover.gif"
	
	
}

function ImgSwap(imgName,newImg) {
	if (document.images) {
		document[imgName].src= eval(newImg + ".src")
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//end function to change image rollovers//
function checkReplyFields() {
	if (document.getElementById('message').value == "") {
		document.getElementById('serverMsg').style.display = "block";
		document.getElementById('errorMsg').style.display = "block";
		
		labels = document.getElementsByTagName('label')
		 for (i in labels) {
			if (document.getElementById('message').value == ""){
				if ( /message/.test(labels[i].htmlFor) ) {  // test if 'for' attribute value equals message
				labels[i].style.color= "crimson";
				}
			}
		}
		return false;
	}
	else {document.forms[0].submit();}
}

function checkFields() {
	if (document.getElementById('subject').value == "" || document.getElementById('message').value == "" ) {
		document.getElementById('serverMsg').style.display = "block";
		document.getElementById('errorMsg').style.display = "block";
		
		labels = document.getElementsByTagName('label')
		 for (i in labels) {
			if (document.getElementById('subject').value == ""){
				if ( /subject/.test(labels[i].htmlFor) ) { // test if 'for' attribute value equals subject
				labels[i].style.color= "crimson";
				}
			}
			else {
				if ( /subject/.test(labels[i].htmlFor) ) { // test if 'for' attribute value equals subject
				labels[i].style.color= "#669900";
				}
			}
			if (document.getElementById('message').value == ""){
				if ( /message/.test(labels[i].htmlFor) ) {  // test if 'for' attribute value equals message
				labels[i].style.color= "crimson";
				}
			}
			else {
				if ( /subject/.test(labels[i].htmlFor) ) { // test if 'for' attribute value equals subject
				labels[i].style.color= "#669900";
				}
			}
		}
		return false;
	}
	else {document.forms[0].submit();}
}

function checkSelect (count) {
	count = 0;
	for(x=0; x<document.forms['formList'].checkbox.length; x++){
		if(document.forms['formList'].checkbox[x].checked==true){
		count++
		}
	}
	
	if(count==0){
		// alert("You must choose at least 1");
		document.getElementById('serverMsg').style.display = "block";
		document.getElementById('alertMsg').style.display = "block";
		if (document.getElementById('bubbleDiv')) { hideBubble('bubbleDiv'); }
	}
	// else if(count>3){
	//	alert("You can only choose upto 3");
	//}
	else {
		// alert("ok")
		document.getElementById('serverMsg').style.display = "none";
	}
}

function checkSelectReply (count) {
	count = 0;
	for(x=0; x<document.forms['formList'].checkbox.length; x++){
		if(document.forms['formList'].checkbox[x].checked==true){
		count++
		}
	}
	
	if(count==0){
		// alert("You must choose at least 1");
		document.getElementById('serverMsg').style.display = "block";
		document.getElementById('alertMsg').style.display = "block";
		if (document.getElementById('bubbleDiv')) { hideBubble('bubbleDiv'); }
	}
	else if(count>1){
		alert("You can only reply to 1 record at a time.");
	}
	else {
		// alert("ok")
		document.getElementById('serverMsg').style.display = "none";
		document.location = "../experts/experts-view-post-reply.html";
	}
}

function setNav(id) {
temp=document.getElementById("context_navigation");
  for(var i=1; i<=temp.getElementsByTagName("li").length; i++) {

	document.getElementById("nav" + i).className='';
	}
	document.getElementById(id).className='selected_nav';


}
function setTab(id) {
temp=document.getElementById("module_navigation");
  for(var i=1; i<=temp.getElementsByTagName("li").length; i++) {

	document.getElementById("tab" + i).className='';
	}
	document.getElementById(id).className='selected_tab';


}
function CSRemoveIEbox(){
if (document.images&&navigator.userAgent.indexOf("MSIE")!=-1){
	for(i=0;i<document.links.length;i++){
		target=eval("document.links[i]")
		target.onfocus=blurHandler
		}
	}
}

function blurHandler(){
obj=window.event.srcElement
if(obj.tagName == "A"||obj.tagName=="AREA") obj.blur()
}

// Begin Common Functions
function getMarkerLeft(selObj) {
	var controller = this.document.getElementById(selObj);
    var iLeft = 0;
	while(controller.tagName != "BODY") {
        iLeft += controller.offsetLeft;
        controller = controller.offsetParent; 
    }
	return iLeft;
};
function getMarkerTop(selObj) {
	var controller = this.document.getElementById(selObj);
    var iTop = 0;
	while(controller.tagName != "BODY") {
        iTop += controller.offsetTop;
        controller = controller.offsetParent; 
    }
	return iTop;
};



// Begin dropnav Functions
function posNav(selObj,id) {
	if(!isSafari && isNS || isIE_MacOSX || isIE_Mac ){//for Netscape and IE MACs
		document.getElementById(id).style.top =(this.getMarkerTop(selObj) + 24) + "px"; // used to adjust height offset of popup
		document.getElementById(id).style.left = (this.getMarkerLeft(selObj) - 79) + "px"; // used to adjust left offset of popup
	}
	else if(isSafari) { // for Safari MAX OSX
		document.getElementById(id).style.top = (this.getMarkerTop(selObj) + 24) + "px"; // used to adjust height offset of popup
		document.getElementById(id).style.left = (this.getMarkerLeft(selObj)  - 79) + "px"; // used to adjust left offset of popup
	}
	else { // all other EI versions on PC
		xPos = xPos;
		xPos = eval(document.getElementById(selObj)).offsetLeft;
		tempEl = eval(document.getElementById(selObj)).offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		}
		yPos = yPos;
		yPos = eval(document.getElementById(selObj)).offsetTop;
		tempEl = eval(document.getElementById(selObj)).offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		xPos = xPos - 0;
		document.getElementById(id).style.top = yPos + 24; // used to adjust height offset of popup
		document.getElementById(id).style.left = xPos  - 79; // used to adjust left offset of popup
	}
};
function showNav() {
	// posNav(selObj,id); // position infobubble  pop up layer
	document.getElementById('help').style.visibility='visible';
	document.getElementById('help').style.display='block';
	
	if (typeof document.body.style.maxHeight != "undefined") {
		// IE 7, mozilla, safari, opera 9
	} else {
		// IE6, older browsers
		hideSelects();  // hides any select objects that were hidden
	}

};
function hideNav(id) {
	document.getElementById(id).style.visibility='hidden';
	document.getElementById(id).style.display='none';

	if (typeof document.body.style.maxHeight != "undefined") {
		// IE 7, mozilla, safari, opera 9
	} else {
		// IE6, older browsers
		showSelects();  // replaces any select objects that were hidden
	}

};

function displayFields() {
	var searchSelect = document.getElementById('searchSelect');
	if (searchSelect.options.selectedIndex == "0") {
		hideDiv('project_searchFields');
		hideDiv('experts_searchFields');
	}
	else if (searchSelect.options.selectedIndex == "1") {
		hideDiv('experts_searchFields');
		showDiv('project_searchFields');
	}
	else if (searchSelect.options.selectedIndex == "2") {
		hideDiv('project_searchFields');
		showDiv('experts_searchFields');
	}
};

function displayList() {
	document.getElementById('quickLinksDiv').innerHTML='<img src="../images/spinner2.gif" style="padding: 10px 65px;" />'
	
	var quickSelect = document.getElementById('quickSelect');
	if (quickSelect.options.selectedIndex == "0") {
		document.getElementById('quickLinksDiv').innerHTML='';
	}
	else if (quickSelect.options.selectedIndex == "1") {
		mtimer = setTimeout("doAjax( '../inc/account/notificationDiv.inc', '', 'displayQuicklinks', 'GET', '0')", 2000);
	}
	else if (quickSelect.options.selectedIndex == "2") {
		mtimer = setTimeout("doAjax( '../inc/account/bookmarkDiv.inc', '', 'displayQuicklinks', 'GET', '0')", 2000);
	}
	else if (quickSelect.options.selectedIndex == "3") {
		mtimer = setTimeout("doAjax( '../inc/account/historyDiv.inc', '', 'displayQuicklinks', 'GET', '0')", 2000);
	}

};

function startInterval () { 
	int = setInterval("slideTabs()", 100); 
}
function stopInterval() {
	clearInterval(int);
};
function slideTabs(){
var tabs = document.getElementById('conTab');
	tabLeft = tabs.style.marginLeft
	units = 10;
var tabLeftStr,newStr

	if (tabLeft == ''){
		tabs.style.marginLeft = (tabLeft - units) + "px";
		//alert("empty");
	}
	 else {
	 	if(tabLeft.substring(3,4)  =='p'){
				tabLeftStr = tabLeft.substring(1,3);
				newStr = (tabLeftStr*1) + units
				tabs.style.marginLeft = "-" + newStr + "px";
				//alert(newStr );
		}
		if(tabLeft.substring(4,5)  =='p') {
			if (tabLeft.substring(1,4)<=120) {
				tabLeftStr = tabLeft.substring(1,4);
				newStr = (tabLeftStr*1) + units
				tabs.style.marginLeft = "-" + newStr + "px";
				//alert(newStr );
			}
			else {
				return false;
			}
		}
	}
	
};

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

