
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


 browserName = navigator.appName;
 browserVer = parseInt(navigator.appVersion);
  
 ns3up = (browserName == "Netscape" && browserVer >= 3);
 ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);
  
 function doPic(imgName) {
 	if (ns3up || ie4up) {
 	imgOn = ("" + imgName);
	 document.mainpic.src = imgOn;
    }
 }

function deleteItem(location) {
	var msg = "\nPlease confirm deletion...\n\n";
	if (confirm(msg)) {
		self.location.href=location;
	}else{
		return false;
	}
}


function confirmSubmit(location) {
	var msg = "\nAre you sure?\n\n";
	if (confirm(msg)) {
		self.location.href=location;
	}else{
		return false;
	}
}

function launchNewLink(location, element) {
	if (element.options[element.selectedIndex].value == "new") {
		self.location.href=location;
	}else{
		return false;
	}
}

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}	
	} 

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}


function check_email_only(f) { // f is the form (passed using the this keyword)
	//alert("yes");
	// check the first email address ( the exclamation means "not" )
	if(!check_email(f.email.value)){
		alert("Invalid email detected");
		// make sure the form is not submitted
		return false;
	} else {
		return true;
	}
}


function openWindow(url, name, w, h) {
	popupWin = window.open(url, name, 'toolbar=yes,menubar=yes,scrollbars=auto,resizable=yes,width='+w+',height='+h+',left=5,top=10');
}

//------- For Re-ordering Tools --------------------
function orderModule( down) {
	sl = document.fm.item.selectedIndex;
	if (sl != -1) {
		oText = document.fm.item.options[sl].text;
		oValue = document.fm.item.options[sl].value;
		 if (sl > 0 && down == 0) {
			  document.fm.item.options[sl].text = document.fm.item.options[sl-1].text;
			  document.fm.item.options[sl].value = document.fm.item.options[sl-1].value;
			  document.fm.item.options[sl-1].text = oText;
			  document.fm.item.options[sl-1].value = oValue;
			  document.fm.item.selectedIndex--;
		 } else if (sl < document.fm.item.length-1 && down == 1) {
			  document.fm.item.options[sl].text = document.fm.item.options[sl+1].text;
			 document.fm.item.options[sl].value = document.fm.item.options[sl+1].value;
			  document.fm.item.options[sl+1].text = oText;
			 document.fm.item.options[sl+1].value = oValue;
			  document.fm.item.selectedIndex++;
		 }
	} else {
	 	alert("Select a content area to move");
	}
return false;
}

function submitIt() {
	var msg = "\nAre you sure?\n\n";
	if (confirm(msg)) {
		val = "";
		for (i=0;i<document.fm.item.length;i++) {
 			if (i!=0) { val += ","; }
				val += document.fm.item.options[i].value;
			} 
		document.fm["items"].value = val;
		return true;
	}else{
		return false;
	}
}

function doSub() {
	val = "";
	for (i=0;i<document.fm.item.length;i++) {
 		if (i!=0) { val += ","; }
		val += document.fm.item.options[i].value;
	} 
	document.fm["items"].value = val;
	return true;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function useThisPhoto(form, photo_id) {
	alert(photo_id);
	form.photo_id.value = photo_id;
	return false;
}

function windowShade(obj) {
	if (document.getElementById) {
		var el = document.getElementById(obj);
		if ( el.style.display != "none" ) {
			el.style.display = 'none';
		} else {
			el.style.display = '';
		}
		
	}
}
function submitItemList() {
	val = "";
	for (i=0;i<document.fm.item.length;i++) {
 		if (i!=0) { val += ","; }
			val += document.fm.item.options[i].value;
		} 
	document.fm["items"].value = val;
	return true;
}

function submitItemList2() {
	val = "";
	for (i=0;i<document.fm.item2.length;i++) {
 		if (i!=0) { val += ","; }
			val += document.fm.item2.options[i].value;
		} 
	document.fm["items2"].value = val;
	return true;
}

function replacePage(url){
	self.location.replace(url);
	return true;
}

// Javascript Toolbox:
function hasOptions(obj){if(obj!=null && obj.options!=null){return true;}return false;}
function selectUnselectMatchingOptions(obj,regex,which,only){if(window.RegExp){if(which == "select"){var selected1=true;var selected2=false;}else if(which == "unselect"){var selected1=false;var selected2=true;}else{return;}var re = new RegExp(regex);if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){if(re.test(obj.options[i].text)){obj.options[i].selected = selected1;}else{if(only == true){obj.options[i].selected = selected2;}}}}}
function selectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"select",false);}
function selectOnlyMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"select",true);}
function unSelectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"unselect",false);}
function sortSelect(obj){var o = new Array();if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;}if(o.length==0){return;}o = o.sort(
function(a,b){if((a.text+"") <(b.text+"")){return -1;}if((a.text+"") >(b.text+"")){return 1;}return 0;});for(var i=0;i<o.length;i++){obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);}}
function selectAllOptions(obj){if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){obj.options[i].selected = true;}}
function moveSelectedOptions(from,to){if(arguments.length>3){var regex = arguments[3];if(regex != ""){unSelectMatchingOptions(from,regex);}}if(!hasOptions(from)){return;}for(var i=0;i<from.options.length;i++){var o = from.options[i];if(o.selected){if(!hasOptions(to)){var index = 0;}else{var index=to.options.length;}to.options[index] = new Option( o.text, o.value, false, false);}}for(var i=(from.options.length-1);i>=0;i--){var o = from.options[i];if(o.selected){from.options[i] = null;}}if((arguments.length<3) ||(arguments[2]==true)){sortSelect(from);sortSelect(to);}from.selectedIndex = -1;to.selectedIndex = -1;}
function copySelectedOptions(from,to){var options = new Object();if(hasOptions(to)){for(var i=0;i<to.options.length;i++){options[to.options[i].value] = to.options[i].text;}}if(!hasOptions(from)){return;}for(var i=0;i<from.options.length;i++){var o = from.options[i];if(o.selected){if(options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text){if(!hasOptions(to)){var index = 0;}else{var index=to.options.length;}to.options[index] = new Option( o.text, o.value, false, false);}}}if((arguments.length<3) ||(arguments[2]==true)){sortSelect(to);}from.selectedIndex = -1;to.selectedIndex = -1;}
function moveAllOptions(from,to){selectAllOptions(from);if(arguments.length==2){moveSelectedOptions(from,to);}else if(arguments.length==3){moveSelectedOptions(from,to,arguments[2]);}else if(arguments.length==4){moveSelectedOptions(from,to,arguments[2],arguments[3]);}}
function copyAllOptions(from,to){selectAllOptions(from);if(arguments.length==2){copySelectedOptions(from,to);}else if(arguments.length==3){copySelectedOptions(from,to,arguments[2]);}}
function swapOptions(obj,i,j){var o = obj.options;var i_selected = o[i].selected;var j_selected = o[j].selected;var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);o[i] = temp2;o[j] = temp;o[i].selected = j_selected;o[j].selected = i_selected;}
function moveOptionUp(obj){if(!hasOptions(obj)){return;}for(i=0;i<obj.options.length;i++){if(obj.options[i].selected){if(i != 0 && !obj.options[i-1].selected){swapOptions(obj,i,i-1);obj.options[i-1].selected = true;}}}}
function moveOptionDown(obj){if(!hasOptions(obj)){return;}for(i=obj.options.length-1;i>=0;i--){if(obj.options[i].selected){if(i !=(obj.options.length-1) && ! obj.options[i+1].selected){swapOptions(obj,i,i+1);obj.options[i+1].selected = true;}}}}
function removeSelectedOptions(from){if(!hasOptions(from)){return;}if(from.type=="select-one"){from.options[from.selectedIndex] = null;}else{for(var i=(from.options.length-1);i>=0;i--){var o=from.options[i];if(o.selected){from.options[i] = null;}}}from.selectedIndex = -1;}
function removeAllOptions(from){if(!hasOptions(from)){return;}for(var i=(from.options.length-1);i>=0;i--){from.options[i] = null;}from.selectedIndex = -1;}
function addOption(obj,text,value,selected){if(obj!=null && obj.options!=null){obj.options[obj.options.length] = new Option(text, value, false, selected);}}


