// JavaScript Document
var prev_id = 'no_id';
var click_url = '';
var conv_url = '';
function reset_div_id (vid_id, old_id, new_id) {
	//reset any previous div to its original id
	if (prev_id != 'no_id') { 
		document.getElementById('im_box_ep').id=prev_id;
	}
	//set previous id to current div we are changing
	prev_id=old_id;
	//set the current vid div to the playable id
	document.getElementById(old_id).id=new_id;
	
	//in addition, load an HTML page that counts the video as having been played
	click_url='http://goldsteinpatentlaw.com/embed/embed_vid_'+vid_id+'.html';
	document.getElementById('iFrameEmbed').src=click_url;
}

function call_conv () {
	
	//in addition, load an HTML page that counts the call button as having been clicked
	conv_url='http://goldsteinpatentlaw.com/embed/click_to_call_conv.html';
	document.getElementById('iFrameEmbed').src=conv_url;
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please use a valid email address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please use a valid email address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please use a valid email address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please use a valid email address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please use a valid email address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please use a valid email address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please use a valid email address")
		    return false
		 }

 		 return true					
	}

function comment_form_onsubmit()
 {		

	if(document.comment_form.name.value=="")
	{
		alert("Please Enter Your Name ");
	
		document.comment_form.name.focus();
		return false;		
	}
		
	var emailID=document.comment_form.email

	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("Please use a valid email address")
		emailID.focus()
		return false
	}
	
	if (echeck(emailID.value)==false)
	{
		emailID.value=""
		emailID.focus()
		return false
	}
	
	
	if(document.comment_form.comment.value.length=="")
		{
		alert("You must add a Comment ");
		document.comment_form.comment.focus();
		return false;
	}
			
	return true;
}

