$(function(){
				// Tabs
				$('#tabs').tabs();
				$('.servicesCont #tabs1').tabs();

			});

function hasWhiteSpacename(s) 
{

     reWhiteSpace = new RegExp(/^\s+$/);

     // Check for white space
     if (reWhiteSpace.test(s)) {
          return false;
     }
return true;
}

function hasWhiteSpacecomment(s) 
{

     reWhiteSpace = new RegExp(/^\s+$/);

     // Check for white space
     if (reWhiteSpace.test(s)) {
          return false;
     }
return true;
}

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){
		   
		   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					
	}

function saveVideo() {
	fullname1=document.getElementById('fullname').value;
	emailContact1=document.getElementById('email').value;
	comments=document.getElementById('comments').value;

	var temp = hasWhiteSpacename(fullname1);
	if (temp == false){
		 fullname1="";
	}
	var temp1 = hasWhiteSpacecomment(comments);
	if (temp1 == false){
		 comments="";
	}

	messageQuery="";
     
	  /*var a = $("#email").val();
		var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-zA-Z]{2,4}$/;
		//if it's valid email
		if(filter.test(a)){
			
		document.getElementById('row2').className="rowBoxVideo2";
		}
		//if it's NOT valid
		else{
			messageQuery = messageQuery + "Valid Email Address.\n";
		document.getElementById('row2').className="rowBoxVideoRed2";
		}*/

		if (echeck(emailContact1)==false){
		if (messageQuery.length == 0) messageQuery = messageQuery + "The following error(s) occurred:\n";	
		messageQuery = messageQuery + "Valid email is required.\n";
		document.getElementById('row2').className="rowBoxVideoRed2";
		}else{
		document.getElementById('row2').className="rowBoxVideo2";
		}
		
	/*AtPos = emailContact1.indexOf("@")
	StopPos = emailContact1.lastIndexOf(".")
	if (AtPos == -1 || StopPos == -1) {
		if (messageQuery.length == 0) messageQuery = messageQuery + "The following error(s) occurred:\n";
		messageQuery = messageQuery + "Valid Email Address.\n";
		document.getElementById('row2').className="rowBoxVideoRed2";
	}
	else {
		document.getElementById('row2').className="rowBoxVideo2";
	}*/
	if (fullname1 == "" ) {
		if (messageQuery.length == 0) messageQuery = messageQuery + "The following error(s) occurred:\n";	
		messageQuery = messageQuery + "Full name is required. \n";
		document.getElementById('row1').className="rowBoxVideoRed2";
	}
	else {
		document.getElementById('row1').className="rowBoxVideo2";
	}
	if (comments == "" ) {
		if (messageQuery.length == 0) messageQuery = messageQuery + "The following error(s) occurred:\n";	
		messageQuery = messageQuery + "Comment is required.\n";
		document.getElementById('row3').className="rowAreavideoRedBox";
	}
	else {
		document.getElementById('row3').className="rowAreavideoBox";
	}
 
 
 
	if (messageQuery == "") {
		document.contactForm.submit(); 
	}
	else {
		alert(messageQuery);
	}
}

function removeVideoRed(id,sourceId) {
if (id == 2) {
	newsEmailTo=document.getElementById('email').value;
 	AtPos = newsEmailTo.indexOf("@")
	StopPos = newsEmailTo.lastIndexOf(".")
	if (AtPos == -1 || StopPos == -1) {
  		document.getElementById('row2').className="rowBoxVideoRed2";
	}
	else {
		document.getElementById('row2').className="rowBoxVideo2";
 	}
}
else {
	 if (id != 3 ) {
		  if (document.getElementById(sourceId).value != "")
			  document.getElementById('row'+id).className="rowBoxVideo2";
		  else
			  document.getElementById('row'+id).className="rowBoxVideoRed2";  
	  }
	  else {
		  
		  if (document.getElementById(sourceId).value != "")
			   document.getElementById('row'+id).className="rowAreavideoBox";		
		  else
			   document.getElementById('row'+id).className="rowAreavideoRedBox";		
	  
	  }
}

}
