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 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();
   }
}

//malfieri
function LinkPreviousPage()
{   
    history.back(); 
}

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;
    } 
}

//malfieri
function validateMinimumCriteria(source, arguments)
{   
   var cblContractType = document.getElementById(oCblContractType);
   var ddlActivityDomain = document.getElementById(oDdlActivityDomain);   
   var txtKeywords = document.getElementById(oTxtKeywords);
   var ddlRegion = document.getElementById(oDdlRegion);   
   var ddlPublicationDate = document.getElementById(oDdlPublicationDate); 
   //var txtPublicationDate = document.getElementById(otxtPublicationDate);  
   var ddlPublicationDate = document.getElementById(oDdlPublicationDate);  
   var i = 0;
   var count = 0;
   var numOfItems =  cblContractType.getElementsByTagName('input');           
  
    // Loop through the checkboxes in the list.
    for(i = 0; i < numOfItems.length; i++)
    {              
        // Is the checkbox checked? 
        var inputItem = numOfItems[i]; 
        if ( (inputItem.type == 'checkbox') && (inputItem.checked == true) )    
        {
            count = count + 1;
        }
    }   
    
    if ((count != 0)||(ddlActivityDomain.options[ddlActivityDomain.selectedIndex].value != "0")||
        ((txtKeywords.value != "")&&(txtKeywords.value != oDefaultText))||(ddlRegion.options[ddlRegion.selectedIndex].value != "0")||
        (/*txtPublicationDate.value != ""*/ ddlPublicationDate.options[ddlPublicationDate.selectedIndex].value != "0"))        
    {
        oTested=true;
        arguments.IsValid = true;  
        event.cancelBubble = true;
        return;              
    }
    else
    {
        oTested=true;
        arguments.IsValid = false;
        event.cancelBubble = true;
    }
}
//malfieri
function validateMinimumAlertCriteria(source, arguments)
{   
   var cblContractType = document.getElementById(oCblContractType);
   var ddlActivityDomain = document.getElementById(oDdlActivityDomain);   
   var txtKeywords = document.getElementById(oTxtKeywords);
   var ddlRegion = document.getElementById(oDdlRegion);   
   var ddlPublicationDate = document.getElementById(oDdlPublicationDate); 
   //var txtPublicationDate = document.getElementById(otxtPublicationDate);  
   var ddlPublicationDate = document.getElementById(oDdlPublicationDate);  
   var i = 0;
   var count = 0;
   var numOfItems =  cblContractType.getElementsByTagName('input');        
   var ddlFrequency = document.getElementById(oDdlFrequency);   
  
    // Loop through the checkboxes in the list.
    for(i = 0; i < numOfItems.length; i++)
    {              
        // Is the checkbox checked? 
        var inputItem = numOfItems[i]; 
        if ( (inputItem.type == 'checkbox') && (inputItem.checked == true) )    
        {
            count = count + 1;
        }
    }          
    
    if ((count != 0)||(ddlActivityDomain.options[ddlActivityDomain.selectedIndex].value != "0")||
        ((txtKeywords.value != "")&&(txtKeywords.value != oDefaultText))||(ddlRegion.options[ddlRegion.selectedIndex].value != "0")||
        (/*txtPublicationDate.value != ""*/ ddlPublicationDate.options[ddlPublicationDate.selectedIndex].value != "0"))
    {		
		arguments.IsValid = true;  
		return;              		
    }    
    else 
    {
        arguments.IsValid = false;
    }
}
//malfieri
function validateFrequency(source,arguments)
{
	var ddlFrequency = document.getElementById(oDdlFrequency);
	
	if (ddlFrequency != null)
	{
		if (ddlFrequency.options[ddlFrequency.selectedIndex].value != "0")
		{
			arguments.IsValid = true;  
			return;              
		}
		else
		{
			arguments.IsValid = false;
		}
	}
}


// Change title of SEO pages in the following sites: 'BranchDetailView' and 'Details-de-l-Agence'.
// Only it will change title in detail pages of previous sites.
//CR 197203
function ChangeTitle()
{
    var sUrl = location.href;
      if((sUrl.indexOf("BranchDetailView.aspx") > -1 )||(sUrl.indexOf("Details-de-l-Agence.aspx") > -1))
      {
        //Change the page title
        if(navigator.appName=="Netscape")
        {
            var lblDescription = document.getElementById('lblDescription').textContent;
            var lblTown = document.getElementById('lblTown').textContent;
        }
        else
        {
            var lblDescription = document.getElementById('lblDescription').childNodes(0).data;
            var lblTown = document.getElementById('lblTown').childNodes(0).data;
        }
         document.title = 'Travail temporaire et Agence Emploi a ' + lblTown + ' - ' + lblDescription;
           
      }

}

