

function Nav(divname) {
	document.getElementById(CurrentDiv).style.display='none' ;
	document.getElementById(divname).style.display='inline' ;
	/*
	var cell1 = document.getElementById('cell'+CurrentDiv);
	var cell2 = document.getElementById('cell'+divname);
	cell1.style.background="#012F51";
	cell2.style.background="black";
	*/
	CurrentDiv=divname;
}//Nav	

function SetTab() {
	if (tab != "") Nav(tab);
	if (!edit) document.getElementById('SaveChanges').style.display='none';
	//disabled=true;
	if (!edit) document.getElementById('ClearChanges').style.display='none';
	//disabled=true;
	if (pending) document.getElementById('pending').style.display='inline';
	
	/* NEED TO CHANGE THE FOLLOWING TO HIDE THE BUTTON USING CSS STYLES */
	
	if (pending) document.getElementById('AddRoomBtn').style.display='none';
}//SetTab()

function AddRoom() {
	open('roominfo.pl', '', 'toolbar=no, scrollbars=no, menubar=no, status=no, width=440, height=240, resizable=yes');
	return false;
}//AddRoom()

function Save() {
	var str = document.location.href;
	var col_array=str.split("/");
	var url = "https://";
	
	for (x=2;x<col_array.length-1;x++) {
		url = url + col_array[x] + "/";
	}
	
	url += "secure/checkout.pl?cmd=sub";
	popupWindow(url,770,590);
	//open(url, '', 'toolbar=no, scrollbars=yes, menubar=no, width=770, height=570, resizable=yes');
	
	//	account.cmd.value="save";
	//	account.submit();
	return false;
}//Save()

function Clear() {
	var ret = confirm("Are you sure you wish to clear all changes?");
	
	if (ret == true) { 
		document.account.cmd.value="clear";
		document.account.submit();
	}
	
	return false;
}//Clear()

function Launch(server, roomid) {
	open('http://www.keynoteconference.com/cgi-bin/launch.pl?server='+server+'&room='+roomid, '', 'toolbar=no, scrollbars=no, menubar=no, status=no, width=400, height=300, resizable=yes');
	return false;
}

function editroom(roomid) {
	
	if (roomid == 0) {
		alert('You are unable to edit a room while its status is not enabled or disabled');
	} else {
		open('roominfo.pl?roomid='+roomid, '', 'toolbar=no, scrollbars=no, menubar=no, status=no, width=440, height=340, resizable=yes');
	}//if
	
	return false;
	
}//editroom()

function ConfirmDelete(roomid, roomf) {
	var ret = confirm("Are you sure you wish to delete room " + roomf);
	
	if (ret == true) { 
		document.account.cmd.value="delete";
		document.account.roomid.value=roomid;
		document.account.submit();
	}
	return false;
}//ConfimDelete()

function ConfirmDeleteChange(roomid) {
	var ret = confirm("Are you sure you wish to delete this pending change?");
	
	if (roomid == 0) {
		alert("You cannot delete this room, please wait for the payment transaction to complete.");
		return false;
	}
	
	
	
	if (ret == true) { 
		document.account.cmd.value="deletechange";
		document.account.roomid.value=roomid;
		document.account.submit();
	}
	
	return false;
}//ConfirmDeleteChange()

function ShowLinks(server, roomid, pass, cid) {
	var sl = 'http://www.keynoteconference.com/join.html?'+roomid;
	var shr = 'Click <a href="' + sl + '">here</a> to enter the conference room.';
	var ll = 'http://www.keynoteconference.com/cgi-bin/launch.pl?server='+server+'&room='+roomid;
	var hr = 'Click <a href="' + ll + '">here</a> to enter the conference room.';

	newwin=window.open('','preview',"width=700,height=700,scrollbars=yes,resizable");
	newwin.document.close();
	newwin.document.open();
	newwin.document.write('<html><head><title>Launch Links</title></head><body>');
	
	// write the normal link
	newwin.document.write('<H3>Simple launch link using KeynoteConference Web Page</H3>');
	newwin.document.write('This is the easiest method and uses KeynoteConference\'s Website to enter the conference room<br>');
	newwin.document.write(shr);
	newwin.document.write('<xmp>' + shr + '</xmp>');
	
	// write the normal link
	newwin.document.write('<H3>Simple launch link using your Web Page</H3>');
	newwin.document.write(hr);
	newwin.document.write('<xmp>' + hr + '</xmp>');

	// write the link to run in a popup
	newwin.document.write('<H3>Secured Launch Link</H3>');
	newwin.document.write('This method requires php and a script that we can help write.  The basics are shown below<br>');
	newwin.document.write('<XMP>');
	newwin.document.write('<?php\n');
	newwin.document.write('  \$password = "' + pass + '";\n  $cid =      "' + cid + '";\n');
	newwin.document.write('  \$url =      "http://download.howudodat.com/launch/launch.php?cid=\$cid";\n  $params =   "room=' + roomid + '";\n');
	newwin.document.write('  header(\'Location: \' . \$url . encode(\$params, \$password));\n  exit;\n\n');
	newwin.document.write('function encode (\$var, \$pass, \$r=1) {\n');
	newwin.document.write('   \$rtrstr = "";\n   \$svrstr = "";\n');
	newwin.document.write('   for(\$i=0; \$i<strlen(\$var); \$i++) {\n');
	newwin.document.write('     \$rtrstr .= chr(ord(\$var[\$i]) + \$r);\n');
	newwin.document.write('   }\n   \$md = md5(\$rtrstr . \$pass);\n   \$rtrstr = base64_encode(\$rtrstr);\n');
	newwin.document.write('   $svrstr = "&sid2=" . \$rtrstr . "&h=" . \$md;\n   return \$svrstr;\n}\n\n?>');
	newwin.document.write('</XMP>\n');
	
	newwin.document.write('</body></html>')
	newwin.document.close();
}//ShowLinks()
/*
function ShowLinks(server, roomid) {
	var sl = 'http://www.keynoteconference.com/join.html?'+roomid;
	var shr = 'Click <a href="' + sl + '">here</a> to enter the conference room.';
	var ll = 'http://www.keynoteconference.com/cgi-bin/launch.pl?server='+server+'&room='+roomid;
	var hr = 'Click <a href="' + ll + '">here</a> to enter the conference room.';
	//	var hrd = 'Click <a href="' + ll + '&debug=2259">here</a> to enter the conference room with debugging.';
	var oc = 'open(\'' + ll + '\', \'\', \'toolbar=no, scrollbars=no, menubar=no, status=no, width=500, height=400, resizable=yes\'); return false;';
	var il = 'Click <a href="' + ll + '"><img src="/images/login.jpg"></a> to enter the conference room.';

	newwin=window.open('','preview',"width=500,height=350,scrollbars=yes,resizable");
	newwin.document.close();
	newwin.document.open();
	newwin.document.write('<html><head><title>Launch Links</title></head><body>');
	
	// write the normal link
	newwin.document.write('<H3>Simple launch link using KeynoteConference Web Page</H3>');
	newwin.document.write('This is the easiest method and uses KeynoteConference\'s Website to enter the conference room<br>');
	newwin.document.write(shr);
	newwin.document.write('<xmp>' + shr + '</xmp>');
	
	// write the normal link
	newwin.document.write('<H3>Simple launch link using your Web Page</H3>');
	newwin.document.write(hr);
	newwin.document.write('<xmp>' + hr + '</xmp>');

	// write the normal debug link
	//	newwin.document.write('<H3>Simple launch link using your Web Page With Debugging</H3>');
	//	newwin.document.write(hrd);
	//	newwin.document.write('<xmp>' + hrd + '</xmp>');
	
	// write the link to run in a popup
	newwin.document.write('<H3>Launch Link that runs in a popup window</H3>');
	newwin.document.write('Click <a href="#" onclick="' + oc + '">here</a> to enter the conference room.');
	newwin.document.write('<XMP>Click <a href="#" onclick="' + oc + '">here</a> to enter the conference room.</XMP>');
	
	// write the link with an img
	newwin.document.write('<H3>Launch Link Using an Image</H3>Note:  This can use either of the above 2 methods to launch<br>');
	newwin.document.write(il);
	newwin.document.write('<xmp>' + il + '</xmp>');
	newwin.document.write('</body></html>')
	newwin.document.close();
}//ShowLinks()
*/


/* 
	Generic Code to Preload & Swapout images 
	Added: 5/17/06 A.B.
*/

var preloadImages = new Array()

function imgHi(sImage,sGraphic) {
	for (i=0;i<preloadImages.length;i++){
		if (preloadImages[i].src = sGraphic){
			document.images[sImage].src = sGraphic
		}//if
	}//for
}//imgHi

function imgLow(sImage,sGraphic) {
	for (i=0;i<preloadImages.length;i++){
		if (preloadImages[i].src = sGraphic){
			document.images[sImage].src = sGraphic
		}//if
	}//for
}//imgLow

function preloadImg(sImages) {
	preloadImages = sImages.split(",");
	for (i=0;i<preloadImg.arguments.length;i++){
		preloadImages[i] = new Image()
		preloadImages[i].src = preloadImg.arguments[i]
	}//for
	SetTab();
}//preloadImg

/* 
	Generic Code for Popup Windows
	Added: 5/17/06 A.B.
*/

function popupWindow(URL,setWidth,setHeight) {

	var winl   = (screen.width-setWidth)/2;
	var wint   = (screen.height-setHeight)/2;
	
	newWindow  = window.open(URL, "popWin", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+setWidth+',height='+setHeight+',top='+wint+',left='+winl);			

}//popupWindow()
