// Ivegas JavaScript
// Created: June 17, 2003
// Last Edited: June 17, 2003
// Last Edited by: Amram Bentolila, Eden Interactive

// openWindow function
// opens a window with the specified url, name and window attributes (chrome)
// Arguments:
// url			-> the url to display in the new window
// name			-> the name of the new window
// width		-> the width of the new window
// height		-> the height of the new window
// menu			-> show the menu bar (default = false)
// loc			-> show the location bar (default = false)
// resize		-> allow resizeable (default = false)
// scrollBars		-> show scrollbars (true,false,auto) (default = false)
// status		-> show the status bar (default = false)
// title		-> show the title bar (default = false)
// toolbar		-> show the toolbar (default = false)
// left			-> x position for new window
// top			-> y position for new window

function openWindow(url,name,width,height,menu,loc,resize,scrollbars,status,title,toolbar,left,top) {
	if(url == "" || url == null) return false;
	if(openWindow.arguments.length == 3) {
		height = width;
		width = name;
		name = "newWin";	
	} else if(openWindow.arguments.length == 1) {
		width = 0;
		name = "newWin";
	}

	menu = menu || 0;
	loc = loc || 0;
	resize = resize || 0;
	scrollbars = scrollbars || 0;
	status = status || 0;
	title = title || 0;
	toolbar = toolbar || 0;
	chrome = "";
	if(width > 0) chrome += "width=" + width + ",height=" + height + ",";
	
	chrome += "menubar=" + menu + ",location=" + loc + ",resizable=" + resize + ",scrollbars=" + scrollbars + ",status=" + status + ",title=" + title + ",toolbar=" + toolbar;
	
	if(left != null && top != null) {
		chrome += ",left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top;
	}
	win = window.open(url,name,chrome);
	win.focus();

}

// resetForm
// Resets a form
// Arguments:
// f 	-> the form to reset
function resetForm(f) {
	f.reset();
}

// submitForm
// submits a form
// Arguments:
// f	-> the form to submit
function submitForm(f) {
	f.submit();
}

// submitLogin
// validates and submits a LOGIN form (username/password necessary fields)
// Arguments:
// f	-> the form to validate and submit
function submitLogin(f) {
	s = validateLogin(f);
	if(s) f.submit();
}

// validateLogin
// validates the iVegas login form
// Arguments:
// f	-> the form to validate
function validateLogin(f) {
	if(f.username.value == null || f.username.value == "" || f.username.value.length < 1) { // no username entered
		alert("Please enter your username to log in.");
		return false;
	}	
	if(f.password.value == null || f.password.value == "" || f.password.value.length < 1) { // no password entered
		alert("Please enter your password to log in.");
		return false;
	}	
	return true;
}

function tc(){

window.open("term_popup.html","terms","height=570,width=600,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,left=0,top=0")

} // terms and conditions

function vt(){

window.open("vote_terms.html","terms","height=570,width=600,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,left=0,top=0")

} // terms and conditions

