var EW_dateSep; // default date separator
if (EW_dateSep == "") EW_dateSep = "/";

function OpenNewsItemPopup(itemId) {
	var popup = window.open('newsitempopup.asp?id='+itemId+'','newsitempopup','width=400,height=300,scrollbars=yes,status=no,resizable=yes');
	popup.focus();
}

function OpenPhotoUploadPopup() {
	var popup = window.open('PhotoUploadPopup.aspx','photouploadpopup','width=400,height=300,scrollbars=yes,status=no,resizable=yes');
	popup.focus();
}

function OpenGameReportPopup(itemId) {
	var popup = window.open('gamereportpopup.asp?id='+itemId+'','gamereportpopup','width=400,height=300,scrollbars=yes,status=no,resizable=yes');
	popup.focus();
}

function OpenCupReportPopup(itemId) {
	var popup = window.open('cupreportpopup.asp?id='+itemId+'','gamereportpopup','width=400,height=300,scrollbars=yes,status=no,resizable=yes');
	popup.focus();
}

function EW_isHTMLArea(input_object, object_type) {
	return (object_type == "TEXTAREA" && EW_HTMLArea && input_object.style && input_object.style.display && input_object.style.display == "none");
}

function EW_onError(form_object, input_object, object_type, error_message) {
	alert(error_message);									
	if (object_type == "RADIO" || object_type == "CHECKBOX") {
		if (input_object[0])
			input_object[0].focus();
		else
			input_object.focus();
	}	else if (!EW_isHTMLArea(input_object, object_type)) { 
		input_object.focus();  
	}  
	if (object_type == "TEXT" || object_type == "PASSWORD" || object_type == "TEXTAREA" || object_type == "FILE") {
		if (!EW_isHTMLArea(input_object, object_type))
			input_object.select();
	}
	return false;	
}

function EW_hasValue(obj, obj_type) {
	if (obj_type == "TEXT" || obj_type == "PASSWORD" || obj_type == "TEXTAREA" || obj_type == "FILE")	{
		if (obj.value.length == 0) 
			return false;		
		else 
			return true;
	}	else if (obj_type == "SELECT") {
		if (obj.type != "select-multiple" && obj.selectedIndex == 0)
			return false;
		else if (obj.type == "select-multiple" && obj.selectedIndex == -1)
			return false;
		else
			return true;
	}	else if (obj_type == "RADIO" || obj_type == "CHECKBOX")	{
		if (obj[0]) {
			for (i=0; i < obj.length; i++) {
				if (obj[i].checked)
					return true;
			}
		} else {
			return (obj.checked);
		}
		return false;	
	}
}

function EW_checkemail(object_value) {
	if (object_value.length == 0)
		return true;
	
	if (!(object_value.indexOf("@") > -1 && object_value.indexOf(".") > -1))
		return false;    
	
	return true;
}

// Get image width/height
function EW_getimagesize(file_object, width_object, height_object) {
	if (navigator.appVersion.indexOf("MSIE") != -1)	{
		myimage = new Image();
		myimage.onload = function () {
			width_object.value = myimage.width; height_object.value = myimage.height;
		}		
		myimage.src = file_object.value;
	}
}