﻿// SIMPLE BROWSER DETECTION
var ua = navigator.userAgent.toLowerCase();
var isW3C = (document.getElementById) ? true : false
var isAll = (document.all) ? true : false
var isSafari = false;
if (ua.indexOf("safari") != -1) { isSafari = true; }


// PRELOADING MOUSEOVER IMAGES
function createObject(imgName,imgSrc) {
	if (loadingFlag) {
		eval(imgName + ' = new Image()');
		eval(imgName + '.src = "' + imgSrc + '"');
		return imgName;
	}
}


// MOUSEOVER IMAGE SWITCHING
function changeImage(layer,imgName,imgObj) {
	if (preloadFlag) {
		if (isW3C) {
			document.getElementById(imgName).src = eval(imgObj+'.src');
		} else {
			document.images[imgName].src = eval(imgObj+'.src');
		}
	}
}


// POPUP WINDOW
function spawn(desktopURL,windowName,width,height) {
	window.open(desktopURL,windowName,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width='+width+',height='+height+',resizable=0');
}

function spawnEvil(desktopURL,windowName,width,height) {
	if (isSafari) {
		newheight = height + 20;
		window.open(desktopURL,windowName,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,width='+width+',height='+(height+17)+',resizable=0');
	} else {
		window.open(desktopURL,windowName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width='+width+',height='+height+',resizable=0');
	}
}


// REMOVES THE LINK BORDER IN IE4+, NS6
function unblur() {
	this.blur();
}

function getLinksToBlur() {
	if ((isW3C) || (isAll)) {
		if (isW3C) {
			links = document.getElementsByTagName("a");
		} else {
			links = document.all.tags("a");
		}
		for(i=0; i<links.length; i++) {
			links[i].onfocus = unblur
		}
	}
}


// SWITCHES BUTTON CLASS
function bSwitcher(thisId,param) {
	if (isW3C) {
		d = document.getElementById(thisId);
		if (param == "off") {
			d.style.backgroundColor='#7EC700';
		} else if (param == "coff") {
			d.style.backgroundColor='#EC8C8C';
		} else if (param == "tgoff") {
			d.style.backgroundColor='#a2c35a';
		} else if (param == "troff") {
			d.style.backgroundColor='#cca251';
		} else {
			d.style.backgroundColor='#FFA800';
		}
	} else {
		d = document.all[thisId];
		d.className = 'btn'+param;
	}
}


// SWITCHES BUTTON TEXT CLASS
function buttonTxtSwitcher(thisId,param) {
	if (isW3C) {
		d = document.getElementById(thisId);
		if (param == "off") {
			d.style.backgroundColor='#BCCF9D';
		} else {
			d.style.backgroundColor='#FFD82B';
		}
	} else {
		d = document.all[thisId];
		d.className = 'txtbtn'+param;
	}
}


// GENERIC CLASS SWITCHER
function cSwitcher(thisId,newClass) {
	if (isW3C) {
		d = document.getElementById(thisId);
		d.className = newClass;
	} else {
		d = document.all[thisId];
		d.className = newClass;
	}
}


// DOM / GET PROPERTY
function getIdProperty(id,property) {
	var styleObject = document.getElementById( id );
	if (styleObject != null) {
		styleObject = styleObject.style;
			if (styleObject[property]) {
				return styleObject[ property ];
			}
		}
	return (styleObject != null) ?
	styleObject[property] :
	null;
}


// DOM / SET PROPERTY
function setIdProperty(id,property,value) {
	var styleObject = document.getElementById( id );
	if (styleObject != null) {
		styleObject = styleObject.style;
		styleObject[ property ] = value;
	}
}


// HIDE AND SHOW LAYERS
function hide(id) {
	if (isW3C) {
		setIdProperty(id,"visibility","hidden");
	} else {
		document.all[id].style.visibility = "hidden";
	}
}

function show(id) {
	if (isW3C) {
		setIdProperty(id,"visibility","visible");
	} else { 
		document.all[id].style.visibility = "visible";
	}
}


// CHANGE DISPLAY VALUE FOR LAYERS
function switchDisplay(id,value) {
	if (isW3C) {
		setIdProperty(id,"display",value);
	} else {
		document.all[id].style.display = value;
	}
}


// RANDOM NUMBER GENERATOR
function randNum (num) {
	var now = new Date();
	var rand = Math.round(num * Math.cos(now.getTime()));
	if (rand < 0) rand = - rand; 
	if (rand == 0) rand++;
	return rand;
}


// ANTI-SPAM
function antispam(name,domain) {
	document.location = "mailto:" + name + "@" + domain;
}


// STATUS
function s(txt) {
	self.status = txt;
}


// FINDS THE POSITION OF AN ELEMENT
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
	

// REWRITE TEXT LAYER
function rwt(txt, id) {
	txt += "\n";
	if (isW3C) {
		d = document.getElementById(id);
		d.innerHTML = txt;
	} else {
		document.all[id].innerHTML = txt;
	}
}


// STANDARD INIT PAGE
function initPage() {
	loadingFlag = true;
	createObject('radiooff','/_img/generic/radio_off1.gif');
	createObject('radioon','/_img/generic/radio_on1.gif');
	createObject('checkoff','/_img/generic/check_off1.gif');
	createObject('checkon','/_img/generic/check_on1.gif');
	loadingFlag = false;
	preloadFlag = true;
	getLinksToBlur();
}

// STANDARD POPUP INIT PAGE
function initPopup() {
	loadingFlag = true;
	createObject('radiooff','/_img/generic/radio_off1.gif');
	createObject('radioon','/_img/generic/radio_on1.gif');
	createObject('checkoff','/_img/generic/check_off1.gif');
	createObject('checkon','/_img/generic/check_on1.gif');
	loadingFlag = false;
	preloadFlag = true;
	getLinksToBlur();
	top.window.focus();
}


// FAKE CHECKBOXES
function fakeCheck(fn,thisId) {
	if (fn.value == "yes") {
		changeImage(null,thisId+'check','checkoff');
		fn.value = "no";
	} else {
		changeImage(null,thisId+'check','checkon');
		fn.value = "yes";
	}
}

// FAKE RADIO BUTTONS
function fakeRadio(fnObj,val) {
	fnObj = eval(fnObj);
	changeImage(null,"radio" + fnObj.value,"radiooff");
	changeImage(null,"radio" + val,"radioon");
	fnObj.value = val;
}

// CHANGE ISSUE DESC
var shownIssueDesc = 1;
function changeDesc() {
	if (shownIssueDesc == 1) {
		show('bissauthor');
		shownIssueDesc = 2;
	} else {
		hide('bissauthor');
		shownIssueDesc = 1;
	}
}

// REMOVED LEADING WHITESPACE
function LTrim(value) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// REMOVES ENDING WHITESPACE
function RTrim(value) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// REMOVEDS LEADING & ENDING WHITESPACE
function trim(value) {
	return LTrim(RTrim(value));
}

// EMAIL VALIDATION
function filterEmail(s)	{
	return s.search(/^\s*[\w\~\-\.]+\@[\w\~\-]+(\.[\w\~\-]+)+\s*$/g) >= 0;
}

// URL VALIDATION
function filterURL(s) {
	var reorg = "(ht|f)tp(s?)\:\/\/[a-zA-Z0-9\-\._]+(\.[a-zA-Z0-9\-\._]+){2,}(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+=&%\$#_]*)?"
  	var re = new RegExp(reorg);
  	if (s.match(re)) {
    	return true;
	} else {
    	return false;
  	}
}

// WORD VALIDATION
function filterCharacter(level,s) {
	var str_name = trim(s);
	switch (level) {
		// allow letter and number only
		case 0:
			var exp = /[^\w]/g;
			break;
		// allow letter, number and basic punct
		case 1:
			var exp = /[^\s\w\?\*\+\.\|\{\}\\\[\]\(\)\-!@#\$&_=;',:<>]/g;
			break;
	}
	if (str_name.search(exp) > -1) {
		return false;
	} else {
		return true;
	}
}

// DATE VALIDATION
function filterDate(y,m,d) {
	var source_date = new Date(y,m,d);
	if ((y != source_date.getFullYear()) || (m != source_date.getMonth()) || (d != source_date.getDate())) {
		return false;
	} else {
		return true;
	}
}

// VARIOUS ERROR MESSAGES
var str_msg_error = "There was a problem with your submission:\n";
var str_msg_loginerror = "There was a problem with your login:\n";
var str_msg_email_check = "- your email address is invalid.";
var str_msg_url_check = "- your link URL is invalid.";
var str_msg_url_empty = "- your link URL is empty.";
var str_msg_siteurl_check = "- your site URL is invalid.";
var str_msg_siteurl_empty = "- your site URL is empty.";
var str_msg_password_length = "- the password needs to be 4-16 characters.";
var str_msg_title_empty = "- please enter a title.";
var str_msg_patname_empty = "- please enter a name for the pattern.";
var str_msg_mmname_empty = "- please enter a name for your Matchmaker project.";
var str_msg_startdate_empty = "- please select a starting date.";
var str_msg_startdate_past = "- your starting date is in the past.";
var str_msg_startdate_enddate = "- your end date is before your starting date.";
var str_msg_startdate_invalid = "- your starting date is invalid.";
var str_msg_enddate_invalid = "- your end date is invalid.";
var str_msg_country_empty = "- please select a country.";
var str_msg_city_empty = "- please select a city.";
var str_msg_citynew_empty = "- please enter a new city.";
var str_msg_name_empty = "- please enter your name.";
var str_msg_email_empty = "- please enter your email address.";
var str_msg_category_empty = "- please choose a category.";
var str_msg_password_empty = "- please enter a password (4-16 chars).";
var str_msg_yourpassword_empty = "- please enter your password.";
var str_msg_desc_empty = "- please enter a description of ";
var str_msg_char = "- special characters (incl. quotes) are not permitted in ";
var str_msg_file_type = "- your file needs to be a GIF, JPG or PNG.";
var str_msg_file_type_gif = "- your file needs to be a GIF.";
var str_msg_file_empty = "- please choose a file.";
var str_msg_tos = "- please accept the Matchmaker Terms of Service.";


// EVENT CALENDAR SUBMISSION
function validateSubmitEvent() {
   	
   	fn = document.submitevent;
   	var strErrorMsg = '';
   	var dtToday = new Date();
   	var dtStartDate = new Date();
   	var dtEndDate = new Date();
   	var dtStartYear = fn.EventStartYear.options[fn.EventStartYear.selectedIndex].value;
   	var dtStartMonth = fn.EventStartMonth.options[fn.EventStartMonth.selectedIndex].value;
   	var dtStartDay = fn.EventStartDay.options[fn.EventStartDay.selectedIndex].value;
   	var dtEndYear = fn.EventEndYear.options[fn.EventEndYear.selectedIndex].value;
   	var dtEndMonth = fn.EventEndMonth.options[fn.EventEndMonth.selectedIndex].value;
   	var dtEndDay = fn.EventEndDay.options[fn.EventEndDay.selectedIndex].value;
   	dtStartDate.setFullYear(dtStartYear,(dtStartMonth - 1),dtStartDay);
   	
   	// event title
   	if (fn.EventTitle.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_title_empty + '\n';
   	} else if (!filterCharacter(1,fn.EventTitle.value)) {
   		strErrorMsg = strErrorMsg + str_msg_char + 'the title.\n';
   	}
   	
   	// start date
   	if (!filterDate(dtStartYear,(dtStartMonth - 1),dtStartDay)) {
   		strErrorMsg = strErrorMsg + str_msg_startdate_invalid + '\n';
   	}
   	if (dtStartDate < dtToday) {
   		strErrorMsg = strErrorMsg + str_msg_startdate_past + '\n';
   	}
   	
   	// end date (if used)
   	if ((dtEndYear > 0) || (dtEndMonth > 0) || (dtEndDay > 0)) {
   		dtEndDate.setFullYear(dtEndYear,(dtEndMonth - 1),dtEndDay);
   		if (!filterDate(dtEndYear,(dtEndMonth - 1),dtEndDay)) {
   			strErrorMsg = strErrorMsg + str_msg_enddate_invalid + '\n';
   		} else if (dtEndDate < dtStartDate) {
   			strErrorMsg = strErrorMsg + str_msg_startdate_enddate + '\n';
   		}
   	}
   	
   	// event country
   	if (fn.EventCountry.options[fn.EventCountry.selectedIndex].value == '') {
   		strErrorMsg = strErrorMsg + str_msg_country_empty + '\n';
   	}
   	if (fn.EventCountry.options[fn.EventCountry.selectedIndex].value != '6') {
   		try {
   			// event city
   			if (fn.EventCity.options[fn.EventCity.selectedIndex].value == '') {
   				strErrorMsg = strErrorMsg + str_msg_city_empty + '\n';
   			}
   			// event new city
   			if (fn.EventCity.options[fn.EventCity.selectedIndex].value == '0') {
   				if (fn.EventCityNew.value == '') {
   					strErrorMsg = strErrorMsg + str_msg_citynew_empty + '\n';
   				}
   			}
   			// event venue (if used)
   			if (fn.EventVenue.value != '') {
				if (!filterCharacter(1,fn.EventVenue.value)) {
   					strErrorMsg = strErrorMsg + str_msg_char + 'the event venue.\n';
   				}
			}
   		} catch(err) {
   			//
   		}
   	}
   	
   	// event url (if used)
   	if ((fn.EventUrl.value != '') && (fn.EventUrl.value != 'http://')) {
   		if (!filterURL(fn.EventUrl.value)) {
   			strErrorMsg = strErrorMsg + str_msg_url_check + '\n';
   		}
   	}
   	
   	// submitter name
   	if ((fn.EventSubmitter.value == '') || (fn.EventSubmitter.value == 'name')) {
   		strErrorMsg = strErrorMsg + str_msg_name_empty + '\n';
   	}
   	
   	// submitter email
   	if ((fn.EventSubmitterEmail.value == '') || (fn.EventSubmitterEmail.value == 'email')) {
   		strErrorMsg = strErrorMsg + str_msg_email_empty + '\n';
   	} else if (!filterEmail(fn.EventSubmitterEmail.value)) {
   		strErrorMsg = strErrorMsg + str_msg_email_check + '\n';
   	}
   	
   	// event description
   	if (fn.EventDesc.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_desc_empty + 'the event.\n';
   	}
   	
   	if (strErrorMsg != "") {
   		strErrorMsg = str_msg_error + strErrorMsg;
   		alert(strErrorMsg);
   		return false;
   	} else {
   		document.submitevent.submit();
   	}

}


// NEWS SEARCH
function validateNewsSearch() {
	document.searchForm.submit();
}


// LINK SUBMISSION (STEP 1)
function validateSubmitLink1() {

	fn = document.submitlink1;
   	var strErrorMsg = '';

	// link url
   	if ((fn.inURL.value == '') || (fn.inURL.value == 'http://')) {
   		strErrorMsg = strErrorMsg + str_msg_url_empty + '\n';
   	} else if (!filterURL(fn.inURL.value)) {
   		strErrorMsg = strErrorMsg + str_msg_url_check + '\n';
   	}
   	
   	if (strErrorMsg != "") {
   		strErrorMsg = str_msg_error + strErrorMsg;
   		alert(strErrorMsg);
   		return false;
   	} else {
   		document.submitlink1.submit();
   	}

}


// LINK SUBMISSION (STEP 2)
function validateSubmitLink2() {

	fn = document.submitlink2;
   	var strErrorMsg = '';

	// link url
   	if ((fn.inURL.value == '') || (fn.inURL.value == 'http://')) {
   		strErrorMsg = strErrorMsg + str_msg_url_empty + '\n';
   	} else if (!filterURL(fn.inURL.value)) {
   		strErrorMsg = strErrorMsg + str_msg_url_check + '\n';
   	}
   	
   	// link name (if used)
   	if (fn.linkName.value != '') {
   		if (!filterCharacter(1,fn.linkName.value)) {
   			strErrorMsg = strErrorMsg + str_msg_char + 'the link name.\n';
   		}
   	}

	// submitter email
   	if ((fn.Email.value == '') || (fn.Email.value == 'email')) {
   		strErrorMsg = strErrorMsg + str_msg_email_empty + '\n';
   	} else if (!filterEmail(fn.Email.value)) {
   		strErrorMsg = strErrorMsg + str_msg_email_check + '\n';
   	}
   	
   	// link description
   	if (fn.ShortDesc.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_desc_empty + 'the link.\n';
   	}
   	
   	if (strErrorMsg != "") {
   		strErrorMsg = str_msg_error + strErrorMsg;
   		alert(strErrorMsg);
   		return false;
   	} else {
   		document.submitlink2.submit();
   	}

}


// DESKTOP SUBMISSION
function validateSubmitDesktop() {

	fn = document.submitdesktop;
   	var strErrorMsg = '';
   	var sImageVal = document.getElementById("FILE1").value;
    var sImageType = sImageVal.substr(sImageVal.length-3,3).toLowerCase();
    
    // image file
    if (sImageVal = "") {
    	strErrorMsg = strErrorMsg + str_msg_file_empty + '\n';
    } else if ((sImageType != 'jpg') && (sImageType != 'gif') && (sImageType != 'peg') && (sImageType != 'png')) {
    	strErrorMsg = strErrorMsg + str_msg_file_type + '\n';
    }
    
    // submitter name
   	if (fn.desktopName.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_name_empty + '\n';
   	}
   	
   	// submitter email
   	if (fn.desktopEmail.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_email_empty + '\n';
   	} else if (!filterEmail(fn.desktopEmail.value)) {
   		strErrorMsg = strErrorMsg + str_msg_email_check + '\n';
   	}
   	
   	// site name (if used)
   	if (fn.desktopSite.value != '') {
   		if (!filterCharacter(1,fn.desktopSite.value)) {
   			strErrorMsg = strErrorMsg + str_msg_char + 'the site name.\n';
   		}
   	}
   	
   	// site url (if used)
   	if ((fn.desktopSiteUrl.value != '') && (fn.desktopSiteUrl.value != 'http://')) {
   		if (!filterURL(fn.desktopSiteUrl.value)) {
   			strErrorMsg = strErrorMsg + str_msg_siteurl_check + '\n';
   		}
   	}
   	
   	if (strErrorMsg != "") {
   		strErrorMsg = str_msg_error + strErrorMsg;
   		alert(strErrorMsg);
   		return false;
   	} else {
   		document.submitdesktop.submit();
   	}

}


// PATTERN SUBMISSION
function validateSubmitPattern() {

	fn = document.submitpattern;
   	var strErrorMsg = '';
   	var sImageVal = document.getElementById("FILE1").value;
    var sImageType = sImageVal.substr(sImageVal.length-3,3).toLowerCase();
    
    // image file
    if (sImageVal = "") {
    	strErrorMsg = strErrorMsg + str_msg_file_empty + '\n';
    } else if (sImageType != 'gif') {
    	strErrorMsg = strErrorMsg + str_msg_file_type_gif + '\n';
    }
    
    // pattern name
   	if (fn.patternname.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_patname_empty + '\n';
   	}
    
    // submitter name
   	if (fn.submittername.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_name_empty + '\n';
   	}
   	
   	// submitter email
   	if (fn.submitteremail.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_email_empty + '\n';
   	} else if (!filterEmail(fn.submitteremail.value)) {
   		strErrorMsg = strErrorMsg + str_msg_email_check + '\n';
   	}
   	
   	// site name (if used)
   	if (fn.submittersite.value != '') {
   		if (!filterCharacter(1,fn.submittersite.value)) {
   			strErrorMsg = strErrorMsg + str_msg_char + 'the site name.\n';
   		}
   	}
   	
   	// site url (if used)
   	if ((fn.submitterurl.value != '') && (fn.submitterurl.value != 'http://')) {
   		if (!filterURL(fn.submitterurl.value)) {
   			strErrorMsg = strErrorMsg + str_msg_siteurl_check + '\n';
   		}
   	}
   	
   	if (strErrorMsg != "") {
   		strErrorMsg = str_msg_error + strErrorMsg;
   		alert(strErrorMsg);
   		return false;
   	} else {
   		document.submitpattern.submit();
   	}

}


// MATCHMAKER LOGIN
function validateMMLogin() {
	
	fn = document.mmlogin;
   	var strErrorMsg = '';
   	
   	// login email
   	if (fn.mmemail.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_email_empty + '\n';
   	} else if (!filterEmail(fn.mmemail.value)) {
   		strErrorMsg = strErrorMsg + str_msg_email_check + '\n';
   	}
   	
   	// login password
   	if (fn.mmpassword.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_yourpassword_empty + '\n';
   	}
   	
   	if (strErrorMsg != "") {
   		strErrorMsg = str_msg_loginerror + strErrorMsg;
   		alert(strErrorMsg);
   		return false;
   	} else {
   		document.mmlogin.submit();
   	}

}


// MATCHMAKER SUBMISSION
function validateSubmitMM(type) {

	fn = document.submitproject;
   	var strErrorMsg = '';
   	var sImageVal = document.getElementById("FILE1").value;
    var sImageType = sImageVal.substr(sImageVal.length-3,3).toLowerCase();
    var state = fn.mmstate.value;
    var strPreview = '';
    
    // submitter name
   	if (fn.mmusername.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_name_empty + '\n';
   	}
   	
   	// submitter email
   	if (fn.mmuseremail.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_email_empty + '\n';
   	} else if (!filterEmail(fn.mmuseremail.value)) {
   		strErrorMsg = strErrorMsg + str_msg_email_check + '\n';
   	}
   	
   	// mm password
   	if (fn.mmpassword.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_password_empty + '\n';
   	} else if (fn.mmpassword.value.length < 4) {
   		strErrorMsg = strErrorMsg + str_msg_password_length + '\n';
   	}
   	
   	// mm category
   	if (document.getElementById("mmcategory").value == '') {
   		strErrorMsg = strErrorMsg + str_msg_category_empty + '\n';
   	}
   	
   	// mm name
   	if (fn.mmname.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_mmname_empty + '\n';
   	} else if (!filterCharacter(1,fn.mmname.value)) {
   		strErrorMsg = strErrorMsg + str_msg_char + 'the project name.\n';
   	}
   	
   	// mm site name (if used)
   	if (fn.mmsitename.value != '') {
   		if (!filterCharacter(1,fn.mmsitename.value)) {
   			strErrorMsg = strErrorMsg + str_msg_char + 'the site name.\n';
   		}
   	}
   	
   	// mm site url (if used)
   	if ((fn.mmsiteurl.value != '') && (fn.mmsiteurl.value != 'http://')) {
   		if (!filterURL(fn.mmsiteurl.value)) {
   			strErrorMsg = strErrorMsg + str_msg_siteurl_check + '\n';
   		}
   	}
   	
   	// mm description
   	if (fn.mmdesc.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_desc_empty + 'the project.\n';
   	}
   	
   	// mm people needed
   	if (fn.mmpeople.value == '') {
   		strErrorMsg = strErrorMsg + str_msg_desc_empty + 'the people needed.\n';
   	}
   	
   	// for new users
    if (state == "new") {
    	// image file
    	if (sImageVal = "") {
    		strErrorMsg = strErrorMsg + str_msg_file_empty + '\n';
    	} else if ((sImageType != 'jpg') && (sImageType != 'gif') && (sImageType != 'peg') && (sImageType != 'png')) {
    		strErrorMsg = strErrorMsg + str_msg_file_type + '\n';
    	}
    	// mm tos
    	if (fn.mmtos.value == 'no') {
   			strErrorMsg = strErrorMsg + str_msg_tos + '\n';
   		}
    } else {
    	if ((sImageVal != "") && (sImageType != 'jpg') && (sImageType != 'gif') && (sImageType != 'peg') && (sImageType != 'png')) {
    		strErrorMsg = strErrorMsg + str_msg_file_type + '\n';
    	}
    }
   	
   	if (strErrorMsg != "") {
   		strErrorMsg = str_msg_error + strErrorMsg;
   		alert(strErrorMsg);
   		return false;
   	} else {
   		if (type == 'post') {
   			document.submitproject.submit();
   		} else if (type == 'preview') {
   			strPreview = strPreview + "mmusername=" + escape(fn.mmusername.value);
   			strPreview = strPreview + "&mmuseremail=" + escape(fn.mmuseremail.value);
   			strPreview = strPreview + "&mmcategory=" + escape(document.getElementById("mmcategory").value);
   			strPreview = strPreview + "&mmname=" + escape(fn.mmname.value);
   			strPreview = strPreview + "&mmsitename=" + escape(fn.mmsitename.value);
   			strPreview = strPreview + "&mmsiteurl=" + escape(fn.mmsiteurl.value);
   			strPreview = strPreview + "&mmdesc=" + escape(fn.mmdesc.value);
   			strPreview = strPreview + "&mmpeople=" + escape(fn.mmpeople.value);
   			parent.f_item.location.replace('/sections/matchmaker/f_itempreview.aspx?' + strPreview);
   			return false;
   		}
   	}

}

// RESET ON DISPLAY FRONTPAGE FORM

function resetOndisplayForm() {
	fn = document.ondisplayform;
    fn.byname.value = "";
    fn.bydate.selectedIndex = 0;
    fn.byletter.selectedIndex = 0;
}


// WM SEND TO A FRIEND
function submitWM(opt) {
	noGo = false;
	alertMsg = "ERROR! Please fill out all the required fields ...";
	if (document.forms.sendwm.recipname.value+'' == '') noGo = true;
	if (document.forms.sendwm.sendname.value+'' == '') noGo = true;
	if (document.forms.sendwm.recipmail.value+'' == '') noGo = true;
	if (document.forms.sendwm.sendmail.value+'' == '') noGo = true;
	if (document.forms.sendwm.recipmail.value.indexOf("@") == -1) {
		alertMsg = "ERROR! Email address not valid ...";
		noGo = true;
	}
	if (document.forms.sendwm.sendmail.value.indexOf("@") == -1) {
		alertMsg = "ERROR! Email address not valid ...";
		noGo = true;
	}
	if (noGo) {
		alert(alertMsg);
		if (opt != 'button') {
			return false;
		}
	} else {
		document.forms.sendwm.submit();
	}
}

// STANDARD DELETE
function standardDelete(url) {
	if (confirm("Are you sure you want to delete this item?")) {
		document.location.href = url;
	}
}

function notop() {}