function blankValue(fieldID){
	if(document.getElementById(fieldID)){
		curElement = document.getElementById(fieldID);
		if(curElement.type == "text" || curElement.type == "textarea"){
			return !document.getElementById(fieldID).value;
		} else if (curElement.type == "checkbox"){
			return false;
		}  else if (curElement.type == "select-one"){
			return !curElement.options[curElement.selectedIndex].value;
		}  else if (curElement.type == "select-multiple"){
			return !curElement.options[curElement.selectedIndex].value;
		}
	} else {
		cnt = -1;
		colRadio = document.getElementsByName(fieldID);
		for (i=colRadio.length-1; i > -1; i--) {
			if (colRadio[i].checked){
				return false;
			}
		}
		return true;
	}  
}

function link_confirm(page_link){
        question = confirm("Are You Sure?")
        if (question !="0"){
                document.location = page_link;
        }
}

function validateNumber(field, min, max) {
	if (!min) { min = 0 }
	if (!max) { max = 255 }

	if (isNaN(field.value) || field.value.length < min || field.value.length > max){
		return false;
	}
	return true;
}

function validateString(field, min, max) {
	if (!min) { min = 1 }
	if (!max) { max = 65535 }

	if (!field.value || field.value.length < min || field.value.max > max) {
		return false;
	}
	return true;
}

function validateEmail(field) {
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if (!re_mail.test(field.value)) {
		return false;
	}
	return true;
}

function print_this() {
        if (window.print) { window.print() }
        else alert('To print this page press Ctrl-P on your keyboard.')
}

function isValidEmail(str) {
   if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
     return true;
   } else {
     return false;
  }
}

function validateSendTo(str1, str2){
	email1 = document.getElementById(str1).value;
	if(!isValidEmail(email1)){
		alert("Your email is not valid.");
		return false;
	}
	email2 = document.getElementById(str2).value;
	if(!isValidEmail(email2)){
		alert("Friend's email is not valid.");
		return false;
	}
	return true;
}

function showSearch(){
	Dialog.confirm($('search').innerHTML, {windowParameters: {className:"alphacube", width:400, height:100}, okLabel: "Search", cancelLabel: "Cancel", ok:function(win){ document.getElementById("searchForm").submit();}});
}

function showLogin(){
	Dialog.confirm($('login').innerHTML, {windowParameters: {className:"alphacube", width:400}, focus: "loginEmail", okLabel: "Login", cancelLabel: "Cancel", ok:function(win){ document.getElementById("signinForm").submit();}});
}

function showPromo(checked){
        if(checked == 1){
                document.getElementById('PromoArea').style.display="block";
        } else {
                document.getElementById('PromoArea').style.display="none";
        }
}

