// JavaScript Document

//changeColor
function changeColor(id) {
	$("#" + id).css({'border-color' : '#2abbf3'});
}

function changeBack(id) {
	$("#" + id).css({'border-color' : '#FFF'});
}

//Validate Mail
	
function submitForm() {	
	var errorFlag = false;
		
	var errorMsg = "There are error(s) with the information you entered:\n";
		
	if( $( "#name" ).val() == "" ) {
		errorMsg += "Name is required\n";
		errorFlag = true;
	}
	if( $( "#email" ).val() == "" ) {
		errorMsg += "Email is required\n";
		errorFlag = true;
	}
	var email_addr = $("#email" ).val();
	if( email_addr.indexOf( "@" ) < 0 ) {
		errorMsg += "Email address is invalid\n";
		errorFlag = true;
	}
	if( $( "#comments" ).val() == "" ) {
		errorMsg += "Message is required\n";
		errorFlag = true;
	}
		
	if( ! errorFlag ) {
		document.contactForm.submit();
	} else {
		alert( errorMsg );
	}
}

//Rollovers
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images ) {
		document[changeImages.arguments[0]].src = changeImages.arguments[1];
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		mc_btn_over = newImage("img/mc_btn_over.gif");
		tennis_btn_over = newImage("img/tennis_btn_over.gif");
		dalpos_btn_over = newImage("img/dalpos_btn_over.gif");
		morfab_btn_over = newImage("img/morfab_btn_over.gif");
		facebook_btn_over =newImage("img/facebook_btn_over.gif")
		preloadFlag = true;
	}
}

function create_popup( url, win_title, win_options )
	{
  		var popWin = window.open( url, win_title, win_options );
  		if( !popWin ) {
    		popWin = window.open('', win_title, win_options);
    		popWin.location.href = url;
  		}
  		return false;
}

