function validate(type, input, output, required) {
	var valid_email = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
	var valid_number = /^\+?[0-9 ()-]+[0-9]$/ ;

if (type=='number') {
	if (!valid_number.test(input.value)) { 
		style = "error" ;
		message("Invalid number.", output, style) ;
	}
	if (valid_number.test(input.value)) {
		style = "success" ;
		message("Ok!", output, style) ;
	}
}

if (type=="email") {
	if (!valid_email.test(input.value)) {
		style= "error" ;
		message("Invalid e-mail.", output, style) ;
	}
	if (valid_email.test(input.value)) {
		style = "success" ;
		message("Ok!", output, style) ;
	}
}
return true;
}

function message(message, output, style) {
	var element = document.getElementById(output) ;
	element.firstChild.nodeValue = message;
	element.className = style;

// document.getElementById(output).firstChild.nodeValue = message ;
// document.getElementById(output).firstChild.className = style ;

	return true;
}

function validate_onsubmit() {
errors = "There were some errors:\n"; 
num_errors = 0;
var valid_email = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
var valid_number = /^\+?[0-9 ()-]+[0-9]$/ ;
if (!document.forms.get_quote.name.value) { errors+='You did not enter a name.\n'; num_errors +=1 ; }
if (!valid_email.test(document.forms.get_quote.email.value)) { errors+='E-mail address is invalid.\n'; num_errors += 1 ;}
// if (!valid_number.test(document.forms.get_quote.number.value)) { errors+='Phone number is invalid.\n'; num_errors += 1 ;}
 if (num_errors != 0) { 
	alert(errors); 
 }
return (num_errors==0) ;

}


function bookmark() {
 var splitURL = window.location.href.split("#") ;
 var video = splitURL[1];
if (video) {
show_video(video) ;
} 
}

function get_video() {
var video = document.getElementById('form_video').select_video.options[document.getElementById('form_video').select_video.selectedIndex].value;
show_video(video) ;
}



function show_video(video) {
new_text = "<object type=\"application/x-shockwave-flash\" data=\"http://www.miltonkrasner.com/FlowPlayerLight.swf\" width=\"320\" height=\"241\" id=\"FlowPlayer\">" ;
new_text = new_text + "<param name=\"allowScriptAccess\" value=\"sameDomain\" />" ;
new_text = new_text + "<param name=\"movie\" value=\"http://www.miltonkrasner.com/FlowPlayerLight.swf\" />" ;
new_text = new_text + "<param name=\"quality\" value=\"high\" />" ;
new_text = new_text + "<param name=\"scale\" value=\"noScale\" />" ;
new_text = new_text + "<param name=\"wmode\" value=\"transparent\" />" ;
new_text = new_text + "<param name=\"flashvars\" value=\"config={videoFile: \'http://www.miltonkrasner.com/video/engagement-rings-san-diego-testimonial-" ;
new_text = new_text + video ; 
new_text = new_text + ".flv\', autoPlay:true, autoBuffering:true, showPlayListButtons: true, showStopButton: true, controlBarBackgroundColor: 0xcecece, loop: false}\" />" ;
new_text = new_text + "</object>" ;

document.getElementById('video').innerHTML = new_text ;


var splitURL = window.location.href.split("#") ;
var URL = splitURL[0];
window.location.href = URL + "#" + video ;

}

