function writeflash () {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="990" height="432"><param name="wmode" value="transparent" /><param name="movie" value="flash/altus_header_03.swf"><param name="quality" value="high"><EMBED SRC="flash/altus_header_03.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  WIDTH="990" HEIGHT="432" WMODE="TRANSPARENT" MENU="FALSE" BGCOLOR="BLACK"></EMBED></object>');
}

function writeflash2 () {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="990" height="432"><param name="wmode" value="transparent" /><param name="movie" value="flash/altus_header_03.swf"><param name="quality" value="high"><EMBED SRC="flash/altus_header_03.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  WIDTH="990" HEIGHT="432" WMODE="TRANSPARENT" MENU="FALSE" BGCOLOR="BLACK"></EMBED></object>');
}

function flashmodal(which){
	if(which == "demo"){
		mycontent = '<object width="640" height="360" id="wistia_63075" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="http://embed.wistia.com/flash/embed_player_v1.1.swf"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="wmode" value="opaque"/><param name="flashvars" value="playButtonVisible=true&unbufferedSeek=true&controlsVisibleOnLoad=false&autoPlay=false&videoUrl=http://embed.wistia.com/deliveries/453d7dc9150f2ba844c51b23011e53c1d604fcf8.bin&stillUrl=http://embed.wistia.com/deliveries/07cea35e9da91990e5b70e5ff4883cd0de0ad705.bin&embedServiceURL=http://distillery.wistia.com/x&accountKey=wistia-production_779&mediaID=wistia-production_63075&mediaDuration=117.8"/><embed src="http://embed.wistia.com/flash/embed_player_v1.1.swf" width="640" height="360" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" wmode="opaque" flashvars="playButtonVisible=true&unbufferedSeek=true&controlsVisibleOnLoad=false&autoPlay=false&videoUrl=http://embed.wistia.com/deliveries/453d7dc9150f2ba844c51b23011e53c1d604fcf8.bin&stillUrl=http://embed.wistia.com/deliveries/07cea35e9da91990e5b70e5ff4883cd0de0ad705.bin&embedServiceURL=http://distillery.wistia.com/x&accountKey=wistia-production_779&mediaID=wistia-production_63075&mediaDuration=117.8"></embed></object>';
		$.nyroModalManual({
	      content: mycontent
	    });
	}
}

function flashmodal2(which){
	if(which == "demo"){
		mycontent = '<object width="640" height="360" id="wistia_63075" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="http://embed.wistia.com/flash/embed_player_v1.1.swf"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="wmode" value="opaque"/><param name="flashvars" value="playButtonVisible=true&unbufferedSeek=true&controlsVisibleOnLoad=false&autoPlay=false&videoUrl=http://embed.wistia.com/deliveries/453d7dc9150f2ba844c51b23011e53c1d604fcf8.bin&stillUrl=http://embed.wistia.com/deliveries/07cea35e9da91990e5b70e5ff4883cd0de0ad705.bin&embedServiceURL=http://distillery.wistia.com/x&accountKey=wistia-production_779&mediaID=wistia-production_63075&mediaDuration=117.8"/><embed src="http://embed.wistia.com/flash/embed_player_v1.1.swf" width="640" height="360" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" wmode="opaque" flashvars="playButtonVisible=true&unbufferedSeek=true&controlsVisibleOnLoad=false&autoPlay=false&videoUrl=http://embed.wistia.com/deliveries/453d7dc9150f2ba844c51b23011e53c1d604fcf8.bin&stillUrl=http://embed.wistia.com/deliveries/07cea35e9da91990e5b70e5ff4883cd0de0ad705.bin&embedServiceURL=http://distillery.wistia.com/x&accountKey=wistia-production_779&mediaID=wistia-production_63075&mediaDuration=117.8"></embed></object>';
		$.nyroModalManual({content: mycontent});
	}
}

//Form validator

function validate_form() {
	
	errors = 0;
	first_name = document.getElementById("first_name").value;
	last_name = document.getElementById("last_name").value;
	job_title = document.getElementById("job_title").value;
	company = document.getElementById("company").value;
	email = document.getElementById("email").value;
	phone = document.getElementById("phone").value;
	
	hideAllErrors();
	
    if (email == "") {    	
        document.getElementById("email_error").style.display = "block"
        document.getElementById("email").focus();
        errors = 1;
    }
    
	if((email != "") && (!IsEmail(email))){					
	  	document.getElementById("email_invalid").style.display = "block";
	  	document.getElementById("email").focus();	  	
	  	errors = 1;				  	  		  	
	}
	
    
    if (first_name == "") {
        document.getElementById("first_name_error").style.display = "block";
        document.getElementById("first_name").focus();
        errors = 1;
    }

    if (last_name == "") {
        document.getElementById("last_name_error").style.display = "block"
        document.getElementById("last_name").focus();
        errors = 1;
    }
    
    if (job_title == "") {
        document.getElementById("job_title_error").style.display = "block"
        document.getElementById("job_title").focus();
        errors = 1;
    }
    
    if (company == "") {
        document.getElementById("company_error").style.display = "block"
        document.getElementById("company").focus();
        errors = 1;
    }
    
    if (phone == "") {
        document.getElementById("phone_error").style.display = "block"
        document.getElementById("phone").focus();
        errors = 1;
    }

	if(errors == 0){
		document.contact_form.submit();
	}
}

function hideAllErrors() {
    document.getElementById("first_name_error").style.display = "none";
    document.getElementById("last_name_error").style.display = "none";
    document.getElementById("job_title_error").style.display = "none";
    document.getElementById("company_error").style.display = "none";
    document.getElementById("email_error").style.display = "none";
    document.getElementById("email_invalid").style.display = "none";
    document.getElementById("phone_error").style.display = "none";
}

//Email Validator
function IsEmail(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1){
	   return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
	    return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
	    return false
	}
	if (str.indexOf(" ")!=-1){
	    return false
	}
	return true
}