var newWindow;
var screenWidth = screen.width;
var screenHeight = screen.height;

function createNewWindow(url, width, height) {
	var left = (screenWidth-width) / 2;
	var top = (screenHeight-height) / 2;

	newWindow = window.open(url, "", "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
}

function submitForm(form) {
	if (form.site.value != 0) {
		form.submit();
	} else {
		return false;
	}
}

function showhide(id){ 
	if (document.getElementById){ 
		obj = document.getElementById(id); 
		if (obj.style.display == "none"){ 
			obj.style.display = ""; 
		} else { 
			obj.style.display = "none"; 
		} 
	} 
} 

function deleteAttachment(type,name,id) {
	var url = '../../assets/includes/delete_attachment.php?id=' + id;
	var params = type + '=' + name;
	var ajax = new Ajax.Updater(
												{success: 'attached-' + type},
												url,
												{method: 'post', parameters: params, onFailure: reportError}
												);

}

function reportError(request) {
	alert('Sorry. There was an error.');
}	

function showForm(type) {
	var newHTML = "<p class=\"input\"><input type='file' name='" + type + "' /></p>";
	document.getElementById("attached-" + type).innerHTML = newHTML;
}

function confirmDelete() {
	var agree = confirm("Are you sure you wish to delete this auction?");
	if (agree)
		return true ;
	else
		return false ;
}

var msgs = {
	help: {
		toggle: function(type) {
		  this.visible(type) ? this.hide(type) : this.show(type)
		},
	
		visible: function(type) {
		  return Element.visible(type + '-help')
		},
	
		show: function(type) {
		  visible = this.visible(type)
	
		  new Effect.BlindDown(type + '-help', {duration: 0.5})
	
		  return visible
		},
	
		hide: function(type) {
		  visible = this.visible(type)
		  
		  new Effect.BlindUp(type + '-help', {duration: 0.5})
	
		  return visible
		}
	}/*,
	(message: {
		toggle: function() {
		  this.visible() ? this.hide() : this.show()
		},
	
		visible: function() {
		  return Element.visible('success')
		},
	
		show: function() {
		  visible = this.visible()
	
		  new Effect.Opacity('success', {duration:0.5, from:0.2, to:1.0});
	
		  return visible
		},
	
		hide: function() {
		  visible = this.visible()
		  
		  new Effect.Opacity('success', {duration:0.5, from:1.0, to:0.2});
	
		  return visible
		}
	}*/
}	

window.onload = function() {
	setTimeout("msgs.message.hide()",2000);
}

