//class to serialize and unserialize in javascript (PHP compatible)
function openTab(systemid, tabid) 
{
	var oldtab  = eval("oldtab_" + systemid);
	if(tabid != oldtab)
	{
		//show the clicked tab
		showHideDiv(tabid,1);
		showHideDiv(oldtab,0);

		thediv = document.getElementById("tab" + tabid);
		thediv.style.display = 'none';

		thediv2 = document.getElementById("tabselected" + tabid);
		thediv2.style.display = 'block';

		thediv = document.getElementById("tab" + oldtab);
		thediv.style.display = 'block';

		thediv2 = document.getElementById("tabselected" + oldtab);
		thediv2.style.display = 'none';

		eval("oldtab_" + systemid + " = '" +  tabid + "';");
	}
}
function clearSelectBox(selectbox)
{
	if(selectbox)
	{
		len = selectbox.length;
		if(len > 2)
		{
			for(i=len;i>=2;i--)
			{
				selectbox.options[i] = null;
			}
		}	
	}
}

//call this function by adding this to your code 
//window.attachEvent("onload", pngTransparent);
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
{
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])

	if ((version >= 5.5) && (document.body.filters))
	{
		for(var i=0; i<document.images.length; i++)
		{
			var img = document.images[i]
			var imgName = img.src.toUpperCase()
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			{
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
				img.outerHTML = strNewHTML
				i = i-1
			}
		}
	}
}

function PHP_Serializer(UTF8) {
	
	/** public methods */
	function serialize(v) {
		// returns serialized var
		var	s;
		switch(v) {
			case null:
				s = "N;";
				break;
			default:
				s = this[this.__sc2s(v)] ? this[this.__sc2s(v)](v) : this[this.__sc2s(__o)](v);
				break;
		};
		return s;
	};
	
	function unserialize(s) {
		// returns unserialized var from a php serialized string
		__c = 0;
		__s = s;
		return this[__s.substr(__c, 1)]();
	};
	
	function stringBytes(s) {
		// returns the php lenght of a string (chars, not bytes)
		return s.length;
	};
	
	function stringBytesUTF8(s) {
		// returns the php lenght of a string (bytes, not chars)
		var 	c, b = 0,
			l = s.length;
		while(l) {
			c = s.charCodeAt(--l);
			b += (c < 128) ? 1 : ((c < 2048) ? 2 : ((c < 65536) ? 3 : 4));
		};
		return b;
	};
	
	/** private methods */
	function __sc2s(v) {
		return v.constructor.toString();
	};
	
	function __sc2sKonqueror(v) {
		var	f;
		switch(typeof(v)) {
			case ("string" || v instanceof String):
				f = "__sString";
				break;
			case ("number" || v instanceof Number):
				f = "__sNumber";
				break;
			case ("boolean" || v instanceof Boolean):
				f = "__sBoolean";
				break;
			case ("function" || v instanceof Function):
				f = "__sFunction";
				break;
			default:
				f = (v instanceof Array) ? "__sArray" : "__sObject";
				break;
		};
		return f;
	};
	
	function __sNConstructor(c) {
		return (c === "[function]" || c === "(Internal Function)");
	};
	
	function __sCommonAO(v) {
		var	b, n,
			a = 0,
			s = [];
		for(b in v) {
			n = v[b] == null;
			if(n || v[b].constructor != Function) {
				s[a] = [
					(!isNaN(b) && parseInt(b).toString() === b ? this.__sNumber(b) : this.__sString(b)),
					(n ? "N;" : this[this.__sc2s(v[b])] ? this[this.__sc2s(v[b])](v[b]) : this[this.__sc2s(__o)](v[b]))
				].join("");
				++a;
			};
		};
		return [a, s.join("")];
	};
	
	function __sBoolean(v) {
		return ["b:", (v ? "1" : "0"), ";"].join("");
	};
	
	function __sNumber(v) {
		var 	s = v.toString();
		return (s.indexOf(".") < 0 ? ["i:", s, ";"] : ["d:", s, ";"]).join("");
	};
	
	function __sString(v) {
		return ["s:", v.length, ":\"", v, "\";"].join("");
	};
	
	function __sStringUTF8(v) {
		return ["s:", this.stringBytes(v), ":\"", v, "\";"].join("");
	};
	
	function __sArray(v) {
		var 	s = this.__sCommonAO(v);
		return ["a:", s[0], ":{", s[1], "}"].join("");
	};
	
	function __sObject(v) {
		var 	o = this.__sc2s(v),
			n = o.substr(__n, (o.indexOf("(") - __n)),
			s = this.__sCommonAO(v);
		return ["O:", this.stringBytes(n), ":\"", n, "\":", s[0], ":{", s[1], "}"].join("");
	};
	
	function __sObjectIE7(v) {
		var 	o = this.__sc2s(v),
			n = o.substr(__n, (o.indexOf("(") - __n)),
			s = this.__sCommonAO(v);
		if(n.charAt(0) === " ")
			n = n.substring(1);
		return ["O:", this.stringBytes(n), ":\"", n, "\":", s[0], ":{", s[1], "}"].join("");
	};
	
	function __sObjectKonqueror(v) {
		var	o = v.constructor.toString(),
			n = this.__sNConstructor(o) ? "Object" : o.substr(__n, (o.indexOf("(") - __n)),
			s = this.__sCommonAO(v);
		return ["O:", this.stringBytes(n), ":\"", n, "\":", s[0], ":{", s[1], "}"].join("");
	};
	
	function __sFunction(v) {
		return "";
	};
	
	function __uCommonAO(tmp) {
		var	a, k;
		++__c;
		a = __s.indexOf(":", ++__c);
		k = parseInt(__s.substr(__c, (a - __c))) + 1;
		__c = a + 2;
		while(--k)
			tmp[this[__s.substr(__c, 1)]()] = this[__s.substr(__c, 1)]();
		return tmp;
	};

	function __uBoolean() {
		var	b = __s.substr((__c + 2), 1) === "1" ? true : false;
		__c += 4;
		return b;
	};
	
	function __uNumber() {
		var	sli = __s.indexOf(";", (__c + 1)) - 2,
			n = Number(__s.substr((__c + 2), (sli - __c)));
		__c = sli + 3;
		return n;
	};
	
	function __uStringUTF8() {
		var 	c, sls, sli, vls,
			pos = 0;
		__c += 2;
		sls = __s.substr(__c, (__s.indexOf(":", __c) - __c));
		sli = parseInt(sls);
		vls = sls = __c + sls.length + 2;
		while(sli) {
			c = __s.charCodeAt(vls);
			pos += (c < 128) ? 1 : ((c < 2048) ? 2 : ((c < 65536) ? 3 : 4));
			++vls;
			if(pos === sli)
				sli = 0;
		};
		pos = (vls - sls);
		__c = sls + pos + 2;
		return __s.substr(sls, pos);
	};
	
	function __uString() {
		var 	sls, sli;
		__c += 2;
		sls = __s.substr(__c, (__s.indexOf(":", __c) - __c));
		sli = parseInt(sls);
		sls = __c + sls.length + 2;
		__c = sls + sli + 2;
		return __s.substr(sls, sli);
	};
	
	function __uArray() {
		var	a = this.__uCommonAO([]);
		++__c;
		return a;
	};
	
	function __uObject() {
		var 	tmp = ["s", __s.substr(++__c, (__s.indexOf(":", (__c + 3)) - __c))].join(""),
			a = tmp.indexOf("\""),
			l = tmp.length - 2,
			o = tmp.substr((a + 1), (l - a));
		if(eval(["typeof(", o, ") === 'undefined'"].join("")))
			eval(["function ", o, "(){};"].join(""));
		__c += l;
		eval(["tmp = this.__uCommonAO(new ", o, "());"].join(""));
		++__c;
		return tmp;
	};
	
	function __uNull() {
		__c += 2;
		return null;
	};
	
	function __constructorCutLength() {
		function ie7bugCheck(){};
		var	o1 = new ie7bugCheck(),
			o2 = new Object(),
			c1 = __sc2s(o1),
			c2 = __sc2s(o2);
		if(c1.charAt(0) !== c2.charAt(0))
			__ie7 = true;
		return (__ie7 || c2.indexOf("(") !== 16) ? 9 : 10;
	};
	
	/** private variables */
	var 	__c = 0,
		__ie7 = false,
		__b = __sNConstructor(__c.constructor.toString()),
		__n = __b ? 9 : __constructorCutLength(),
		__s = "",
		__a = [],
		__o = {},
		__f = function(){};
	
	/** public prototypes */
	PHP_Serializer.prototype.serialize = serialize;
	PHP_Serializer.prototype.unserialize = unserialize;
	PHP_Serializer.prototype.stringBytes = UTF8 ? stringBytesUTF8 : stringBytes;
	
	/** serialize: private prototypes */
	if(__b) { // Konqueror / Safari prototypes
		PHP_Serializer.prototype.__sc2s = __sc2sKonqueror;
		PHP_Serializer.prototype.__sNConstructor = __sNConstructor;
		PHP_Serializer.prototype.__sCommonAO = __sCommonAO;
		PHP_Serializer.prototype[__sc2sKonqueror(__b)] = __sBoolean;
		PHP_Serializer.prototype.__sNumber = 
		PHP_Serializer.prototype[__sc2sKonqueror(__n)] = __sNumber;
		PHP_Serializer.prototype.__sString = PHP_Serializer.prototype[__sc2sKonqueror(__s)] = UTF8 ? __sStringUTF8 : __sString;
		PHP_Serializer.prototype[__sc2sKonqueror(__a)] = __sArray;
		PHP_Serializer.prototype[__sc2sKonqueror(__o)] = __sObjectKonqueror;
		PHP_Serializer.prototype[__sc2sKonqueror(__f)] = __sFunction;
	}
	else { // FireFox, IE, Opera prototypes
		PHP_Serializer.prototype.__sc2s = __sc2s;
		PHP_Serializer.prototype.__sCommonAO = __sCommonAO;
		PHP_Serializer.prototype[__sc2s(__b)] = __sBoolean;
		PHP_Serializer.prototype.__sNumber = 
		PHP_Serializer.prototype[__sc2s(__n)] = __sNumber;
		PHP_Serializer.prototype.__sString = PHP_Serializer.prototype[__sc2s(__s)] = UTF8 ? __sStringUTF8 : __sString;
		PHP_Serializer.prototype[__sc2s(__a)] = __sArray;
		PHP_Serializer.prototype[__sc2s(__o)] = __ie7 ? __sObjectIE7 : __sObject;
		PHP_Serializer.prototype[__sc2s(__f)] = __sFunction;
	};
	
	/** unserialize: private prototypes */
	PHP_Serializer.prototype.__uCommonAO = __uCommonAO;
	PHP_Serializer.prototype.b = __uBoolean;
	PHP_Serializer.prototype.i =
	PHP_Serializer.prototype.d = __uNumber;
	PHP_Serializer.prototype.s = UTF8 ? __uStringUTF8 : __uString;
	PHP_Serializer.prototype.a = __uArray;
	PHP_Serializer.prototype.O = __uObject;
	PHP_Serializer.prototype.N = __uNull;
};

function base64_encode(input) 
{
	var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	var output = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;

	do {
	chr1 = input.charCodeAt(i++);
	chr2 = input.charCodeAt(i++);
	chr3 = input.charCodeAt(i++);

	enc1 = chr1 >> 2;
	enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
	enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
	enc4 = chr3 & 63;

	if (isNaN(chr2)) {
	enc3 = enc4 = 64;
	} else if (isNaN(chr3)) {
	enc4 = 64;
	}

	output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
	keyStr.charAt(enc3) + keyStr.charAt(enc4);
	} while (i < input.length);

	return output;
}

function base64_decode(input) 
{
	var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	var output = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;

	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do 
	{
		enc1 = keyStr.indexOf(input.charAt(i++));
		enc2 = keyStr.indexOf(input.charAt(i++));
		enc3 = keyStr.indexOf(input.charAt(i++));
		enc4 = keyStr.indexOf(input.charAt(i++));

		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;

		output = output + String.fromCharCode(chr1);

		if (enc3 != 64) {
			output = output + String.fromCharCode(chr2);
		}
		if (enc4 != 64) {
			output = output + String.fromCharCode(chr3);
		}
	} while (i < input.length);

	return output;
}
function renderFieldLength(field, divid)
{
	thestring = new String(field.value);
	document.getElementById(divid).innerHTML = thestring.length;

}
function goToLocation(thefield)
{
	str = new String(thefield.value); 

	if(str.match(/^page:/i))
	{
		url = str.replace(/page\:/,"");
		alert(url);
		openWin(url, "newwindow", 600,550);
	}	
	else if(str.match(/^external:/i))
	{
		url = str.replace(/external\:/,"");
		openWin(url, "newwindow", 800,550);
	}	
	else
	{
		window.location = str; 
	}	

}

function showHelp(help_link)
{
	var obj = help_link[help_link.selectedIndex].value;
	if(obj != '')
	{
		var options = "";

		//var help_page = 'wysiwygVideos/EditorVideoTutorials/'+ obj +'.html';
		var help_page = 'wysiwyg_help.php?type='+ obj;
		options="top=0,left=0,width=800,height=600,status=yes,";
		options += "resizable=yes,scrollbars=yes,menubar=no,location=no";

		helpwin = window.open(help_page, 'Editor_Help', options);
		helpwin.focus();
	}	
}


function useEditor(Form, Field, w, h, applyandsave)
{   
	var file = 'wysiwyg.php?form='+ Form +'&field='+ Field +'&applyandsave=' + applyandsave;
	details="top=0,left=0,width="+w+",height="+h+",status=yes,";
    details += "resizable=yes,scrollbars=yes,menubar=no,location=no";


	myWin = window.open(file, 'editwin', details);
	myWin.focus();

	// myWin.document.forms['EditForm'].elements['Editor'].value = info;
	// myWin.document.forms['EditForm'].elements['Editor'].value = document.forms[Form].elements[Field].value;
}
function openScrollWin(file,winname, w, h)
{	
	var myWin;
	details="top=0,left=0,width="+w+",height="+h+",status=no,";
	details += "resizable=yes,scrollbars=yes,menubar=no,location=no";
	myWin = window.open(file, winname, details);
	myWin.focus();
}

function openWin(file,winname, w, h)
{
	details="top=0,left=0,width="+w+",height="+h+",status=no,";
	details += "resizable=yes,scrollbars=yes,menubar=no,location=no";

	myWin = window.open(file, winname, details);
	myWin.focus();
}

function openSecWin(file,winname, w, h)
{
    var myWin;
    details="top=0,left=0,width="+w+",height="+h+",status=yes,";
    details += "resizable=yes,scrollbars=yes,menubar=no,location=no";

    myWin = window.open(file, winname, details);
    myWin.focus();
}


function toggleDiv(tagname)
{
	obj = document.getElementById(tagname);
	if(obj.style.display == 'block')
	{
		obj.style.display = 'none';
	}
	else if(obj.style.display ==  'none')
	{
		obj.style.display = 'block';
	}
	else if(obj.style.diplay == null || obj.style.display == '')
	{
		obj.style.display = 'none';
	}
}
function showHideDiv(tagname, showhide)
{
    if (showhide == 1)
    {
        //document.all[tagname].style.display = "block"
		obj = document.getElementById(tagname);
		if(obj)
			obj.style.display='block';
    }

    if (showhide == 0)
    {
        //document.all[tagname].style.display = "none"
		obj = document.getElementById(tagname);
		if(obj)
			obj.style.display='none';
    }

}

function showHideSpan(tagname, showhide)
{
    if (showhide == 1)
    {
        obj = document.getElementById(tagname);
        if(obj)
            obj.style.display='inline';
    }

    if (showhide == 0)
    {
        obj = document.getElementById(tagname);
        if(obj)
            obj.style.display='none';
    }

}


function maskVariable(thefield)
{
    strobj = new String(thefield.value);
    value = new String (strobj.replace(/[^\w]*/g, ""));

	thefield.value = value;


}
function maskZipCode(thefield)
{
    strobj = new String(thefield.value);
    value = new String (strobj.replace(/\D*/g, ""));

    if(value.length > 5)
    {
        zip5 = value.substr(0,5);
        zip4 = value.substr(5,4);

        newvalue = zip5 + "-";
        newvalue = newvalue + zip4;

        thefield.value = newvalue;
    }
    else
    {
        thefield.value = value;
    }


}

function maskDecimal(thefield, limit)
{
    strobj = new String(thefield.value);
    newvalue = new String (strobj.replace(/[^\d\.]*/g, ""));
	if(newvalue.length > limit)
		value = newvalue.substr(0,limit);
	else
		value = newvalue;
		
    thefield.value = value;
}

function maskAlphaNumeric(thefield, limit)
{
    strobj = new String(thefield.value);
    newvalue = new String (strobj.replace(/[^\w-]*/g, ""));
	if(newvalue.length > limit)
		value = newvalue.substr(0,limit);
	else
		value = newvalue;
		
    thefield.value = value;
}
function maskNumber(thefield, limit)
{
    strobj = new String(thefield.value);
    newvalue = new String (strobj.replace(/\D*/g, ""));
	if(newvalue.length > limit)
		value = newvalue.substr(0,limit);
	else
		value = newvalue;
		
    thefield.value = value;
}

function maskDate(thefield)
{
	strobj = new String(thefield.value);
	value = new String (strobj.replace(/\D*/g, ""));

	if(value.length > 2)
	{
		month = value.substr(0,2);
		day = value.substr(2,2);

		newvalue = month + "-";
		newvalue = newvalue + day;

		if(value.length > 4)
		{
			year = value.substr(4,4);
			newvalue = newvalue + "-" + year;
		}

		thefield.value = newvalue;
	}
	else
	{
		thefield.value = value;
	}
}

function maskPhoneNumber(thefield, format)
{
	if(format == null)
	{
		strobj = new String(thefield.value);
		value = new String (strobj.replace(/\D*/g, ""));

		if(value.length > 3)
		{
			areacode = value.substr(0,3);
			n3 = value.substr(3,3);

			newvalue = areacode + ".";
			newvalue = newvalue + n3;

			if(value.length > 6)
			{
				n4 = value.substr(6,4);
				newvalue = newvalue + "." + n4;
			}

			thefield.value = newvalue;
		}
		else
		{
			thefield.value = value;
		}
	}
	else if(format == "australia")
	{
		
//		strobj = new String(thefield.value);
//		value = new String (strobj.replace(/\D*/g, ""));

/*		if(value.length > 2)
		{
			areacode = value.substr(0,2);
			n3 = value.substr(2,4);

			newvalue = areacode + ".";
			newvalue = newvalue + n3;

			if(value.length > 6)
			{
				n4 = value.substr(6,4);
				newvalue = newvalue + "." + n4;
			}

			thefield.value = newvalue;
		}
		else
		{
			thefield.value = value;
		}
		*/
	}
}

// Returns TRUE if a valid Email Address.
function checkEmailAddress(email)
{
    var re = '^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$';
    var result;

    result = email.search(re);
    if(result == -1)
        return false;
    else
        return true;
}

function maskHexNumber(thefield)
{
	strobj = new String(thefield.value);
	value = new String (strobj.replace(/[^0-9abcdefABCDEF]*/g, ""));

	if(value.length > 6)		
	{
		hex= value.substr(0,6);
		thefield.value = hex;
	}
	else
	{
		thefield.value = value;
	}
}
// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
	begin = dc.indexOf(prefix);
	if (begin != 0) return null;
	} else
	begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
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";
	}
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)
		date.setTime(date.getTime() - skew);
}

function runSP()
{
	showHideDiv("clubworksite", 0);
}

function FlashVersion(src, width, height, bgcolor, version)
{
	//DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision);

	hasRightVersion = DetectFlashVer(version, 0, 0);
	if(hasRightVersion)
	{
		str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ width +'" height="'+ height +'">';
		str += '<param name="movie" value="'+ src +'" />';
		if(bgcolor != "")
		{
			str += '<param name="bgcolor" value="'+ bgcolor +'" />';
		}	
		str += '<param name="quality" value="high" />';
		str += '<param name="wmode" value="transparent">';
		str += '<embed src="'+ src +'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'"></embed>';
		str += '</object>';
		document.write(str);
	}
	else
	{
		if(width > 200)
			w = width;
		else
			w = 200;

		if(height > 200)
			h = height;
		else
			h = 200;

		str = '<div class=content align=left style="background-color: white; width: ' + w + 'px; height: ' + h + 'px; border: 1px black solid; padding: 4px;"><img src="images/flashlogo.gif" border=0 style="padding: 0 4px 4px 0;" align=left>You are currently running ' + flash_current_version + '.  <a href="http://www.macromedia.com/go/getflash/" target="_new" style="color:blue;">Click here to upgrade your of Flash</a>.</div>';
		document.write(str);
	}
}

function Flash(src, width, height, bgcolor)
{
	str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ width +'" height="'+ height +'">';
	str += '<param name="movie" value="'+ src +'" />';
	if(bgcolor != "")
	{
		str += '<param name="bgcolor" value="'+ bgcolor +'" />';
	}	
	str += '<param name="quality" value="high" />';
	str += '<param name="wmode" value="transparent">';
	str += '<embed src="'+ src +'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'"></embed>';
	str += '</object>';
	document.write(str);
}
function includeJavaScript(url, scriptid)
{
   var e = document.createElement("script");
	e.src = url;
	e.type="text/javascript";
	e.id= scriptid;//"imscript";
	document.getElementsByTagName("head")[0].appendChild(e);
	
}
function getWindowSize()
{
	size = new Array(2);
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName=="Netscape") {
			size[0] = window.innerWidth;
			size[1] = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			size[0] = document.body.offsetWidth;
			size[1] = document.body.offsetHeight;
		}
		return size;
	}
}

function getImageType(src)
{
	str = new String(src);

	if(str.match(/jpg/i))
		return "jpg";
	else if(str.match(/jpe/i))
		return "jpg";
	else if(str.match(/jpeg/i))
		return "jpg";
	else if(str.match(/gif/i))
		return "gif";
	else if(str.match(/png/i))
		return "png";
	else
		return -1;
		
}
function innerHTML(div, content)
{
	obj = document.getElementById(div);
	if(obj != null)
	{
		obj.innerHTML = content;
	}
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}       

String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}   

String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

Array.prototype.find = function(searchStr) {
		var returnArray = false;
	for (loop_var_ii=0; loop_var_ii<this.length; loop_var_ii++) {
		if (typeof(searchStr) == 'function') {
		if (searchStr.test(this[loop_var_ii])) {
			if (!returnArray) { returnArray = [] }
				returnArray.push(i);
			}
		} else {
		if (this[loop_var_ii]===searchStr) {
		if (!returnArray) { returnArray = [] }
		returnArray.push(loop_var_ii);
		}
	}
	}
	return returnArray;
} 

function hidePageSubManagerMenu()
{
	if(document.getElementById('pageSubManagerMenu'))
	{
		var smm = document.getElementById('pageSubManagerMenu');
		smm.style.display = 'none';
		var smm = document.getElementById('pageManagerMenu');
		smm.style.marginBottom = "5px";
	}
}

function writePageSubManagerMenu(html)
{
	if(document.getElementById('pageSubManagerMenu'))
	{
		var smm = document.getElementById('pageSubManagerMenu');
		smm.style.display = 'block';
		smm.innerHTML = html;
	}
}

function getFormFields(theform)
{
	if(theform)
	{
		var buffer = new Array(theform.elements.length);
		str = "";

		for(i=0;i<theform.elements.length;i++)
		{
			buffer[i] = new Array(4);
			buffer[i]["Name"] = theform.elements[i].name;
			buffer[i]["Type"] = theform.elements[i].type;
			buffer[i]["Value"] = theform.elements[i].value;
			buffer[i]["Object"] = theform.elements[i];
		}
		return buffer;
	}	

	return false;
}


var global_link_calendar_css_included = 0;
function renderLinkCalendar(DivContainerId, Month, Year, CallBackFunction, CloseWin, Opener)
{
	//style should be included in host file, however if not, it will auto add
	//the css file
	if(global_link_calendar_css_included == 0)
	{
		var CSSFile = 'css/linkcalendar.css';
		var v_css  = document.createElement('link');
		v_css.rel = 'stylesheet'
		v_css.type = 'text/css';
		v_css.href = CSSFile;
		document.getElementsByTagName('head')[0].appendChild(v_css);
		global_link_calendar_css_included = 1;
	}

	if(CloseWin == undefined)
		CloseWin  = 0;
	if(Opener == undefined)
		Opener = 1;
	if(CallBackFunction == undefined)
		CallBackFunction = "startDate";

	var function_str;

	//set the function string
	if(Opener == 1)
		function_str = "parent.opener." + CallBackFunction;
	else	
		function_str = CallBackFunction; 


	var ndpm = new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31);
	var mname = new Array("","Jan","Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	var dow = new Array("", "S", "M", "T", "W", "R", "F", "S");

	var refday = 2;
	var refyear = 1996;
	var difyear = Year - refyear;
	var rem;
	var i = 0;

	//figure out the first day of the year
	for (i = 0; i < difyear; i++)
	//var do_width = getElementWidth(DivContainerId);
	//var do_width = getElementWidth(DivContainerId);
	//var do_width = getElementWidth(DivContainerId);
  	{
		refyear++;
  		rem = refyear % 4;
  		if (rem == 1) { refday = refday + 2; }
		else { refday++; }
		if (refday > 7){ refday = refday - 7; }
 	}

	//compute first days for all the months
	var FirstDay = new Array();
	var temp;

	FirstDay[1] = refday;
	temp = (31 % 7) + FirstDay[1];
	if (temp > 7){temp = temp - 7;}

	FirstDay[2]  = temp;
	if ((Year % 4) == 0){
		ndpm[2] = 29;
		temp = (29 % 7) + FirstDay[2];
	}
	else{temp = (28 % 7) + FirstDay[2];}
	if (temp > 7){temp = temp - 7;}

	FirstDay[3]  = temp;
	temp = (31 % 7) + FirstDay[3];
	if (temp > 7){temp = temp - 7;}

	FirstDay[4]  = temp;
	temp = (30 % 7) + FirstDay[4];
	if (temp > 7){temp = temp - 7;}
	
	FirstDay[5]  = temp;
	temp = (31 % 7) + FirstDay[5];
	if (temp > 7){temp = temp - 7;}
	
	FirstDay[6]  = temp;
	temp = (30 % 7) + FirstDay[6];
	if (temp > 7)	{temp = temp - 7;}
	
	FirstDay[7]  = temp;
	temp = (31 % 7) + FirstDay[7];
	if (temp > 7){temp = temp - 7;}
	
	FirstDay[8]  = temp;
	temp = (31 % 7) + FirstDay[8];
	if (temp > 7){temp = temp - 7; }
	
	FirstDay[9]  = temp;
	temp = (30 % 7) + FirstDay[9];
	if (temp > 7){temp = temp - 7;}
	
	FirstDay[10]  = temp;
	temp = (31 % 7) + FirstDay[10];
	if (temp > 7){temp = temp - 7;}
	
	FirstDay[11]  = temp;
	temp = (30 % 7) + FirstDay[11];
	if (temp > 7){temp = temp - 7; }

	FirstDay[12] = temp;

	//counter var
	var numdays = 1;

	var html = "";

	var dateObj = new Date();
	var today_month = dateObj.getMonth() + 1;
	var today_day = dateObj.getDate();
	var today_year = dateObj.getFullYear();


	var dMonth = parseInt(Month,10)
	var dYear = parseInt(Year,10)
	
	var nextyear = (dMonth == 12) ? (dYear + 1) : (dYear);
	var nextmonth = (dMonth == 12) ? (1) : (dMonth + 1);
	var prevyear = (dMonth == 1) ? (dYear - 1) : (dYear);
	var prevmonth = (dMonth == 1) ? (12) : (dMonth - 1);


	// alert(navigator.appVersion);
	var ie6 = ((navigator.appVersion.indexOf('MSIE') >= 0) && (navigator.appVersion.indexOf('6.0') >= 0));
	if(ie6)
		html += '<iframe src="javascript:void(0)" scrolling="no" frameborder="0" style="position: absolute; margin: 0; padding: 0; width: 206px; height: 400px; filter: alpha(opacity = 0);"></iframe>';
	html += "<div id='linkCalendar'>";
		html += "<div id='linkCalendarContainer'>";
			html += "<div id='linkCalendarTopContainer'>";
				html += "<a href=\"javascript:renderLinkCalendar('"+DivContainerId+"', "+ prevmonth +", "+ prevyear +", '"+ CallBackFunction +"',"+ CloseWin +","+ Opener+");\" class='linkCalendarButton' id='linkCalendarLeftButton'>&laquo;</a>";
				html += "<div id='linkCalendarHeader'>";
					html += mname[Month] + " - " + Year; 
				html += "</div>"; //linkCalendaerHeader
				html += "<a href=\"javascript:renderLinkCalendar('"+DivContainerId+"', "+ nextmonth +", "+ nextyear +",'" + CallBackFunction +"',"+ CloseWin+","+ Opener+");\" class='linkCalendarButton' id='linkCalendarRightButton'>&raquo;</a>";
				html += "<div style='clear: both;'><!-- --></div>";
			html += "</div>";	

			html += "<div id='linkCalendarContent'>" ;
				//html += "<div id='linkCalendarContent2'>";
				/* RENDER Days of Week */
				html += "<div class='linkCalendarWeek'><ul>";
					for(i=1;i<8;i++)
					{
						html += "<li><a class='linkCalendarDay lcdHeader' href='javascript:null(void);'>" + dow[i] + "</a></li>";
					}	
				html += "</ul></div>"; //linkCalendarWeek
				html += "<div style='clear: both;'><!-- --></div>"; //clearfix
				/* RENDER Row of Days */
				var do_class = "";
				for(d=0;d<6;d++)
				{
					html += "<div class='linkCalendarWeek'><ul>";
					for(i=1;i<8;i++)
					{
						if(d == 0 && i < FirstDay[Month])
						{
							html += "<li><a href='javascript:null(void);' class='linkCalendarDay'>&nbsp</a></li>";
						}	
						else if(numdays < ndpm[Month] + 1 )
						{
							if(today_month == dMonth && today_year == dYear && today_day == numdays)
								do_class = " today";// add space for seperator
							else	
								do_class = "";

							if(CloseWin == 1)
								html += "<li><a class='linkCalendarDay"+ do_class +"' href=\"javascript:" + function_str + "(" + Month + "," + numdays + "," + Year +"); showHideDiv('"+DivContainerId +"',0);\">" + numdays + "</a></li>";
							else	
								html += "<li><a class='linkCalendarDay"+ do_class +"' href=\"javascript:" + function_str + "(" + Month + "," + numdays + "," + Year +");\">" + numdays + "</a></li>";
							numdays++;
						}
					}	
					html += "</ul></div>"; //linkCalendarWeek
					html += "<div style='clear: both;'><!-- --></div>"; //clearfix
				}	
				//html += "</div>"; //linkCalendarContent2
			html += "</div>"; //linkCalendarContent
		html += "</div>"; //linkCalenderContainer	
	html += "</div>";	


	var divObj = document.getElementById(DivContainerId);
	divObj.innerHTML = html;


}

var pp_prompt_timeout = null;
function dialog(title,html,auto_close) {
    if(auto_close == null || auto_close == undefined)
        auto_close = true;
    var str = '';
    var dh = jQuery(window).height();
    str += '<div id="pp-prompt" style="visibility: hidden; position: fixed; _position: absolute; z-index: 300000001; top: 0; left: 0; margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;">';
        str += '<div id="pp-prompt-BG" style="position: fixed; z-index: 99; top: 0; left: 0; width: 100%; opacity: 0.3; filter: alpha(opacity=30); background-color: #000; height:100%;"></div>';
        str += '<div id="pp-prompt-1" style="position: fixed; _position: absolute; z-index: 100; top: 0; left: 50%; margin-left: -275px; width: 576px; background-color: #FFF; -moz-box-shadow: 0 10px 100px #000000; overflow: hidden;">';
            // str += '<div id="pp-prompt-A" style="position: absolute; z-index: 1; top: 0; left: 0; width: 550px; -moz-box-shadow: 0 0 100px #666; -webkit-box-shadow: 0 0 100px #666; opacity: 0.85; filter: alpha(opacity=85); background-color: #FFF;"></div>';
            str += '<div id="pp-prompt-C" style="position: relative; z-index: 2; margin: 0; padding: 30px 15px; width: 546px; overflow: hidden;">';
                str += '<div id="pp-prompt-control" style="position: absolute; z-index: 3; top: 15px; right: 15px; text-align: right;">';
                    str += '<a href="javascript:;" class="sub pp-prompt-close" style="padding: 3px; border: 1px solid #DDD; text-decoration: none; font-weight: bold; font-size: 12px;">Close</a>';
                str += '</div>';
                if(title)
                    str += '<h1 style="margin: 0 0 15px;" class="header">'+title+'</h1>';
                if(html)
                    str += html;
            str += '</div>';
        str += '</div>';
    str += '</div>';

    if(jQuery('#pp-prompt').length == 0) {
        jQuery('body').append(str);
        jQuery('.pp-prompt-close,#pp-prompt-BG').click(function() {
            dialog_close();
        });

        if(jQuery('#pp-prompt-C').length) {
            var h = jQuery('#pp-prompt-C').height();
            var pl = jQuery('#pp-prompt-C').css('padding-top');
            var pr = jQuery('#pp-prompt-C').css('padding-bottom');
            if(pl)
                pl = parseInt(pl);
            if(pr)
                pr = parseInt(pr);
            var th = h+pl+pr;
            jQuery('#pp-prompt').height(dh);
            setTimeout(function() {
                h = jQuery('#pp-prompt-C').height();
                if(h > dh) {
                    jQuery('#pp-prompt-1').height(dh-20);

                    var w = jQuery('#pp-prompt-1').outerWidth();
                    jQuery('#pp-prompt-1').width(w-16);

                    var wc = jQuery('#pp-prompt-C').outerWidth();
                    jQuery('#pp-prompt-C').width(wc-16-pl-pr);

                    jQuery('#pp-prompt-1').css({'overflow':'scroll'});
                }
            },200);

            /*
            jQuery('#pp-prompt-A').height(th);
            jQuery('#pp-prompt-1').height(th);
            */

            var ie = navigator.appVersion.indexOf('MSIE 6');
            if(ie != -1) {
                jQuery(window).resize(function() {
                    var dh = jQuery(window).height();
                    if(dh) {
                        if(jQuery('#pp-prompt').length)
                            jQuery('#pp-prompt').height(dh);
                        if(jQuery('#pp-prompt-BG').length)
                            jQuery('#pp-prompt-BG').height(dh);
                    }
                });
                jQuery(window).scroll(function() {
                    var st = jQuery(this).scrollTop();
                    if(jQuery('#pp-prompt').length)
                        jQuery('#pp-prompt').css({'top':st+'px'});
                });
            }

            jQuery('#pp-prompt-1').css({'top':'-'+th+'px'});

            jQuery('#pp-prompt').css({'visibility':'visible'});
            /*
            jQuery('#pp-prompt').animate({'opacity':'1.0'});
            */
            jQuery('#pp-prompt-1').animate({'top':'0'},'slow',function() {
                if(auto_close)
                    pp_prompt_timeout = setTimeout('dialog_close()',3000);
            });
        }
    }
}

function dialog_close() {
    if(pp_prompt_timeout)
        clearTimeout(pp_prompt_timeout);

    if(jQuery('#pp-prompt').length) {
        var h = jQuery('#pp-prompt-C').height();
        var pl = jQuery('#pp-prompt-C').css('padding-top');
        var pr = jQuery('#pp-prompt-C').css('padding-bottom');
        if(pl)
            pl = parseInt(pl);
        if(pr)
            pr = parseInt(pr);
        var th = h+pl+pr;
        jQuery('#pp-prompt-1').animate({'top':'-'+th+'px'},function() {
            jQuery('#pp-prompt').remove();
        });
        /*
        jQuery('#pp-prompt').animate({'opacity':'0'},'slow',function() {
        });
        */
    }
}
function jQueryScrubInput(input) { 
	if(input && input != '') {
		jQuery(document).ready(function() {
			jQuery(input).bind('click focus blur',function(e) {
				var _dv = jQuery(this)[0].defaultValue;
				var _v  = jQuery(this).val();
				if(e.type == 'blur') {
					if(_v == '')
						jQuery(this).val(_dv);
				}
				else {
					if(_v == _dv)
						jQuery(this).val('');
				}
			});
		});
	}
}

