
var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printPage() {
  if (pr) // NS4, IE5
    window.print()
  else if (da && !mac) // IE4 (Windows)
    vbPrintPage()
  else // other browsers
    alert("Sorry, your browser doesn't support this feature.");
  return false;
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}

function openwin(url,winname) {
     my_url = url;
     pic_win = window.open(my_url,winname,"'menubar,scrollbars,resizable,copyhistory,width=500,height=480'");
     pic_win.focus();
}

function gcopenwin(url,winname) {
     my_url = url;
     pic_win = window.open(my_url,winname,"'width=150,height=100'");
     pic_win.focus();
}

function show_pic(url) {
     my_url = url;
     pic_win = window.open(my_url,'',"'menubar,scrollbars,resizable,status,copyhistory,width=420,height=500'");
     pic_win.focus();
}

function send_mail(url) {
     my_url = url;
     pic_win = window.open(my_url,'mail',"'scrollbars,copyhistory,resizable,width=580,height=500'");
     pic_win.focus();
}

function openConsole() {
  popupWin = window.open('/IM/console/console_frame.smpl', 'im_console', 'width=350,height=380')
  popupWin.focus();
}

function sendClose() {
     if( confirm("Send This?") ) {
	  document.sendywend.submit();
     } else { 
	  window.close();
     }
}

function check_em_all() {
     for(var i = 0; i < document.check_box_list.elements.length; i++) {
	  if( document.check_box_list.elements[i].name.indexOf("do_me") > -1 ) {
	       document.check_box_list.elements[i].checked = 'true';
	  }
     }
}

function uncheck_em_all() {
     for(var i = 0; i < document.check_box_list.elements.length; i++) {
	  if( document.check_box_list.elements[i].name.indexOf("do_me") > -1 ) {
	       document.check_box_list.elements[i].checked = '';
	  }
     }
}


function generic_check_em_all(f,test) {
     form_name = f.name;
     this_form = eval ('document.' + form_name);
     
     for(var i = 0; i < this_form.elements.length; i++) {
	  if( this_form.elements[i].name.indexOf(test) > -1 ) {
	       this_form.elements[i].checked = 'true';
	  }
     }
}

function generic_uncheck_em_all(f,test) {
	
	 form_name = f.name;
     this_form = eval ('document.' + form_name);
	
     for(var i = 0; i < this_form.elements.length; i++) {
	  if( this_form.elements[i].name.indexOf(test) > -1 ) {
	       this_form.elements[i].checked = '';
	  }
     }
}


//Ultimate Chat Functions

var buddyWindow = null;
var global_screen_name = null;
var global_uid = null;

//check for a handle in a cookie

function openchatwin(screen_name,uid,u_id,user_screen_name,user_status,brand_name) {

	W=234;
	H=331;
	
	//First determine if buddy window is open - if not open it
   	if (buddyWindow == null || buddyWindow.closed) {
   		
   		//global_screen_name = screen_name;
		//global_uid = uid;		
   		openBuddyWindow(W, H, user_screen_name, u_id, user_status, brand_name);
   		//alert("Please open your Buddy List first by clicking the Instant Messaging link in the main navigation.");
	
	} else {

		buddyWindow.flabberObj.SetVariable("command", 99);
		buddyWindow.flabberObj.SetVariable("windowname", screen_name);
		buddyWindow.flabberObj.SetVariable("uid", uid);
		buddyWindow.flabberObj.TCallLabel("_root", "ActionPeriod");
		
	}

}

function openBuddyWindow(W, H, user_screen_name, u_id, user_status, brand_name, do_init) {
	W=234;
	H=331;
 	if (buddyWindow == null || buddyWindow.closed) {
		var str = "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=" + W + ",height=" + H;
   		buddyWindow = window.open("/ultimatechat/index.smpl?username=" + u_id + "&sendername=" + user_screen_name + "&user_status=" + user_status + "&brand_name=" + brand_name + "&do_init=" + do_init,'buddy_win',str);
	}
}

function wait() {

	; //do nothing
	
}

function message_init () {
				
		if (global_screen_name && global_uid) {
			//alert("Starting Chat");
			buddyWindow.flabberObj.SetVariable("command", 99);
			buddyWindow.flabberObj.SetVariable("windowname", global_screen_name);
			buddyWindow.flabberObj.SetVariable("uid", global_uid);
			buddyWindow.flabberObj.TCallLabel("_root", "ActionPeriod");
			
		}
		
		global_screen_name='';
		global_uid='';
		
}


// cookies.js
// Derived from the Bill Dortch code at http://www.hidaho.com/cookies/cookie.txt

var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal (j);
			}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
		}
	return null;
}

function DeleteCookie (name,path,domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
}

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

//Dreamweaver Functions

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// ======================================
// Random image swapper thingy
// ======================================

var randomImages = new Array()

// To add more images, increment the number and change the image file name

randomImages[0] = '/images/3in10_sml.jpg'
randomImages[1] = '/images/94years_sml.jpg'
randomImages[2] = '/images/976_sml.jpg'

// ======================================
// do not touch anything below this
// ======================================

var j = 0
var p = randomImages.length;

var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = randomImages[i]
}

var whichImage = Math.round(Math.random()*(p-1));
function randomLeftImage(){
document.write('<img src="'+randomImages[whichImage]+'">');
}

function showElement(theElement, method) {
		
		if (method == 0 || method == '' || !method) {
			method = "inline";
		}
		
        if (document.getElementById) {
                // this is the way the standards work
                var style2 = document.getElementById(theElement).style;
                style2.display =  method;
        } else if (document.all) {
                // this is the way old msie versions work
                var style2 = document.all[theElement].style;
                style2.display = method;
        } else if (document.layers) {
                // this is the way nn4 works
                var style2 = document.layers[theElement].style;
                style2.display = method;
        }
}

function hideElement(theElement, method) {
		
        if (document.getElementById) {
                // this is the way the standards work
                var style2 = document.getElementById(theElement).style;
                style2.display = "none";
        } else if (document.all) {
                // this is the way old msie versions work
                var style2 = document.all[theElement].style;
                style2.display = "none";
        } else if (document.layers) {
                // this is the way nn4 works
                var style2 = document.layers[theElement].style;
                style2.display = "none";
        }
}

function saveTextFieldTohidden(textfield,hidden_field) {
    var myElement = document.getElementById(hidden_field);
    var text_box = document.getElementById(textfield);
    myElement.value = text_box.value;
}

function updateSpanText(ElementId,text) {
        if (document.getElementById) {
                // this is the way the standards work
                document.getElementById(ElementId).innerHTML = text;
        } else if (document.all) {
                // this is the way old msie versions work
                document.all[ElementId].innerHTML= text;
        } else if (document.layers) {
                // this is the way nn4 works
                document.layers[ElementId].innerHTML=text;
        }
}



