//Toggles the visibility of an object
function toggleVisibility(mode, objID, parentID){
	//mode 0 - hide
	//mode 1 - display

	if(mode==0){
		if(client.ie || client.ns6){
			if(client.ie4){
				var element = eval("document.all." + objID);
				element.style.visibility='hidden';
			} else {
				document.getElementById(objID).style.visibility='hidden';
			}
		} else if(client.ns4){
			document[parentID].document[objID].visibility='hidden';
		}
	} else if(mode==1){
		if(client.ie || client.ns6){
			if(client.ie4){
				var element = eval("document.all." + objID);
				element.style.visibility='visible';
			} else {
				document.getElementById(objID).style.visibility='visible';
			}			
		} else if(client.ns4){
			document[parentID].document[objID].visibility='show';
		}	
	}
}

var wws_imgRoot = 'docs/wwsbook/wws_btn_';
function wws_imgSwap(nav, mode){
	imgSrc = wws_imgRoot + nav + '_' + mode + '.gif';
	imgSwap(nav, imgSrc);
}

function _imgSwap(nav, mode){
	imgSrc = imgRoot + nav + '_' + mode + '.gif';
	imgSwap(nav, imgSrc);
}

//Swaps out an image for an img element
function imgSwap(objID, src, parentID){
	if((client.ns4) && (parentID!=null)){
		document[parentID].document.images[objID].src = src;	
	} else {
		document.images[objID].src = src;		
	}
}

//Preloads the Images
function preloadImages(images_array) {
	for(i=0; i < images_array.length; i++){
   		var an_image = new Image();
		an_image.src = images_array[i];
	}
}

function popUp( url, width, height, target, otherFeatures, replace ) {
// url is REQUIRED; target defaults to "_blank"; otherFeatures defaults to the string below.
	
	if( url ) {
		target = target ? target : "_blank";
		var features = "";
		if( width )  features += "width=" + width + ",";
		if( height ) features += "height=" + height + ",";
		features += otherFeatures ? otherFeatures : "location=no,scrollbars=yes,status=no,toolbar=no,resizable=no";
		var newWin = window.open( url, target, features, replace );
		newWin.focus();
		return newWin;
	} else {
		return false;
	}
}

//researchPopUp clarsen 2/7/2002
function researchPopUp(theURL){
	//popUp(theURL, 800, 600, 'gcom', 'resizable=yes,scrollbars=yes');
	gPop(theURL, 798, 569);
}

//This should be removed when a final solution is made for the security team

function securityTeamPopUp(theURL){
	gPop(theURL, 800, 600);
}

function researchPop(theURL){
	gPop(theURL, 798, 569);
}
function gPopUp(url, w, h, title, features, target) {
	
	var newWin=null;
	
	target = target ? target : "_blank";
	
	//calculate the x, and y position of the popup to center it
	var left = (screen.width - w)/2;
	var top = (screen.height - h)/2;
	
	var settings = 'width=' + w + ',height=' + h + ',top=' + top + ',left=' + left + ', ' + features;
	
	newWin = window.open(url, target, settings);
	newWin.focus();
	
}
function gPop(url, w, h){
	target = "_blank";
	features = 'resizable=yes,scrollbars=yes,toolbar=yes';
	gPopUp(url, w, h, "", features);
}
//


//CHANGE

//loadtheCookies clarsen 2/5/2002 
//the fuction returns an associative array indexed on the name of the cookie.
//currently Cookies is the name of this associative array 

function loadtheCookies(){
	theCookies=0;
	if(!theCookies) theCookies = new Array();	
	var cookieArray = document.cookie.split(';');
	for(i=0;i<cookieArray.length;i++){
		var nameValue = cookieArray[i].split('=');
		if(nameValue[0].substring(0,1)==" ") nameValue[0] = nameValue[0].substring(1);
		theCookies[nameValue[0]]=nameValue[1];
	}
	return theCookies;		
}
Cookies = loadtheCookies();

//user clarsen 2/7/2002
//user return an object that provides info about the users login and access state  

function user(){
	this.fullAccess=Cookies['WCW_Authentication']||(Cookies['WCW_Security'] && Cookies['SecurityId'])?true:false;
	this.recognized=Cookies['wcw.recognized.user']?true:false;
	this.hasBeenToGartner=Cookies['outage113001']?true:false;
}

theUser=new user();



// The next three functions, randomImage(), linkToDocumentation() and countDown(), are from docs/symposium/utils.js -- greg.smalley@gartner.com, 20020716

//Random image generator for background image on story pages.
function randomImage(){
	var mycontent=new Array()
	mycontent[1]='<td valign=top nowrap background=docs/symposium/bg_woman.jpg>'
	mycontent[2]='<td valign=top nowrap background=docs/symposium/bg_woman_glasses.jpg>'
	mycontent[3]='<td valign=top nowrap background=docs/symposium/bg_man.jpg>'
	
	var ry=Math.floor(Math.random()*mycontent.length)
	if (ry==0)
	ry=1
	document.write(mycontent[ry])
}

//Return user to gartner3 or gartner4 when linking to documentation page.
function linkToDocumentation() {
	if (document.cookie.indexOf("trackDomain") != -1) {
		var beginTD = document.cookie.indexOf("trackDomain=") + 12;
		var substringTD = document.cookie.substring(beginTD, document.cookie.length);
		var endTD = substringTD.indexOf("gartner.com") + 11;
		var trackDomain = substringTD.substring(0, endTD);
		} else {
		var trackDomain = "www.gartner.com"
	}
	gotoURL = "http://" + trackDomain + "/2_events/symposium/spg4/spg4_documentation.jsp";
	self.location=gotoURL;
	return;
}

//Return user to gartner3 or gartner4 when linking to documentation page.
function linkToDocumentation2() {
	if (document.cookie.indexOf("trackDomain") != -1) {
		var beginTD = document.cookie.indexOf("trackDomain=") + 12;
		var substringTD = document.cookie.substring(beginTD, document.cookie.length);
		var endTD = substringTD.indexOf("gartner.com") + 11;
		var trackDomain = substringTD.substring(0, endTD);
		} else {
		var trackDomain = "www.gartner.com"
	}
	gotoURL = "http://" + trackDomain + "/pages/story.php.id.2027.s.8.jsp";
	self.location=gotoURL;
	return;
}

//Return user to gartner3 or gartner4 when linking to documentation page.
function linkToDocumentation3() {
	if (document.cookie.indexOf("trackDomain") != -1) {
		var beginTD = document.cookie.indexOf("trackDomain=") + 12;
		var substringTD = document.cookie.substring(beginTD, document.cookie.length);
		var endTD = substringTD.indexOf("gartner.com") + 11;
		var trackDomain = substringTD.substring(0, endTD);
		} else {
		var trackDomain = "www.gartner.com"
	}
	gotoURL = "http://" + trackDomain + "/pages/story.php.id.2261.s.8.jsp";
	self.location=gotoURL;
	return;
}

//Removes countdown banner for SPG4 after event start date.
function countDown() {
	currentDate= new Date();
	targetDate=new Date(2002,3,29);
	daysLeft=targetDate-currentDate;
	daysLeft=Math.ceil(daysLeft/1000/60/60/24);

	if (daysLeft <= 0) {
		document.write ("<img src=docs/dot.gif border=0 hspace=0 vspace=0 height=1 width=195><br>");
	}
	else {
		document.write ("<table border=0 cellpadding=0 cellspacing=0 width=195>");
		document.write ("<tr>");
		document.write ("<td bgcolor=#000000 colspan=3><img src=docs/dot.gif border=0 hspace=0 vspace=0></td>");
		document.write ("</tr>");
		document.write ("<tr bgcolor=#ECECEC>");
		document.write ("<td valign=top><img src=docs/calendar.gif border=0 hspace=0 vspace=0 width=59 height=47></td>");
		document.write ("<td><span class=countDownNumber>" + daysLeft + "<br></span></td>");
		document.write ("<td><span style=font-family:arial,helvetica;color:#555555;font-size:15px;font-weight:bold;>days until<br>Symposium<br></span></td>");
		document.write ("</tr>");
		document.write ("<tr>");
		document.write ("<td bgcolor=#000000 colspan=3><a href=/news/story.php.id.339.html target=_top><img src=docs/registernow_ani.gif border=0 hspace=0 vspace=0 height=20 width=195></a></td>");
		document.write ("</tr>");
		document.write ("</table>");
	}
}

//Removes countdown banner for SYM12 after event start date.
function countDown2() {
	currentDate= new Date();
	targetDate=new Date(2002,9,6);
	daysLeft=targetDate-currentDate;
	daysLeft=Math.ceil(daysLeft/1000/60/60/24);

	if (daysLeft <= 0) {
		document.write ("<img src=docs/dot.gif border=0 hspace=0 vspace=0 height=1 width=195><br>");
	}
	else {
		document.write ("<table border=0 cellpadding=0 cellspacing=0 width=195>");
		document.write ("<tr>");
		document.write ("<td bgcolor=#000000 colspan=3><img src=docs/symposium/dot.gif border=0 hspace=0 vspace=0></td>");
		document.write ("</tr>");
		document.write ("<tr bgcolor=#ECBD00>");
		document.write ("<td valign=top><img src=docs/symposium/calendar.gif border=0 hspace=0 vspace=0 width=59 height=47></td>");
		document.write ('<td><span style="font-family:arial narrow,verdana,arial,helvetica;color:#000000;font-size:38px;font-weight:bold;">' + daysLeft + '<br></span></td>');
		document.write ("<td><span style=font-family:arial,helvetica;color:#555555;font-size:15px;font-weight:bold;>days until<br>Symposium<br></span></td>");
		document.write ("</tr>");
		document.write ("<tr>");
		document.write ("<td bgcolor=#000000 colspan=3><a href=javascript:sym12CloseReg();><img src=docs/symposium/registernow_sym12_ani.gif border=0 hspace=0 vspace=0 height=20 width=195></a></td>");
		document.write ("</tr>");
		document.write ("</table>");
	}
}

//Removes countdown banner for ESC14 after event start date.
function countDown3() {
	currentDate= new Date();
	targetDate=new Date(2002,10,4);
	daysLeft=targetDate-currentDate;
	daysLeft=Math.ceil(daysLeft/1000/60/60/24);

	if (daysLeft <= 0) {
		document.write ("<img src=docs/dot.gif border=0 hspace=0 vspace=0 height=1 width=195><br>");
	}
	else {
		document.write ("<table border=0 cellpadding=0 cellspacing=0 width=195>");
		document.write ("<tr>");
		document.write ("<td bgcolor=#000000 colspan=3><img src=docs/symposium/dot.gif border=0 hspace=0 vspace=0></td>");
		document.write ("</tr>");
		document.write ("<tr bgcolor=#ECBD00>");
		document.write ("<td valign=top><img src=docs/symposium/calendar.gif border=0 hspace=0 vspace=0 width=59 height=47></td>");
		document.write ('<td><span style="font-family:arial narrow,verdana,arial,helvetica;color:#000000;font-size:38px;font-weight:bold;">' + daysLeft + '<br></span></td>');
		document.write ("<td><span style=font-family:arial,helvetica;color:#555555;font-size:15px;font-weight:bold;>days until<br>Symposium<br></span></td>");
		document.write ("</tr>");
		document.write ("<tr>");
		document.write ("<td bgcolor=#000000 colspan=3><a href=/story.php.id.1327.s.5.html><img src=docs/symposium/registernow_sym12_ani.gif border=0 hspace=0 vspace=0 height=20 width=195></a></td>");
		document.write ("</tr>");
		document.write ("</table>");
	}
}

//Removes countdown banner for PS02 after event start date.
function countDown4() {
	currentDate= new Date();
	targetDate=new Date(2002,10,12);
	daysLeft=targetDate-currentDate;
	daysLeft=Math.ceil(daysLeft/1000/60/60/24);

	if (daysLeft <= 0) {
		document.write ("<img src=docs/dot.gif border=0 hspace=0 vspace=0 height=1 width=195><br>");
	}
	else {
		document.write ("<table border=0 cellpadding=0 cellspacing=0 width=195>");
		document.write ("<tr>");
		document.write ("<td bgcolor=#000000 colspan=3><img src=docs/symposium/dot.gif border=0 hspace=0 vspace=0></td>");
		document.write ("</tr>");
		document.write ("<tr bgcolor=#ECBD00>");
		document.write ("<td valign=top><img src=docs/symposium/calendar.gif border=0 hspace=0 vspace=0 width=59 height=47></td>");
		document.write ('<td><span style="font-family:arial narrow,verdana,arial,helvetica;color:#000000;font-size:38px;font-weight:bold;">' + daysLeft + '<br></span></td>');
		document.write ("<td><span style=font-family:arial,helvetica;color:#555555;font-size:15px;font-weight:bold;>days until<br>Symposium<br></span></td>");
		document.write ("</tr>");
		document.write ("<tr>");
		document.write ("<td bgcolor=#000000 colspan=3><a href=https://www.infosalons.com.au/SymposiumITxpo/Conference.asp target=_new><img src=docs/symposium/registernow_sym12_ani.gif border=0 hspace=0 vspace=0 height=20 width=195></a></td>");
		document.write ("</tr>");
		document.write ("</table>");
	}
}

function sym12CloseReg() {
	window.open('http://symposium.gartner.com/docs/symposium/sym12_regclose.html','sym12_regclose','height=220,width=400,scrollbars=yes,status=no,resizable=no');
}

function redirectDomain() {
	if (document.cookie.indexOf("trackDomain") != -1) {
		// the cookie contains trackDomain...
		
		// get domain from cookie...
		start = document.cookie.indexOf("trackDomain") + 12;
		trackDomain = document.cookie.substring(start,document.cookie.length);
		stop = trackDomain.indexOf("com") + 3;
		targetDomain = trackDomain.substring(0,stop);
		
		// check to see if cookie domain is same as current domain...
		if (targetDomain != location.hostname) {
			// redirect to cookie domain if current domain is not same...
			gotoURL = "http://" + targetDomain + location.pathname;
			self.location = gotoURL;
			return;
		}
	}
}

//used for drop down menu navigation
function g_go(selectObj){
	var listValue = selectObj.options[selectObj.selectedIndex].value; 
	if(listValue != "none"){
		window.location=listValue;
	}
}


/*
	EMAIL A FRIEND Directions
	
	Parameters:
	1) 	FORM url - optional
	2) 	WIDTH - of the form - optional
	3) 	HEIGHT - of the form - optional
	4) 	TITLE - to be displayed in the email - optional
	5) 	URL - to be displayed in the email - optional
	6) 	HEADER IMAGE - absolute path to the header image width: 187px - optional
	7) 	BUTTON IMAGE - absolute path to the button image width: 187px - optional
	8) 	TEXT BLURB - absolute path to the text blurb .js file  - optional
		- see \\enablizer.gartner.com\docs\common\emailafriend\default_blurb.js for an example
	9)  EMAIL SUFFIX - absolute path to the email suffix text blurb .js file - optional	
*/

//Calls the email a friend form
function emailAFriend(formURL, w, h, title, refer, hdrImage, btnImage, txtBlurb, txtPrefixBlurb, txtSuffixBlurb){

	var baseURL = "http://security.gartner.com";
	var formURL = formURL ? baseURL + "/docs/jspdocs/" + formURL : baseURL + "/docs/jspdocs/emailafriend/emailLinkerForm.jsp";
	var w = w ? w : 192;
	var h = h ? h : 380;
	var title = title ? title : escape(document.title);
	var refer = refer ? refer : escape(document.location);
	var hdrImage = hdrImage ? hdrImage : "http://symposium.gartner.com/docs/symposium/2003/subhead_emailafriend_blue.gif";
	var btnImage = btnImage ? btnImage : "http://symposium.gartner.com/docs/symposium/2003/button_sendemail.gif";
	var txtBlurb = txtBlurb ? txtBlurb : baseURL + "/docs/common/emailafriend/default_blurb.js"; 
	var txtPrefixBlurb = txtPrefixBlurb ? txtPrefixBlurb : baseURL + "/docs/common/emailafriend/default/txtPrefixBlurb.inc";
	var txtSuffixBlurb = txtSuffixBlurb ? txtSuffixBlurb : "";
	
	var url = formURL;
	url += "?title=" + title;
	url += "&refer=" + refer;
	url += "&hdrImage=" + hdrImage;
	url += "&btnImage=" + btnImage;
	url += "&txtBlurb=" + txtBlurb;
	url += "&txtPrefixBlurb=" + txtPrefixBlurb;
		
	if(txtSuffixBlurb != ""){
		url += "&txtSuffixBlurb=" + txtSuffixBlurb;
	}
	
	
	var features = 'resizable=yes,scrollbars=no,toolbar=no';	
	gPopUp(url, w, h, "", features);
}

//Generic Random number generation
//r1 = min number, r2 = max number
function randomNumber(r1, r2) {
  if (r2 > r1) return (Math.round(Math.random()*(r2-r1))+r1);
  else return (Math.round(Math.random()*(r1-r2))+r2);
}	

function openBio(href) {
   window.open(href,'_blank','width=565,height=450,scrollbars=yes,resizable=no');
   return false;
}

function alertIsDemo() {
	alert("This is a demo. To learn more about Gartner Membership Programs, email us at apmember@gartner.com");
}
