
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}


function val_email()
{
	
	var email=document.getElementById("email").value;
	var invalid_items=0
				
	if(email.length==0)
	{
			invalid_items++
			document.getElementById('email_error_msg').innerHTML=ENTER_THE_EMAIL;

	}
	else 
	{
		var str1=email;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (!filter.test(str1))
		{
			invalid_items++
			document.getElementById('email_error_msg').innerHTML=INVALID_EMAIL;
		}
	}//email


	 if(invalid_items>0)
		{	
			//window.scrollTo(0, 0)
			document.getElementById("email").focus()
			return false;
		}	
	
		
		//make the ajax
		
		
		xmlHttp= new GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}
		var url="ajax/submit_email.php";

	
		xmlHttp.onreadystatechange= function ()
		{
			if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
			{ 
				var result=xmlHttp.responseText;

				
				if(result==1)
				{
					document.getElementById('email_error_msg').innerHTML=EMAIL_ADDED;
				}				
				
				else if(result==2)
				{
					document.getElementById('email_error_msg').innerHTML=EMAIL_EXIST;
				}
				
				else if(result==3)
				{
					document.getElementById('email_error_msg').innerHTML=INVALID_EMAIL;
				}
		
			}
		
		}
		xmlHttp.open("POST",url)
		xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8')
		xmlHttp.send("email=" + email)

	
	
}





function val_main_form()
{
	var checkbox_choices = 0;
	var xx=document.getElementsByTagName('input');

	for (counter = 0; counter < xx.length; counter++)
	{
		if(((xx[counter].type=="checkbox"))&&(xx[counter].checked))
		{
			checkbox_choices = checkbox_choices + 1;
		}
	}
	if (checkbox_choices==0 )
	{
		alert('Please check any email first. ');
		return false;
	}
	else return true;
}

function validate_email_notification_from()
{
	
	var title=document.getElementById('title');
 	if (title.value.length==0)
	{
		document.getElementById("title_error_msg").innerHTML='Please write the message title'
		title.focus();
		window.scrollTo(0, 0)
		return false;
		
	}
	
}

function val_settings_form()
{
	var name=document.getElementById('name');
	if (name.value.length==0)
	{
		alert ('Please write the From Name .');
		
		name.focus();
		return false;
	}
	
	var email=document.getElementById('email');
	if (email.value.length==0)
	{
		alert ('Please write the From Email .');
		
		email.focus();
		return false;
	}

	var hosting=document.getElementById('hosting');
	if (hosting.value.length==0)
	{
		alert ('Please write the hosting server name .');
		
		hosting.focus();
		return false;
	}
	
	return true;

	
	
}//function


function doExpand(paraNum,arrowNum) {

	var divNum=document.getElementById(paraNum);
	var imageNum=document.getElementById(arrowNum);
if (divNum.style.display=="none") {

divNum.style.display="";
imageNum.src="../images/minus.gif";
}
else {

divNum.style.display="none";
imageNum.src="../images/plus.gif";
}
}