
function deleteItem(location) {
	var msg = "\nPlease confirm deletion...\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 = '';
		}
	}
}

