﻿// ** Common JavaScript File **
var isIE6 = (document.all && !window.XMLHttpRequest)?true:false;

// CREATE INFO WINDOW

function view_info(){

// ------------

var theBody = document.getElementsByTagName("BODY")[0];
var yPos = Math.max(document.getElementsByTagName("HTML")[0].scrollTop,theBody.scrollTop);

if (document.getElementById("info_window") == null) {

	var infoWin = document.createElement("div");
	infoWin.id = "info_window";
	infoWin.innerHTML = '<div class="outer"><div class="inner"><p id="info_window_close" onclick="close_info()"><input type="button" class="btn" value="x" /></p><div id="info_window_content"><h3>loading...</h3></div></div></div>';

	var mute = document.createElement("div");
	mute.id = "ajax_deafmute";
	mute.setAttribute("style","display:none");

	theBody.appendChild(infoWin);
	theBody.appendChild(mute);

}

document.getElementById("info_window").style.top = yPos+20+"px";
document.getElementById("info_window").style.visibility = "visible";

// if IE6 hide select boxes...
if (isIE6) {
	var theSelects = document.getElementById("content").getElementsByTagName('select');
	for (var i = 0; i < theSelects.length; i++) {
	theSelects[i].style.visibility = 'hidden';
		}
	}
}

function close_info(){
// ----------
if (document.getElementById("info_window")) {
document.getElementById("info_window").style.visibility = "hidden";
document.getElementById("info_window").innerHTML = '<div class="outer"><div class="inner"><p id="info_window_close" onclick="close_info()"><input type="button" class="btn" value="x" /></p><div id="info_window_content"><h3>loading...</h3></div></div></div>';

// if IE6 show select boxes previously hidden...
if (isIE6) {
var theSelects = document.getElementById("content").getElementsByTagName('select');
for (var i = 0; i < theSelects.length; i++) {
theSelects[i].style.visibility= 'visible';
}
}
}
}

function clear_info_content() {
// ----------
if (document.getElementById('info_window_content')) {
	document.getElementById('info_window_content').innerHTML='&nbsp;';
}
}

function ajaxManager() {
// ----------
// arg_0 == function name
// arg_1 == page to request
// arg_2 == element ID to inject the returned data into
// arg_3 == asynchronous (true | false)
// arg_4 == request method (empty=GET | POST == POST)
// arg_5 == showState

var thedate = new Date();
var thetime = thedate.getTime();

var args = ajaxManager.arguments;

var async = args[3];
var rMethod = args[4];
if (rMethod == null) { rMethod='GET'; } else { rMethod.toUpper=rMethod; }
if (async == null) {async=true;}

var showState = args[5];		// determines whether to display the server responses
if (showState == null) {showState=false;}

var el_ok = false;

switch (args[0])
{
case "load_page":
if (document.getElementById(args[2])){
el_ok = true;
}
if (el_ok) {
var el = document.getElementById(args[2]);
}
//var xAjax = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
var xAjax = GetXmlHttpObject();

if (xAjax) {
xAjax.onreadystatechange = function() {
try {
	if (xAjax.readyState == 0)
		{ if (el_ok) { 	if (showState) {el.innerHTML = "initializing..."; }}}
	else if (xAjax.readyState == 1)
		{ if (el_ok) { 	if (showState) {el.innerHTML = "processing request..."; }}}
	else if (xAjax.readyState == 2)
		{ if (el_ok) { 	if (showState) {el.innerHTML = "request acknowledged..."; }}}
	else if (xAjax.readyState == 3)
		{ if (el_ok) { 	if (showState) {el.innerHTML = "loading data..."; }}}
	else if (xAjax.readyState == 4) {
		//el.innerHTML = x.status + '<br>' + args[1];
		if (xAjax.status == 200) {
			 if (el_ok) { el.innerHTML = xAjax.responseText; }
			}
		if (xAjax.status > 400) {
			 //alert('ERROR: ' + parseFloat(xAjax.status) + '\n' + xAjax.responseText); 
			 }
		}
}
catch (err) {
}
	};

if (rMethod=='GET') {
	 // GET
	var sPage=args[1];		// the full page, create the URL and FORM data
	if (sPage.indexOf("?") > 0) {
		sPage+='&rand=' + thetime;		// add it to the querystring
		} else {
		sPage+='?rand=' + thetime;		// because there was no query string
	}
	xAjax.open(rMethod, sPage, async);		// args[1] is the url to GET, true for async,
	xAjax.send(null);
} else {
	// POST		
	var sPage=args[1];		// the full page, create the URL and FORM data
	var qs = '';
	qs = sPage.substring(sPage.indexOf("?")+1,sPage.length);
	if (sPage.indexOf("?") > 0) {
		qs+='&rand=' + thetime;		// add it to the querystring
	} else {
		qs+='?rand=' + thetime;		// because there was no query string
	}
	sPage = sPage.substring(0,sPage.indexOf("?"));
	xAjax.open(rMethod, sPage, async);		// args[1] is the url to POST, true for async,
	xAjax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xAjax.send(qs);
	}
}
break;
}
}


function GetXmlHttpObject()
{
var xmlHttp=null;

try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


function launchIM(p,n) {
// ----------
//prompt('You are launching /chatroom/im.asp' + p + ' from member_id=' + n, '/chatroom/im.asp' + p);

var iw=600;
var ih=650;
var w=window.open('/chatroom/im.asp' + p, 'im' + n, config='height=' + ih + ',width=' + iw + ', toolbar=no, menubar=no, scrollbars=auto, resizable=yes,location=no, directories=no, status=no');
if (w) {
	//w.blur();
	w.moveTo((screen.width/2)-(iw/2),(screen.height/2)-(ih / 2));
	w.focus();
}
}


//ADDS CORNERS TO THE IMAGES...
function addCorners() {
// ----------
}


/* SHOW/HIDE FUNCTION FOR THE TABS */

function toggle(x) {
// ----------

if (x.tagName!="A"){x=x.parentNode;}

var theTabs = x.parentNode.getElementsByTagName("A");
var i = theTabs.length-1;
var whichOne;

do {
	if (theTabs[i].className=="t t_on") {
		theTabs[i].className="t";
	}

	if (x == theTabs[i]){
		whichOne=i;
	}
}

while (i--)

var theDivs = x.parentNode.parentNode.getElementsByTagName("DIV");
i = theDivs.length-1;
var theTabContents = new Array();

do {
	if (theDivs[i].className.indexOf("t_content")>-1) {
		theTabContents[theTabContents.length] = theDivs[i];
	}
}

while (i--)

i = theTabContents.length-1;
theTabContents.reverse();

do {
	if (theTabContents[i].className=="t_content on") {
		theTabContents[i].className="t_content";
		break;
	}
}

while (i--)

theTabContents[whichOne].className="t_content on";
theTabs[whichOne].className="t t_on";

}

String.prototype.trim = function() {
// ----------
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};

function viewimage(viewer_type,parm_string,w,h,parent_type,parent_id) {
// ----------
popUpWindow=window.open('/utility/image_viewer.asp?image_type=' + viewer_type + '&w=' + w +'&h='+ h + '&' + parm_string + '&parent_type=' + parent_type + '&parent_id=' + parent_id ,viewer_type,'width='+w+',height='+(h+50)+',scrollbars=no,toolbars=no,resizable=no,menubar=no,status=no');
popUpWindow.focus();
}

function launch_viewer(viewer_type,parm_string) {
// ----------
var w=332;
var h=470;
popUpWindow=window.open('/utility/image_viewer.asp?image_type=' + viewer_type + '&w=' + w +'&h='+ h + '&' + parm_string ,'','width='+w+',height='+parseFloat(h+60)+',scrollbars=no,toolbars=no,resizable=no,menubar=no,status=no');
popUpWindow.focus();
}

function resizeMe(x){
// ----------
var theIframe = document.getElementById(x);
var theIframeHeight = Math.max(theIframe.contentWindow.document.body.scrollHeight, theIframe.contentWindow.document.documentElement.scrollHeight);
theIframe.style.height = theIframeHeight+"px";
theIframe.contentWindow.document.getElementById('iframe_content').style.visibility = "visible";
}

function viewPostImg(me) {
// ----------
popUpWindow=window.open(me,'img','resizable=yes,scrollbars=yes,menubar=no,status=yes');
popUpWindow.focus();
}

// ** FLASH HANDLING **

var flash_msg = '<p>You need Flash to view this, please download it <a href="http://www.adobe.com/go/getflashplayer" target="_blank">here</a>.</p>';

// EMBEDS THE FLASH
function embedFlash (url,w,h) {
// ----------
document.write('<object type="application/x-shockwave-flash" data="'+url+'" width="'+w+'" height="'+h+'" menu="false" wmode="transparent">');
document.write('<param name="movie" value="'+url+'">');
document.write('<param name="menu" value="false">');
document.write(flash_msg);
document.write('<\/object>');
}

// EMBEDS A YOUTUBE MODULE
function embedYouTube (url,w,h) {
// ----------
document.write('<object type="application/x-shockwave-flash" data="'+url+'" width="'+w+'" height="'+h+'" menu="false">');
document.write('<param name="movie" value="'+url+'">');
document.write('<param name="menu" value="false">');
document.write(flash_msg);
document.write('<\/object>');
}

// EMBEDS AN UPLOADED FLV
function embedVideo (url,w,h) {
// ----------
document.write('<object type="application/x-shockwave-flash" data="/params/video/player.swf?video='+url+'" width="'+w+'" height="'+h+'" menu="false">');
document.write('<param name="movie" value="/params/video/player.swf?video='+url+'">');
document.write('<param name="menu" value="false">');
document.write(flash_msg);
document.write('<\/object>');
}
