function CheckNumeric(e)
{
  var key //= (window.event) ? event.keyCode : e.which;
  if (window.event)
    key = event.keyCode
  else
    key = e.which
 
  // Was key that was pressed a numeric character (0-9), backspace (8) or null character (0)
  if ( key > 47 && key < 58 || key == 8 || key ==0)
    return; // if so, do nothing
  else // otherwise, discard character
    if (window.event) //Internet Explorer
      window.event.returnValue = null;     
    else //Firefox
      e.preventDefault();
}

function VerifyFieldsUserContactForm(source, arguments)
{	
	var ddlObject = document.getElementById(oObject);
    if (ddlObject.selectedIndex !='0')
	{
	    arguments.IsValid=true;
        return;
	}
	else
	{
        arguments.IsValid=false;
	}
}
function VerifyFields(source, arguments)
{
    var sDepartment,sCity,sExpertise,sToutes, sTous;
    var oSpeciality;
    sCity = document.getElementById(oCity).value;
    sDepartment = document.getElementById(oDepartment).value;
    oSpeciality=document.getElementById(oExpertise);
    //sToutes = document.getElementById(oToutes).value;
    //sTous = document.getElementById(oTous).value;
    if ((sDepartment != "") || (sCity != "") || (oSpeciality.selectedIndex !='0'))
	{
	    arguments.IsValid=true;
        return;
	}
	else
	{
        arguments.IsValid=false;
	}
}

function validateCity(oEvent, sLiteral) 
{
	var lLength;
	var sString = document.getElementById(sLiteral).value;
	var obj;
	if (navigator.appName.indexOf("Explorer")==-1) 
	{
		obj=oEvent.target;
		lLength=parseInt(obj.value.length,10);
	} 
	else 
	{
		obj=oEvent.srcElement;
		lLength=parseInt(obj.value.length,10);
	}
	if (lLength==0) 
	{
	    obj.value= sString;	
    }
}

function validateDepartment(oEvent, sLiteral) 
{
	var lLength;
	var sString = document.getElementById(sLiteral).value;
	var obj;
	if (navigator.appName.indexOf("Explorer")==-1) 
	{
		obj=oEvent.target;
		lLength=parseInt(obj.value.length,10);
	} 
	else 
	{
		obj=oEvent.srcElement;
		lLength=parseInt(obj.value.length,10);
	}
	if (lLength==0) 
	{
	    obj.value= sString;	
    }
}
 
function OpenWindowInfoslegales()
{
	var oWindow;
	oWindow = window.open("/Pages/Infos-legales.aspx", "infoslegales", "directories=no, scrollbar=no, width=500px, height=500px, top=50px, left=100px, location=no, resizeable=no, titlebar=yes");
}

function EnterPress(oEvent)
{
    var iAscii; 
     
    if (window.event) 
        iAscii = oEvent.keyCode; 
    else
        iAscii = oEvent.which; 
      
    if (iAscii == 13)
    {
        document.getElementById(oButtonSearch).click();
    }

    return true; 
} 

//function EnterPressAdd(oEvent, fn)
//{
//    alert('hola');
//    var iAscii;
//    debugger; 
//     
//    if (window.event){
//          
//        iAscii = event.keyCode; 
//    }
//    else
//        iAscii = oEvent.which; 
//      
//    if (iAscii == 13)
//    {      
//        fn(); 
//        return false;        
//    }

//    return true;
//} 

function CheckNumericIntro(e)
{
  var key //= (window.event) ? event.keyCode : e.which;
  if (window.event)
    key = event.keyCode
  else
    key = e.which
  
  if (key == 13) //Intro
  {
        document.getElementById(oButtonSearch).click();
  }
  else
  {
      // Was key that was pressed a numeric character (0-9), backspace (8) or null character (0)?
      if ( key > 47 && key < 58 || key == 8 || key ==0 )
        return; // if so, do nothing
      else // otherwise, discard character
        if (window.event) //Intenet Explorer
          window.event.returnValue = null;     
        else //Firefox
          e.preventDefault();
   }
}

function validateMCQ(source, arguments)
{    
   var ddlActivityDomain = document.getElementById(oDdlActivityDomain);   
   var txtKeywords = document.getElementById(oTxtKeywords);
   var ddlRegion = document.getElementById(oDdlRegion);  
  
   var i = 0;
   
    if ( (ddlActivityDomain.options[ddlActivityDomain.selectedIndex].value != "0") ||
        ((txtKeywords.value != "") && (txtKeywords.value != oDefaultText)) || (ddlRegion.options[ddlRegion.selectedIndex].value != "0"))        
    {
        arguments.IsValid = true;  
        return;
    }
    else
    {
        arguments.IsValid = false;
    } 
}

// Change title of SEO pages in the following sites: 'agences-interim' and 'offres-emploi'.
// Only it will change title in detail pages of previous sites.
// URL Path is displayed by ISAPI filter. Example URL: /agence-interim/Pages/[BRANCH].aspx
function ChangeTitle()
{
	var sUrl = location.href; 
	var sBranch = sUrl.split('/')[5];
	if(sBranch.indexOf('default.aspx') < 0) //if page isnīt default.aspx
	{
		if(sBranch.indexOf('index.aspx') >= 0) // if page is index.aspx
		{
			document.title ='Travail temporaire & Agence interim';
		}
		else  
		{
			if(sUrl.indexOf("/agence-interim/Pages/" + sBranch) > -1 )
				document.title = 'Travail temporaire & Agence interim a ' + sBranch.replace('.aspx','') +
					 ', Adia ' +  sBranch.replace('.aspx','');
			if(sUrl.indexOf("/offres-emploi/Pages/" + sBranch) > -1)
				document.title = 'Recrutement & offre d\'emploi: ' + sBranch.replace('.aspx','');
		}
	}
}
