
function Subject_UserContactForm(source, arguments)
{	
	var oObject = document.getElementById(source.controltovalidate);

    if (oObject.selectedIndex != "0")	
	    arguments.IsValid = true;
        
	else	
        arguments.IsValid = false;	
        
    return;
}


/*Validation for OA phone number format*/


function ClientValidate(source, clientside_arguments)
   {     
    var regEx=/^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$/; /*/^0\d{2,4}[ -][\d -]{6,9}$/;*/
    var re= new RegExp(regEx);
    var m = re.exec(document.getElementById(oInputPhone).value);
    if(m!=null)
        clientside_arguments.IsValid=true;
    else
        clientside_arguments.IsValid=false;
  }
  
/************************/
/*Form WSK-Common fr    */
/************************/
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 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;
    } 
}

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 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")||
        (ddlPublicationDate.options[ddlPublicationDate.selectedIndex].value != "0"))        
    {
        arguments.IsValid = true;  
        return;              
    }
    else
    {
        arguments.IsValid = false;
    }
}

/*************************
	Video WebPart
**************************/

	function VideoPopUp(URL, WidthPopUp, HeightPopUp)
	{
		
		if (WidthPopUp == "")
			WidthPopUp = "450";
			
		if (HeightPopUp == "")
			HeightPopUp = "400";
			
		var options = "width=" + WidthPopUp + " , height=" + HeightPopUp + " , toolbar=NO, location=NO, directories=NO, status=NO, menubar=NO, scrollbars=NO, resizable=NO, left=300, top=200";
		
		window.open("/CAPPages/VideoPopUp.aspx?VideoURL=" + URL + "&VideoWidth=" + WidthPopUp + "&VideoHeight=" + HeightPopUp, "VideoPopUp", options);				
	}
	
/*************************
	End. Video WebPart
**************************/

/*************************
	SendPageToFriend WebPart
**************************/

   window.onload = WindowOpener;

    function WindowOpener()
    {     
        control = document.getElementById(oURLOpener);
        control.value = window.opener.location.href;
        
        window.resizeTo(400,500);
        
        return false;
    }

/*****************************
 End. SendPageToFriend WebPart
******************************/
