function validateEmail(field){
	var emailReg = "^[a-z|0-9]+([\-|_|\.]?[a-z|0-9|_]+)*@[a-z|0-9]+([\-|\.]+[a-z|0-9]+)+$";
	var regex = new RegExp(emailReg);
	if (!regex.test(document.getElementById(field).value.toLowerCase()))
	{
		return false;
	}					
        return true;
}

function validateForm(daForm){
    var errstring='';
    var flag=1;

        if(document.getElementById('firstname').value.length<=0) { errstring=errstring+'- First Name\n'; flag=0; }
        if(document.getElementById('lastname').value.length<=0) { errstring=errstring+'- Last Name\n'; flag=0; }
        if(!validateEmail('email')) { errstring=errstring+'- Email\n'; flag=0; }
        if(document.getElementById('phone').value.length<=0) { errstring=errstring+'- Telephone\n'; flag=0; }
        if(flag==0){ 
        	alert('Please fill out these fields correctly:\n\n'+errstring);
        }else  {
			daForm.submit();
		}
	return false;

}
$(document).ready(function(){
	$("#html5report").click(function(){
		$(location).attr('href',"html5-video-report.html");
	});
	$("#scroller").simplyScroll({
			autoMode: 'loop'
		});
        $('.acc_container').hide();
        $('.acc_trigger:first').addClass('active').next().show();
        $('.acc_trigger').click(function(){
            if( $(this).next().is(':hidden') ) {
                    $('.acc_trigger').removeClass('active').next().slideUp();
                    $(this).toggleClass('active').next().slideDown();
            }
            return false;
        });
	$(".demoAJAX").colorbox();
	$(".demoIFRAME").colorbox({iframe:true, width:"85%", height:"85%"});
	$(".openActor").colorbox({iframe:true,width:"340px",height:"350px"});
	$(".openVideo").colorbox({iframe:true,width:"372px",height:"446px"});
	$(".openVideoPresentation").colorbox({iframe:true,width:"680px",height:"406px"});
	$("#demonstrate").click(function(){
		var o= document.getElementById('url').value;
		var url='demonstrate.htm?url='+o;
		window.open(url,'iSpeakVideoDemo','titlebar=no,toolbar=no,location=no,top=0,left=0,width='+
										   screen.width+ ',height=' + screen.height);
	});
	$(".actors li").css("opacity","0.7");
	$(".actors li").hover(
		function(){
			$(this).fadeTo("slow",100);
			$(".play_btn", this).fadeTo("fast",100);
		},
		function(){
			$(this).fadeTo("slow",0.7);
			$(".play_btn", this).fadeTo("fast",0);
		}
	);
        $("#video").bind("play",function(){
            $("#wrap").prepend('<div id="dim" style="position:fixed; width:100%; height:100%; background-color:#000; z-index:1001;"></div>');
            $(".multimedia").css({'z-index':'1002'});
            $("#dim").fadeTo("slow",0.8);
        });
        $("#video").bind("pause",function(){
            $("#dim").remove();
            $(".multimedia").css({'z-index':'999'});
        });
});



