//::pop-up window (QuickPoint™)
var win = null;
function QPWin(){
w = 670;
h = 490;
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable=yes,toolbar=no,location=no,status=yes,menubar=yes';
win = window.open('https://rataassociates.com/qp/login.asp','QuickPointWindow',settings)
if(win.window.focus){win.window.focus();}
}

//::pop-up window (complete settings)
//ex -> onClick="CiPopWin('./pageurl.asp','WindowName','500','300','no','no','no','no','no','no');return false"
var win = null;
function CiPopWin(mypage,myname,w,h,scroll,resize,toolbar,loc,status,menubar){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+',toolbar='+toolbar+',location='+loc+',status='+status+',menubar='+menubar;
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}

//::Spell Check
function spellCheck() {
	try {
		var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
		tmpis.CheckAllLinkedDocuments(document);
	}
	catch(exception) {
		if(exception.number==-2146827859) {
			if (confirm("ieSpell™ Spell Check Component was not detected.\n\nWould you like to download this freeware component now?"))
				window.open("http://www.iespell.com/download.php","DLieSpell","");
		}
		else
			alert("Error Loading ieSpell™: Exception " + exception.number);
	}
}

//::highlight table cells
var isIE4 = false;
function CheckBrowser(){
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.charAt(0) >= 4) {isIE4 = true;}
}
function hOvr(src,clrOver){
	if (!src.contains(event.fromElement)) {src.style.cursor = 'default'; src.bgColor = clrOver;}
}
function hOut(src,clrIn){
	if (!src.contains(event.toElement)) {src.style.cursor = 'default'; src.bgColor = clrIn;}
}

//Usage: onmouseover="mOvr(this,'#A6CAF0');" onmouseout="mOut(this,'#F0F0F0');"

function ViewNewsletter(pg){
	//NavWin(pg,"EmailWindow",600,360); return false
	window.open(pg,"NewsletterWindow");
}

//::Swap Div
function SwapDiv(val,div){
	switch (val) {
		case "Yes":
			document.getElementById(div).style.visibility = "visible";
			break;
		case "No": case "":
			document.getElementById(div).style.visibility = "hidden";
			break;
	}
}

//::E-Mail Fields Show/Hide
function EmailFieldsShowHide(){
	if (document.getElementById('AddEmail1').style.display=="none"){
		document.getElementById('AddEmail1').style.display="block";
		document.getElementById('AddEmail2').style.display="block";
	}
	else{
		document.getElementById('AddEmail1').style.display="none";
		document.getElementById('AddEmail2').style.display="none";
	}
}

//::Show Other...
function ShowOther(val){
	switch (val) {
		case "3":
			document.getElementById('subjectother').style.display = "block";
			break;
		default:
			document.getElementById('subjectother').style.display = "none";
			break;
	}
}

//::Select/UnSelect List with Checkbox Function
//	ex. SelectCheckList(document.forms[0].LIST,document.forms[0].CHECKBOX);
function SelectCheckList(lst,chk) {
	for (i = 0; i < lst.length; i++) {
		lst.options[i].selected = chk.checked;
	}
}

//::Numeric Mask Function
//ex. onKeyDown="javascript:return NumericMask(this,'(###) ###-####');"
function NumericMask(objText,strMask) {
	key = event.keyCode;
	FilterNum = FilterStrip(objText.value,strMask);
	if (key==9)	{
		return true;
	}
	else if (key==8&&FilterNum.length!=0) {
		FilterNum = FilterNum.substring(0,FilterNum.length-1);
	}
	else if (((key>47 && key<58)||(key>95 && key<106)) && FilterNum.length<FilterMax(strMask)) {
		if (key>95 && key<106) {
			key = (key-48);
		}
		FilterNum=FilterNum+String.fromCharCode(key);
	}
	var FilterFinal='';
	for (FilterStep = 0; FilterStep < strMask.length; FilterStep++) {
		if (strMask.charAt(FilterStep)=='#') {
			if (FilterNum.length!=0) {
				FilterFinal = FilterFinal + FilterNum.charAt(0);
				FilterNum = FilterNum.substring(1,FilterNum.length);
			}
			else {
				FilterFinal = FilterFinal + "";
			}
		}
		else if (strMask.charAt(FilterStep)!='#') {
			FilterFinal = FilterFinal + strMask.charAt(FilterStep);
		}
	}
	objText.value = FilterFinal;
	return false;
}
function FilterStrip(FilterTemp,strMask) {
	strMask = ReplaceAll(strMask,'#','');
	for (FilterStep = 0; FilterStep < strMask.length++; FilterStep++) {
		FilterTemp = ReplaceAll(FilterTemp,strMask.substring(FilterStep,FilterStep+1),'');
	}
	return FilterTemp;
}
function FilterMax(strMask) {
	FilterTemp = strMask;
	for (FilterStep = 0; FilterStep < (strMask.length+1); FilterStep++) {
		if (strMask.charAt(FilterStep)!='#') {
			FilterTemp = ReplaceAll(FilterTemp,strMask.charAt(FilterStep),'');
		}
	}
	return FilterTemp.length;
}

//::Replace All Function
function ReplaceAll(strFull,strOld,strNew) {
	var strLength = strFull.length, txtLength = strOld.length;
	if ((strLength == 0) || (txtLength == 0)) return strFull;
	var i = strFull.indexOf(strOld);
	if ((!i) && (strOld != strFull.substring(0,txtLength))) return strFull;
	if (i == -1) return strFull;
	var strReplace = strFull.substring(0,i) + strNew;
	if (i+txtLength < strLength) strReplace += ReplaceAll(strFull.substring(i+txtLength,strLength),strOld,strNew);
	return strReplace;
}

//::Trim String Function
function Trim(str){
	str = str.replace(/\s+/,'');
	str = str.replace(/\s+$/,'');
	return str;
}

//::IsNumeric Function
function IsNumeric(val){
	for (i=0; i<val.length; i++){
		if (isNaN(val.charAt(i))){
			return false;
		}
	}
	return true;
}

//::Valid E-Mail
function ValidEmail(str){
	AccPos = str.indexOf('@');
	AccStr = str.substr(0,AccPos);
	AccLen = AccStr.length;
	DomPos = str.lastIndexOf('.');
	DomStr = str.substr(AccPos+1,(DomPos-AccPos)-1);
	DomLen = DomStr.length;
	ExtPos = DomPos + 1;
	ExtLen = str.length - ExtPos;
	ExtStr = str.substr(ExtPos,ExtLen);
	if(	   (AccPos != -1)
		&& (DomPos != -1)
		&& (AccLen >= 2)
		&& (DomLen >= 2)
		&& (ExtLen >= 2)
		&& (ExtLen <= 3)){
		return true;
	}
	else{return false}
}

//::Valid Telephone
function ValidTelephone(str){
	str = Trim(str);
	str = str.replace("(","");
	str = str.replace(")","");
	str = str.replace(".","");
	str = str.replace(".","");
	str = str.replace("-","");
	str = str.replace("-","");
	str = str.replace(" ","");
	strLen = str.length;
	if((strLen == 10 || strLen == 7) && IsNumeric(str)){
		return true;
	}
	else{
		return false;
	}
}

//::Valid Password
function ValidPassword(p1,p2){
	if (p1 != "" && p2 != ""){
		if (p1 == p2) {
			return true;
		}else{
			return false;
		}
	}else{
		return false;
	}
}

//::check if radio or checkbox items are selected
function CheckSelected(arr){
	if(arr.length > 0){
		for(var index = 0; index < arr.length; index++){
			if(arr[index].checked){
				return true;
				break;
			}
		}
	}
	else{
		if(arr.checked){
			return true;
		}
		else{
			return false;
		}
	}
}

//::Validate Quick Point Registration Form
function ValidateQuickPointRegistration() {
	missinginfo = "";
	var objForm = document.frm;

	if (objForm.companyname.value == "") {
	missinginfo += "\n     »  Company Name";
	}
	if (objForm.address.value == "") {
	missinginfo += "\n     »  Address";
	}
	if (objForm.city.value == "") {
	missinginfo += "\n     »  City";
	}
	if (objForm.state.value == "") {
	missinginfo += "\n     »  State";
	}
	if (objForm.zipcode.value == "") {
	missinginfo += "\n     »  Zip Code";
	}
	if (objForm.firstname.value == "") {
	missinginfo += "\n     »  Company: First Name";
	}
	if (objForm.lastname.value == "") {
	missinginfo += "\n     »  Company: Last Name";
	}
	if (!ValidTelephone(objForm.phone.value)) {
	missinginfo += "\n     »  Company: Phone Number";
	}
	if (!ValidEmail(objForm.email.value)) {
	missinginfo += "\n     »  Company: E-Mail Address";
	}

	if (objForm.b_firstname.value == "") {
	missinginfo += "\n     »  Billing: First Name";
	}
	if (objForm.b_lastname.value == "") {
	missinginfo += "\n     »  Billing: Last Name";
	}
	if (objForm.b_address.value == "") {
	missinginfo += "\n     »  Billing: Address";
	}
	if (objForm.b_city.value == "") {
	missinginfo += "\n     »  Billing: City";
	}
	if (objForm.b_state.value == "") {
	missinginfo += "\n     »  Billing: State";
	}
	if (objForm.b_zipcode.value == "") {
	missinginfo += "\n     »  Billing: Zip Code";
	}
	if (!ValidTelephone(objForm.b_phone.value)) {
	missinginfo += "\n     »  Billing: Phone Number";
	}
	if (!ValidEmail(objForm.b_email.value)) {
	missinginfo += "\n     »  Billing: E-Mail Address";
	}

	if (!ValidPassword(objForm.pw1.value,objForm.pw2.value)) {
	missinginfo += "\n     »  Password (does not match)";
	}
	if (!CheckSelected(objForm.acceptterms)) {
	missinginfo += "\n     »  Terms and Conditions (must read and accept)";
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Validate Advisory Board Form
function ValidateAdvisoryBoard() {
	missinginfo = "";
	var objForm = document.frm;

	if (objForm.firstname.value == "") {
	missinginfo += "\n     »  First Name";
	}
	if (objForm.lastname.value == "") {
	missinginfo += "\n     »  Last Name";
	}
	if (objForm.company.value == "") {
	missinginfo += "\n     »  Company";
	}
	if (objForm.title.value == "") {
	missinginfo += "\n     »  Title";
	}
	if (objForm.address.value == "") {
	missinginfo += "\n     »  Address";
	}
	if (objForm.city.value == "") {
	missinginfo += "\n     »  City";
	}
	if (objForm.state.value == "") {
	missinginfo += "\n     »  State";
	}
	if (objForm.zip.value == "") {
	missinginfo += "\n     »  Zip Code";
	}
	if (!ValidTelephone(objForm.phone.value)) {
	missinginfo += "\n     »  Phone Number";
	}
	if (!ValidEmail(objForm.email.value)) {
	missinginfo += "\n     »  E-Mail Address";
	}

	for(var j = 0; j < objForm.advisoryboard.length; j++){
		if (objForm.advisoryboard[j].value == "") {
			missinginfo += "\n     »  Please rank ALL advisory board options";
			break;
		}
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Validate Live Meeting Registration Form
function ValidateLiveMeetingRegistration() {
	missinginfo = "";
	var objForm = document.frm;

	if (objForm.firstname.value == "") {
	missinginfo += "\n     »  First Name";
	}
	if (objForm.lastname.value == "") {
	missinginfo += "\n     »  Last Name";
	}
	if (objForm.companyname.value == "") {
	missinginfo += "\n     »  Company Name";
	}
	if (objForm.address.value == "") {
	missinginfo += "\n     »  Address";
	}
	if (objForm.city.value == "") {
	missinginfo += "\n     »  City";
	}
	if (objForm.state.value == "") {
	missinginfo += "\n     »  State";
	}
	if (objForm.zipcode.value == "") {
	missinginfo += "\n     »  Zip Code";
	}
	if (!ValidTelephone(objForm.phonenumber.value)) {
	missinginfo += "\n     »  Phone Number";
	}
	if (!ValidEmail(objForm.email.value)) {
	missinginfo += "\n     »  E-Mail Address";
	}
	if (!ValidPassword(objForm.password.value,objForm.passwordconfirm.value)) {
	missinginfo += "\n     »  Password (does not match)";
	}
	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Validate Live Meeting Password Request Form
function ValidateLiveMeetingPasswordRequest() {
	missinginfo = "";
	var objForm = document.frm;

	if (!ValidEmail(objForm.email.value)) {
	missinginfo += "\n     »  E-Mail Address";
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Validate Subscribe Form (Newsletter)
function ValidateSubscribe() {
	missinginfo = "";
	var objForm = document.frmSubscribe;

	if (objForm.firstname.value == "") {
	missinginfo += "\n     »  First Name";
	}
	if (objForm.lastname.value == "") {
	missinginfo += "\n     »  Last Name";
	}
	if (!ValidEmail(objForm.emailaddress1.value)) {
	missinginfo += "\n     »  E-Mail Address";
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Validate Unsubscribe Form (Newsletter)
function ValidateUnsubscribe() {
	missinginfo = "";
	var objForm = document.frmUnsubscribe;

	if (!ValidEmail(objForm.emailaddress2.value)) {
	missinginfo += "\n     »  E-Mail Address";
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Validate Contact Form
function ValidateContact() {
	missinginfo = "";
	var objForm = document.frm;

	if (objForm.name.value == "") {
	missinginfo += "\n     »  Name";
	}
	if (!ValidEmail(objForm.email.value)) {
	missinginfo += "\n     »  E-Mail Address";
	}
	if (objForm.questions.value == "") {
	missinginfo += "\n     »  Questions / Comments";
	}
	if (objForm.captcha.value == "") {
	missinginfo += "\n     »  Security Code";
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Validate Case Studies
function ValidateCaseStudies() {
	missinginfo = "";
	var objForm = document.frm;

	if (objForm.institutionname.value == "") {
	missinginfo += "\n     »  Institution Name";
	}
	if (objForm.institutioncontact.value == "") {
	missinginfo += "\n     »  Institution Contact";
	}
	if (objForm.subject.value == "") {
	missinginfo += "\n     »  Subject";
	}
	if (objForm.subject.value == "3") {
		if (objForm.subjectother.value == "") {
		missinginfo += "\n     »  Subject (Other...)";
		}
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Validate Conference Registration Form
function ValidateConferenceRegistration() {
	missinginfo = "";
	var objForm = document.frm;

	if (objForm.firstname.value == "") {
	missinginfo += "\n     »  First Name";
	}
	if (objForm.lastname.value == "") {
	missinginfo += "\n     »  Last Name";
	}
	if (objForm.title.value == "") {
	missinginfo += "\n     »  Title";
	}
	if (objForm.company.value == "") {
	missinginfo += "\n     »  Company";
	}
	if (objForm.address.value == "") {
	missinginfo += "\n     »  Address";
	}
	if (objForm.city.value == "") {
	missinginfo += "\n     »  City";
	}
	if (objForm.state.value == "") {
	missinginfo += "\n     »  State";
	}
	if (objForm.zip.value == "") {
	missinginfo += "\n     »  Zip Code";
	}
	if (!ValidTelephone(objForm.telephone.value)) {
	missinginfo += "\n     »  Telephone";
	}
	if (!ValidEmail(objForm.email.value)) {
	missinginfo += "\n     »  E-Mail Address";
	}
	if (objForm.travelpartners.value == "") {
	missinginfo += "\n     »  Number of Travel Partners";
	}
	if (objForm.children.value == "") {
	missinginfo += "\n     »  Number of Children";
	}
	if (objForm.tshirtsize.value == "") {
	missinginfo += "\n     »  Your T-Shirt Size";
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Validate Download Request Form
function ValidateDownloadRequest() {
	missinginfo = "";
	var objForm = document.frm;

	if (objForm.firstname.value == "") {
	missinginfo += "\n     »  First Name";
	}
	if (objForm.lastname.value == "") {
	missinginfo += "\n     »  Last Name";
	}
	if (objForm.companyname.value == "") {
	missinginfo += "\n     »  Company Name";
	}
	if (!ValidEmail(objForm.email.value)) {
	missinginfo += "\n     »  E-Mail Address";
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Validate Newsletter
function ValidateNewsletter(btn) {
	missinginfo = "";
	var objForm = document.frm;

	if (objForm.recipientemails.value == "") {
	missinginfo += "\n     »  Recipient(s)";
	}

	if (objForm.additionalemails.value != "") {
		emailStr = RemoveSpaces(objForm.additionalemails.value);
		if (emailStr.indexOf(",") > 0) {
			emailArr = emailStr.split(",");
			for (i=0; i<emailArr.length; i++) {
				if (!ValidEmail(emailArr[i])) {
					missinginfo += "\n     »  E-Mail Address(es):  One of the e-mails in the list is formatted incorrectly.";
					missinginfo += "\n\n\t\t[" + emailArr[i] + "]";
					break;
				}
			}
		}
		else if (emailStr.indexOf(";") > 0) {
			emailArr = emailStr.split(";");
			for (i=0; i<emailArr.length; i++) {
				if (!ValidEmail(emailArr[i])) {
					missinginfo += "\n     »  E-Mail Address(es):  One of the e-mails in the list is formatted incorrectly.";
					missinginfo += "\n\n\t\t[" + emailArr[i] + "]";
					break;
				}
			}
		}
		else {
			if (!ValidEmail(objForm.additionalemails.value)) {
				missinginfo += "\n     »  E-Mail Address(es):  E-Mail is formatted incorrectly.";
			}
		}
	}
	if (objForm.subject.value == "") {
	missinginfo += "\n     »  Subject";
	}
	if (objForm.content.value == "") {
	missinginfo += "\n     »  E-Mail Message";
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else {
		if (btn == "sendemails") {
			if (confirm("» Are you sure you want to send out the e-mails?")) {
				if (Save()) {
					return true;
				}
				else {
					return false;
				}
			}
			else {
				return false;
			}
		}
		else {
			if (Save()) {
				return true;
			}
			else {
				return false;
			}
		}
	}
}

//::Validate Admin: Newsletter Subscription Form
function ValidateAdminNewsletterSubscription() {
	missinginfo = "";
	var objForm = document.frm;

	if (objForm.company.value == "") {
	missinginfo += "\n     »  Company";
	}
	if (!ValidEmail(objForm.emailaddress.value)) {
	missinginfo += "\n     »  E-Mail Address";
	}

	if (missinginfo != "") {
	missinginfo = "The following information was entered incorrectly:\n" +
	missinginfo + "\n\nPlease re-enter the information and try again...";
	alert(missinginfo);
	return false;
	}
	else return true;
}

//::Remove All Blank Spaces
function RemoveSpaces(sStr) {
	var s = "";
	for (var i = 0; i < sStr.length; i++) {
		if (sStr.charAt(i) != " ") s += sStr.charAt(i);
	}
	return s;
}

//::JS Calendar
function showCalendar(str_target, str_datetime) {
	var arr_months = ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"];
	var week_days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
	var n_weekstart = 0; //day week starts from (normally 0 or 1)
	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt4(str_datetime));
	var dt_prev_month = new Date(dt_datetime);
	window.onerror=ignore
	function ignore(){return true}
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
	if (dt_datetime.getMonth()%12 != (dt_prev_month.getMonth()+1)%12) {
		dt_prev_month.setMonth(dt_datetime.getMonth());
		dt_prev_month.setDate(0);
	}
	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	if ((dt_datetime.getMonth() + 1)%12 != dt_next_month.getMonth()%12)
		dt_next_month.setDate(0);
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	var str_buffer = new String (
		"<HTML>"+
		"<HEAD>"+
		"	<TITLE>[calendar]</TITLE>"+
		"<style>"+
		"a.{color:#AOAOA4;text-decoration:none}"+
		"a:link{color:#AOAOA4;}"+
		"a:active{color:#A0A0A4;}"+
		"a:visited{color:#A0A0A4;}"+
		"a:hover{color:#FFFFFF; text-decoration:none}"+
		"</style>"+
		"<SCR"+
		"IPT>"+
		"var isIE4 = false;"+
		"function CheckBrowser(){ "+
		"	if (navigator.appName == \"Microsoft Internet Explorer\" && navigator.appVersion.charAt(0) >= 4) { isIE4 = true; }"+
		"}"+
		"function mOvr(src,clrOver){"+
		"	if (!src.contains(event.fromElement)) { src.style.cursor = 'hand'; src.bgColor = clrOver;}"+
		"}"+
		"function mOut(src,clrIn){"+
		"	if (!src.contains(event.toElement)) { src.style.cursor = 'default'; src.bgColor = clrIn;}"+
		"}"+
		"</SCR"+
		"IPT>"+
		"</HEAD>"+
		"<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" TOPMARGIN=3 LEFTMARGIN=3 MARGINWIDTH=3 MARGINHEIGHT=3 STYLE='border:0;'>"+
			"<TABLE BORDER=0 BGCOLOR=\"#000000\" CELLSPACING=1 CELLPADDING=0 WIDTH=\"100%\" >"+
				"<TR>"+
					"<TD WIDTH=29 BGCOLOR=\"#1C4BA0\" HEIGHT=15 style=\"cursor:hand\" onClick=\"javascript:window.opener.showCalendar('"+
				str_target+"', '"+ dt2dtstr4(dt_prev_month)+"');\">"+
						"<P ALIGN=CENTER><a href=\"javascript:window.opener.showCalendar('"+
				str_target+"', '"+ dt2dtstr4(dt_prev_month)+"');\"><FONT COLOR=\"#FFFFFF\" SIZE=\"-2\" FACE=\"Verdana\">«</FONT></P></a>"+
					"</TD>"+
					"<TD COLSPAN=5 BGCOLOR=\"#1C4BA0\" style=\"cursor:default\">"+
						"<P ALIGN=CENTER><B><FONT COLOR=\"#FFFFFF\" SIZE=\"-2\" FACE=\"Verdana\">"+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</FONT></B></P>"+
					"</TD>"+
					"<TD WIDTH=28 BGCOLOR=\"#1C4BA0\" style=\"cursor:hand\" onClick=\"javascript:window.opener.showCalendar('"
				+str_target+"', '"+dt2dtstr4(dt_next_month)+"');\">"+
						"<P ALIGN=CENTER><a href=\"javascript:window.opener.showCalendar('"
				+str_target+"', '"+dt2dtstr4(dt_next_month)+"');\"><FONT COLOR=\"#FFFFFF\" SIZE=\"-2\" FACE=\"Verdana\">»</FONT></P></a>"+
					"</TD>"+
				"</TR>"+
				"<TR>"
	);
	var dt_current_day = new Date(dt_firstday);
	//weekdays titles
	for (var n=0; n<7; n++)
		str_buffer += "<TD WIDTH=29 BGCOLOR=\"#D2D2D2\" HEIGHT=15 style=\"cursor:default\"><P ALIGN=CENTER><B><FONT SIZE=\"-2\" FACE=\"Verdana\">"+
		week_days[(n_weekstart+n)%7]+"</FONT></B></P></TD>";
	//calendar table
	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		//row header
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if ((dt_current_day.getMonth() == dt_datetime.getMonth()) && (dt_current_day.getDate() == dt_datetime.getDate()))
					// print current date
					str_buffer += "	<td bgcolor=\"#0099FF\" align=\"right\" HEIGHT=15 onmouseover=\"mOvr(this,'#A6CAF0');\" onmouseout=\"mOut(this,'#0099FF');\" onClick=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr4(dt_current_day)+"'; window.close();\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#F0F0F0\" align=\"right\" HEIGHT=15 onmouseover=\"mOvr(this,'#A6CAF0');\" onmouseout=\"mOut(this,'#F0F0F0');\" onClick=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr4(dt_current_day)+"'; window.close();\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\" HEIGHT=15 onmouseover=\"mOvr(this,'#A6CAF0');\" onmouseout=\"mOut(this,'white');\" onClick=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr4(dt_current_day)+"'; window.close();\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr4(dt_current_day)+"'; window.close();\">"+
					"<font color=\"black\" face=\"verdana\" size=\"-2\">";
				else
					// print days of other months
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr4(dt_current_day)+"'; window.close();\">"+
					"<font color=\"#A0A0A4\" face=\"verdana\" size=\"-2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		//row footer
		str_buffer += "</tr>\n";
	}
	//calendar footer
	str_buffer +=
		"</table>\n" +
		"</tr>\n</td>\n</table>\n" +
		"</body>\n" +
		"</html>\n";
	var w = 200;
	var h = 131;
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var vWinCal = window.open("", "Calendar",
		"width="+w+",height="+h+",status=no,resizable=no,top="+TopPosition+",left="+LeftPosition);
	vWinCal.opener = self;
	vWinCal.focus();
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();
}
//::Valid Date Function
function str2dt4(dt) {
	var dt1 = /(\d+)\/(\d+)\/(\d+)$/;
	var dt2 = /(\d+)\-(\d+)\-(\d+)$/;
	var dt3 = /(\d+)\.(\d+)\.(\d+)$/;
	if (dt1.exec(dt) ||
		dt2.exec(dt) ||
		dt3.exec(dt)) {
		return (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2));
	}
	else{
		return alert("Invalid Date format: "+ dt);
	}
}
function dt2dtstr4 (dt_datetime) {
	return (new String (
			(dt_datetime.getMonth()+1)+"/"+dt_datetime.getDate()+"/"+dt_datetime.getFullYear()));
}
//::Examble of HTML usage
//<a href="javascript:showCalendar('document.frmDate.date', document.frmDate.date.value);">
//<script language="JavaScript" src="calendar.js"></script>

//::Confirm Delete
function del(url,msg){
	if (confirm(msg)) {
		document.location.href = url;
	}else{}
}

//::Copy Registration Fields Function
function CopyRegistrationFields(){
	var objForm = document.frm;
	if(objForm.copy.checked){
		objForm.b_firstname.value = objForm.firstname.value;
		objForm.b_lastname.value = objForm.lastname.value;
		objForm.b_title.value = objForm.title.value;
		objForm.b_address.value = objForm.address.value;
		objForm.b_city.value = objForm.city.value;
		objForm.b_state.value = objForm.state.value;
		objForm.b_zipcode.value = objForm.zipcode.value;
		objForm.b_phone.value = objForm.phone.value;
		objForm.b_fax.value = objForm.fax.value;
		objForm.b_email.value = objForm.email.value;
	}
	else{
		objForm.b_firstname.value = "";
		objForm.b_lastname.value = "";
		objForm.b_title.value = "";
		objForm.b_address.value = "";
		objForm.b_city.value = "";
		objForm.b_state.value = "";
		objForm.b_zipcode.value = "";
		objForm.b_phone.value = "";
		objForm.b_fax.value = "";
		objForm.b_email.value = "";
	}
}

//::Block Character
//ex.	onKeypress="BlockChar();"
function BlockChar(){
	if (event.keyCode==32) {
		event.returnValue = false;
	}
}

//::Check All Function
//ex.	onClick="CheckAll(document.forms[0].chkFields);"
var checkflag = "false";
function CheckAll(field){
	if(field.length == null){
		if (checkflag == "false") {
			field.checked = true;
			checkflag = "true";
		}
		else{
			field.checked = false;
			checkflag = "false";
		}
	}
	else{
		if (checkflag == "false") {
			for (i = 0; i < field.length; i++){
			field[i].checked = true;}
			checkflag = "true";
		}
		else{
			for (i = 0; i < field.length; i++){
			field[i].checked = false; }
			checkflag = "false";
		}
	}
}

//::Ad Rotator
var intTotalAds = 3;
var intDelaySec = 5;

function AdRotator(arrStart){
	if(arrStart == null){
		arrStart = Math.floor(Math.random()*(intTotalAds+1));
	}

	if(arrStart >= intTotalAds){
		arrStart = 1;
	}
	else{
		arrStart++;
	}

	for(i=1; i<=intTotalAds; i++){
		document.getElementById('ad'+i).style.display = "none";
	}

	document.getElementById('ad'+arrStart).style.display = "block";

	adTimeoutId = setTimeout("AdRotator("+arrStart+");", intDelaySec*1000);
}

//::Pause Ad Rotator
function PauseAdRotator(status){
	if(status == "pause"){
		clearTimeout(adTimeoutId);
	}
	else if(status == "continue"){
		arrStart = Math.floor(Math.random()*(intTotalAds+1));
		adTimeoutId = setTimeout("AdRotator("+arrStart+");", intDelaySec*1000);
	}
}
