﻿/* Show-Hide panel sub Attributes */
function showHidePanelSubAttributes(  idSubAttributesPanel , idClosePanel  )
{
  var subAttributesPanel = document.getElementById(idSubAttributesPanel); 
  var closePanel = document.getElementById(idClosePanel);

  if ( subAttributesPanel.style.display == 'block' )
  {
    subAttributesPanel.style.display = 'none';
    closePanel.style.display = 'none';
  }
  else
  {
    subAttributesPanel.style.display = 'block';
    closePanel.style.display = 'block';
  }
}

/* Hide panel sub Attributes */
function hidePanelSubAttributes( idSubAttributesPanel , idClosePanel )
{
  var subAttributesPanel = document.getElementById(idSubAttributesPanel); 
  var closePanel = document.getElementById(idClosePanel);
  
  subAttributesPanel.style.display = 'none';
  closePanel.style.display = 'none';
}

/* Upadte checked SubAttributes Number */
function upChSuAtNu( idLblCo, thisChk, checkParentAttribute, idParentChk )
{ 
  var lblCo = document.getElementById(idLblCo);
  var spans = lblCo.getElementsByTagName('span');
  //var labelMaxValue = document.getElementById(idLabelMaxValue);
  //var labelCurrentCheckedValue = document.getElementById(idLabelCurrentCheckedValue);
  var labelMaxValue = spans[1];
  var labelCurrentCheckedValue = spans[0];
  var chkParentObject = document.getElementById(idParentChk+"_chkV");
   
  var chkChecked = thisChk.checked;
  
//  if(labelCurrentCheckedValue.innerHTML == "")
//  {
//    var currentCheckedNumber = 0;
//  }
//  else
//  {
//    var currentCheckedNumber = Number(labelCurrentCheckedValue.innerHTML);
//  }
  
  if (chkChecked)
  {
//    currentCheckedNumber++;
//    if ( (currentCheckedNumber == 1) && (labelMaxValue.innerHTML.match("di") == null ) )
//    {
//      labelMaxValue.innerHTML = " di " + labelMaxValue.innerHTML; 
//    }    
    if( checkParentAttribute == 1 )
    {    
      chkParentObject.checked = true;
    }
  }  
//  else  
//  {
//    currentCheckedNumber--;
//  }
  
//  labelCurrentCheckedValue.innerHTML = currentCheckedNumber.toString();
}

/* Check all SubAttributes to checked or not checked */
function chkUnchkAllSubAtt( idChkAttribute , idPnlAttributes, checkSubAttributes)
{
  var chkAttribute = document.getElementById(idChkAttribute+"_chkV"); 
  var pnlAttributes = document.getElementById(idPnlAttributes); 
  var tagCollection = pnlAttributes.getElementsByTagName("input");
//  var labelMaxValue = document.getElementById(idLabelMaxValue);
//  var labelCurrentCheckedValue = document.getElementById(idLabelCurrentCheckedValue);
  var i;
  
  if(checkSubAttributes == 'False')
  {
    if(chkAttribute.checked)
      pnlAttributes.style.display = 'block';
    else
      pnlAttributes.style.display = 'none';
  }
  else
  {
//    if ( labelMaxValue.innerHTML.match("di") == null )
//    {
//      labelMaxValue.innerHTML = " di " + labelMaxValue.innerHTML; 
//    }  
    
    if(chkAttribute.checked)
    {
      //labelCurrentCheckedValue.innerHTML = tagCollection.length; 
      for(i=0; i<tagCollection.length; i++)
      {
        tagCollection[i].checked = true;
      }
      pnlAttributes.style.display = 'block';  
    }
    else
    {
      //labelCurrentCheckedValue.innerHTML = "0";
      for(i=0; i<tagCollection.length; i++)
      {
        tagCollection[i].checked = false;
      }
      pnlAttributes.style.display = 'none';  
    }       
  }
}

function chkExcAtt(idChkAtt, chkSubAtt, idPnlAttributes)
{
  var controlProfession = document.getElementById('elementContainer');
  var chkAtt = document.getElementById(idChkAtt + "_chkV");  
  var tagCollection = controlProfession.getElementsByTagName("input");
  var pnlAttributes = document.getElementById(idPnlAttributes);
  
  if(pnlAttributes!=null)
  {
    if(chkAtt.checked)
      pnlAttributes.style.display = 'block';
    else
      pnlAttributes.style.display = 'none';
  }
    
  for(i=0; i<tagCollection.length; i++)
  {    
    if(chkSubAtt == null)
    {
      if( (tagCollection[i].id != chkAtt.id) )
        tagCollection[i].checked = false;
    }
    else
    {
      if( (tagCollection[i].id != chkAtt.id) && (tagCollection[i].id != chkSubAtt.id) )
        tagCollection[i].checked = false;
    }    
  }
}

function setCurrentVisibleField()
{ 
  var objForm = document.forms['form1'];
  var mainTelephone = document.getElementById('fwCandidate_ddlMainTelephone');
  
  if( mainTelephone.value == 1 )      
  {
    document.getElementById('telHomeMandatory').style.visibility='visible';    
    document.getElementById('telMobileMandatory').style.visibility='hidden'; 
  }
  else if( mainTelephone.value == 2 )      
  {
    document.getElementById('telHomeMandatory').style.visibility='hidden';   
    document.getElementById('telMobileMandatory').style.visibility='hidden';
  }  
  else if( mainTelephone.value == 3 )      
  {
    document.getElementById('telHomeMandatory').style.visibility='hidden';    
    document.getElementById('telMobileMandatory').style.visibility='visible';
  }
  else
  {
    document.getElementById('telHomeMandatory').style.visibility='hidden';    
    document.getElementById('telMobileMandatory').style.visibility='hidden';
  }
}


function telephoneContactManage()
{  
  var mainTelephone = document.getElementById('fwCandidate_ddlMainTelephone');
 
  if( mainTelephone.value == 1 )      
  {
    document.getElementById('telHomeMandatory').style.visibility='visible';    
    document.getElementById('telMobileMandatory').style.visibility='hidden'; 
  }
  else if( mainTelephone.value == 3 )      
  {
    document.getElementById('telHomeMandatory').style.visibility='hidden';    
    document.getElementById('telMobileMandatory').style.visibility='visible';
  }
  else
  {
    document.getElementById('telHomeMandatory').style.visibility='hidden';    
    document.getElementById('telMobileMandatory').style.visibility='hidden';
  }
}

function setEmail()
{
  var objForm = document.forms['form1'];
  var txtEmail = objForm.wucGenericSubscriberRegistration$txtEmail$txtValue;
  var txtEmailDemand = objForm.wucGenericSubscriberRegistration$txtEmailDemand$txtValue;
  
  txtEmailDemand.value = txtEmail.value;
}

function showHideAdvanceSearchBox(idTitle, idBox, idHiddenField)
{   
  titleClassName = document.getElementById(idTitle).className;
	boxClassName = document.getElementById(idBox).className;	
			  
  if (titleClassName == 'advanceSearchBoxTitleClose')
  {    
    document.getElementById(idTitle).className = 'advanceSearchBoxTitleOpen';
    document.getElementById(idBox).className = 'advanceSearchBoxVisible';    
  }
  else
  {
    document.getElementById(idTitle).className = 'advanceSearchBoxTitleClose';
    document.getElementById(idBox).className = 'advanceSearchBoxHide';    
  }
}

/* paypal */
function CheckDataDoSubmit( siteName, url )
{
  
  var form = document.getElementById("form1");
  var hidItemName = document.getElementById("hidItemName");
  var hidAmount = document.getElementById("hidAmount");  
  var hidCreditToUpdate = document.getElementById("hidCreditToUpdate");
  var rd1 = document.getElementById("rd1");
  var rd2 = document.getElementById("rd2");
  var rd3 = document.getElementById("rd3");
  var rd4 = document.getElementById("rd4");
  var rd5 = document.getElementById("rd5");
  var rd6 = document.getElementById("rd6");
  var rd7 = document.getElementById("rd7");
  var rd8 = document.getElementById("rd8");      
  
  if( !rd1.checked && !rd2.checked && !rd3.checked && !rd4.checked && !rd5.checked && !rd6.checked && !rd7.checked && !rd8.checked )
  {
    alert( "Selezionare un valore!" );    
    return false;
  }
  
  if( rd1.checked)
    hidAmount.value = rd1.value;
  else if( rd2.checked)
    hidAmount.value = rd2.value;
  else if( rd3.checked)
    hidAmount.value = rd3.value;
  else if( rd4.checked)
    hidAmount.value = rd4.value;
  else if( rd5.checked)
    hidAmount.value = rd5.value;
  else if( rd6.checked)
    hidAmount.value = rd6.value;
  else if( rd7.checked)
    hidAmount.value = rd7.value;
  else if( rd8.checked)
    hidAmount.value = rd8.value;                        
    
  hidAmount.value = hidAmount.value + ".00";
  hidItemName.value = "Acquisto crediti - " + siteName;
  form.action = url;
  
  hidCreditToUpdate.value = hidAmount.value;
    
  form.submit();
  
}


function openUtest()
{
  var w = 780;
  var h = 550;
  var l = Math.floor((screen.width-w)/2);
  var t = Math.floor((screen.height-h)/2);
  myUrl= "./Utest/Default.aspx";
  popupWindow = window.open( myUrl, '_utest', 'width=' + w + ',height=' + h + ",top=" + t + ",left=" + l + ',status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1' );
  popupWindow.focus();    
}


function videoCVRecord()
{
  var w = 760;
  var h = 430;
  var l = Math.floor((screen.width-w)/2);
  var t = Math.floor((screen.height-h)/2);
  myUrl= "VideoRecorder.aspx";
  popupWindow = window.open( myUrl, null, 'width=' + w + ',height=' + h + ",top=" + t + ",left=" + l + ',status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0' );
  popupWindow.focus();    
}


function videoPlay( downloadIdentifier )
{
  var videoplayerwindow = window.open( 'VideoPlayer.aspx?identifier=' + downloadIdentifier, 'play', 'width=470px,height=450px,toolbar=no,location=, status=no,menubar=no,scrollbars=no,resizable=yes,top=200,left=300' );
  videoplayerwindow.focus();
}

function videoPlayNoPopup( downloadIdentifier )
{
  window.location.href = 'VideoPlayer.aspx?identifier=' + downloadIdentifier;
  videoplayerwindow.focus();
}

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}	    

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        { 
            c_start=c_start + c_name.length+1; 
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        } 
    }
    return "";
}

function openForgottenPassword()
{
  var w = 380;
  var h = 200;
  var l = Math.floor((screen.width-w)/2);
  var t = Math.floor((screen.height-h)/2);
  myUrl= "ForgottenPassword.aspx";
  popupWindow = window.open( myUrl, null, 'width=' + w + ',height=' + h + ",top=" + t + ",left=" + l + ',status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1' );
  popupWindow.focus();    
}

function videoResponderOpen( idJobOffer )
{
  var w = 760;
  var h = 430;
  var l = Math.floor((screen.width-w)/2);
  var t = Math.floor((screen.height-h)/2);
  if ( idJobOffer != null )
    myUrl= "VideoResponder.aspx?mode=i&idJobOffer=" + idJobOffer;
  else
    myUrl= "VideoResponder.aspx?mode=i&questionType=expert";
  popupWindow = window.open( myUrl, null, 'width=' + w + ',height=' + h + ",top=" + t + ",left=" + l + ',status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0' );
  popupWindow.focus();    
}


function setFiled()

{
    valueToSet= document.getElementById('fwCompany_txtEmail').value;
    document.getElementById('fwCompany_txtSubmissionEmail').value = valueToSet;
}

function sendToFriend() 
{
    var url = window.location.href;    
    var w = 440;
    var h = 490;
    var l = Math.floor((screen.width-w)/2);
    var t = Math.floor((screen.height-h)/2);
    var pageUrl= "SendToFriend.aspx?sendUrl=" + url;
    popupWindow = window.open( pageUrl, '', 'width=' + w + ',height=' + h + ",top=" + t + ",left=" + l + ',status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1' );
    popupWindow.focus();         
}

function sendAllFriends() 
{
    var url = window.location.href;    
    var w = 440;
    var h = 450;
    var l = Math.floor((screen.width-w)/2);
    var t = Math.floor((screen.height-h)/2);
    var pageUrl= "SendAllFriends.aspx?sendUrl=" + url;
    popupWindow = window.open( pageUrl, '', 'width=' + w + ',height=' + h + ",top=" + t + ",left=" + l + ',status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1' );
    popupWindow.focus();         
}

function signal() 
{
    var w = 440;
    var h = 280;
    var l = Math.floor((screen.width-w)/2);
    var t = Math.floor((screen.height-h)/2);
    var pageUrl= "Signal.aspx?";
    popupWindow = window.open( pageUrl, '', 'width=' + w + ',height=' + h + ",top=" + t + ",left=" + l + ',status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1' );
    popupWindow.focus();         
}

function message(idCandidate, idCompany) 
{
    var w = 440;
    var h = 280;
    var l = Math.floor((screen.width-w)/2);
    var t = Math.floor((screen.height-h)/2);
    var pageUrl;
    if(idCandidate > 0)
      pageUrl= "Message.aspx?idCandidate=" + idCandidate;
    else if(idCompany > 0)
      pageUrl= "Message.aspx?idCompany=" + idCompany;
    popupWindow = window.open( pageUrl, '', 'width=' + w + ',height=' + h + ",top=" + t + ",left=" + l + ',status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1' );
    popupWindow.focus();         
}

/** Animazione in homepage **/
function goToPage(path)
{
	window.parent.document.location = path; 
}


function openPopUp(path)
{
	Lightview.show({
      href: path,
      rel: 'iframe',
      title: '',
      caption: '',
      options: 
      {
        autosize: true,
        topclose: false,
        width:480,
        height:285        
      }
  });
}


function onLoad()
{
  var w = 485;
  var h = 285;
  var l = Math.floor((screen.width-w)/2);
  var t = Math.floor((screen.height-h)/2);	 
	homepromotionPopup = window.open( 'html/homepromotion.htm', 'POPUP', 'width=' + w + ',height=' + h + ",top=" + t + ",left=" + l + ',status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1' );
	homepromotionPopup.opener.focus();	
}	


function diplayHomeVideoPromo()
{
  var randomnumber=Math.floor(Math.random()*7);
  var flvname= "video_promo_" + randomnumber + ".flv";
  var vpimage= "video_grab_vp_" + randomnumber + ".jpg";
  document.write("<embed height='203' width='250' flashvars='width=250&height=203&file=../YOUCV/" + flvname + "&image=../../App_Themes/YOUCV/images/" + vpimage +"' allowfullscreen='true' allowscriptaccess='always' src='movies/Common/mediaplayer.swf'></embed>"); 
}


function UpperCaseWords(str) 
{ 
  arrStr = str.split(" ");
  var strOut = "";

  for (i=0;i<arrStr.length;i++)
  {       
    firstChar = arrStr[i].substring(0,1);
    remainChar = arrStr[i].substring(1);

    firstChar = firstChar.toUpperCase(); 
    remainChar = remainChar.toLowerCase();

    strOut += firstChar + remainChar + ' ';
  }

  return strOut.substring(0, strOut.length - 1);
}
