var xmlHttp

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}


//==============================================================================================

function Get_Currency_Converter(){ 

var amount,from_curr,to_curr,action_action
var go_flag

go_flag="YES"

amount=document.frm_converter.amount.value
from=document.frm_converter.from_curr.value
to_curr=document.frm_converter.to_curr.value
action_action=document.frm_converter.action_action.value

	if (document.frm_converter.amount.value==""){
		alert("Montant Entrez s'il vous plaît ...!");
		document.frm_converter.amount.focus();
		go_flag="NO"
		return;
	}

	if(trim(document.frm_converter.amount.value) == '') {
      alert("Montant Entrez s'il vous plaît ...!");
      document.frm_converter.amount.focus();
	  go_flag="NO"
      return;
   }
    if (isNaN(document.frm_converter.amount.value)){
        alert("Entrez s'il vous plaît numérique Montant");
		document.frm_converter.amount.focus();
		go_flag="NO"
		return;
	}

	if (document.frm_converter.from_curr.value==""){
		alert("S'il vous plaît Choisir De Monnaie ...!");
		document.frm_converter.from_curr.focus();
		go_flag="NO"
		return;
	}

	if (document.frm_converter.to_curr.value==""){
		alert("S'il vous plaît Choisir la monnaie ...!");
		document.frm_converter.to_curr.focus();
		go_flag="NO"
		return;
	}
	 
if (go_flag=="YES") { // go flag
document.getElementById("Show_Conver").innerHTML="<img src='images/load.gif' width='80'>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Get_Currency_Converter.php"
	var parameters="amount="+amount
	var parameters="amount="+amount
	parameters=parameters+"&from="+from
	parameters=parameters+"&to="+to_curr
	parameters=parameters+"&ram_id="+Math.random()
	xmlHttp.onreadystatechange=Get_Currency_Converter_Change
	//xmlHttp.open("GET",url,true)
	//xmlHttp.send(null)
	xmlHttp.open("POST",url,true)
      xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlHttp.setRequestHeader("Content-length", parameters.length);
      xmlHttp.setRequestHeader("Connection", "close");
      xmlHttp.send(parameters);
	} // go flag
}
function Get_Currency_Converter_Change() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("Show_Conver").innerHTML=xmlHttp.responseText		 
	} 
}


//==============================================================================================

function Go_Subsc(){ 

document.getElementById("Show_Subsc_Message").innerHTML=""

var suns_name,suns_email,site_id,action_action
var go_flag

go_flag="YES"

suns_name=document.frm_news.suns_name.value
suns_email=document.frm_news.suns_email.value
site_id=document.frm_news.site_id.value
action_action=document.frm_news.action_action.value

	if (document.frm_news.suns_name.value==""){
		alert("S'il vous plaît entrer votre nom ...!");
		document.frm_news.suns_name.focus();
		go_flag="NO"
		return;
	}

	if(trim(document.frm_news.suns_name.value) == '') {
      alert("S'il vous plaît entrer votre nom ...!");
      document.frm_news.suns_name.focus();
	  go_flag="NO"
      return;
   }
   
	if (document.frm_news.suns_email.value==""){
		alert("S'il vous plaît entrer votre adresse e-mail ...!");
		document.frm_news.suns_email.focus();
		go_flag="NO"
		return;
	}

	if(trim(document.frm_news.suns_email.value) == '') {
      alert("S'il vous plaît entrer votre adresse e-mail ...!");
      document.frm_news.suns_email.focus();
	  go_flag="NO"
      return;
   }
   
if(document.frm_news.suns_email.value!=""){
	if(IsEmailValid(document.frm_news.suns_email)==false){
		alert("S'il vous plaît entrer une adresse e-mail valide!");
		document.frm_news.suns_email.focus();
		go_flag="NO"
		return;
		}
}	

if (go_flag=="YES") { // go flag
document.getElementById("Show_Subsc_Message").innerHTML="<img src='images/load.gif' >"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Go_Subsc.php"
	var parameters="suns_name="+suns_name
	parameters=parameters+"&suns_email="+suns_email
	parameters=parameters+"&site_id="+site_id
	parameters=parameters+"&action_action="+action_action
	parameters=parameters+"&ram_id="+Math.random()
	xmlHttp.onreadystatechange=Go_Subsc_Change
	//xmlHttp.open("GET",url,true)
	//xmlHttp.send(null)
	xmlHttp.open("POST",url,true)
      xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlHttp.setRequestHeader("Content-length", parameters.length);
      xmlHttp.setRequestHeader("Connection", "close");
      xmlHttp.send(parameters);
	} // go flag
}
function Go_Subsc_Change() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.frm_news.suns_name.value=""
		document.frm_news.suns_email.value=""
		document.getElementById("Show_Subsc_Message").innerHTML=xmlHttp.responseText		 
	} 
}


function IsEmailValid(ElemName){
				var EmailOk  = true
				var Temp     = ElemName;
				var AtSym    = Temp.value.indexOf('@')
				var Period   = Temp.value.lastIndexOf('.')
				var Space    = Temp.value.indexOf(' ')
				var Length   = Temp.value.length - 1   // Array is from 0 to length-1
					if ((AtSym < 1) ||                     // '@' cannot be in first position
					    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
					    (Period == Length ) ||             // Must be atleast one valid char after '.'
					    (Space  != -1))                    // No empty spaces permitted
						   {
						      EmailOk = false
						      //alert('Please enter a valid e-mail address!')
						      //Temp.focus()
						      return false
						   }
					//return EmailOk				
}

function trim(str){
   return str.replace(/^\s+|\s+$/g,'');
}
