function InsertFlashMovie(src, height, width)
{
  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="'+ width +'" height="'+ height +'"><param name="wmode" value="transparent" /><param name="movie" value="'+src+'"><param name="quality" value="high"><EMBED SRC="'+src+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  WIDTH="'+width+'" HEIGHT="'+height+'" WMODE="TRANSPARENT" MENU="FALSE" BGCOLOR="BLACK"></EMBED></object>');
}

function tabswitch(){
	if (document.getElementById('div1').style.display == "none"){
		document.getElementById('div1').style.display = "block";
		document.getElementById('div2').style.display = "none";
		document.getElementById('services').className = "active";
		document.getElementById('markets').className = "";
	}else{
		document.getElementById('div2').style.display = "block";
		document.getElementById('div1').style.display = "none";
		document.getElementById('services').className = "";
		document.getElementById('markets').className = "active";
	}
}

//Expand and Collapse
function expand(id){
	if(document.getElementById(id).style.display == "none"){
		document.getElementById(id).style.display = "block";
		document.getElementById('expand_text_'+id).setAttribute("class", "less");
	}else{
		document.getElementById(id).style.display = "none";
		document.getElementById('expand_text_'+id).setAttribute("class", "more");
	}
}

function expand_byclass(id){
	if(document.getElementById(id).className == "expand_closed"){
		document.getElementById(id).setAttribute("class", "expand_open");
		document.getElementById(id).setAttribute("className", "expand_open");
		document.getElementById('expand_text_'+id).setAttribute("class", "less");
		document.getElementById('expand_text_'+id).setAttribute("className", "less");
	}else{
		document.getElementById(id).setAttribute("class", "expand_closed");
		document.getElementById(id).setAttribute("className", "expand_closed");
		document.getElementById('expand_text_'+id).setAttribute("class", "more");
		document.getElementById('expand_text_'+id).setAttribute("className", "more");
	}
}

//Form Validation
function validate_contact_form() {
	
	errors = 0;
	first_name = document.getElementById("first_name").value;
	last_name = document.getElementById("last_name").value;
	email = document.getElementById("email").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(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("email_error").style.display = "none";
    document.getElementById("email_invalid").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
}

