//google analytics old code
//var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
//document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//try {
//var pageTracker = _gat._getTracker("UA-15956257-1");
//pageTracker._trackPageview();
//} catch(err) {}

//google analytics new
	//workaround for JSON in stupid IE 
  var isIEx  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
  	var isWins = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
  	if(isIEx && isWins){
  		var scriptsrc = window.location.protocol+'//'+window.location.host+'/includes/3rd/json2/json2.js';
  		document.write('<script type="text/javascript" src="'+scriptsrc+'"></scr' + 'ipt>');
 		//The reason for having "</scr' + 'ipt>" instead of "</script>" in the document.write in the script is simply that IE 7 would 
  		//interpret "</script>" as the end of the script, even though it is enclosed in quotes and is part of a string. Breaking "</script>" 
  		//into two parts gets round this problem.
  	}	
  	
// for swf's
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function ControlVersion()
{
	var version;
	var axo;
	var e;
	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in
	// the registry
	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}
	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through
			// 6.0.29,
			// so we have to be careful.
			
			// default to the first public version
			version = "WIN 6,0,21,0";
			// throws if AllowScripAccess does not exist (introduced in 6.0r47)
			axo.AllowScriptAccess = "always";
			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}
// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that
// version or greater is available

function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];
	// is the major.revision >= requested major.revision AND the minor version
	// >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}
function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }
  document.write(str);
}
function Ret_AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }
  return str;
}
function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function Ret_AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  return Ret_AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    
    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
// //////////////

//globals for jquery labels
var selopttxt="select";
var jq_dialog_salva ="Salva";
var jq_dialog_close="Close";
var jq_dialog_yes="Si";
var jq_dialog_no="No";
var jq_dialog_confirm="Conferma";
var jq_dialog_cancel="Anulla";

selopttxt = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=lbl_choose');
jq_dialog_salva = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.btn.save');
jq_dialog_close = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.btn.close');
jq_dialog_yes = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.btn.yes');
jq_dialog_no = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.btn.no');
jq_dialog_confirm=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.btn.confirm');
jq_dialog_cancel=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.btn.cancel');

function getUrlVars() { // function who retrive an associative array with url
						// variables.
	var vars = [], hash;
	var hashes = window.location.href.slice(
			window.location.href.indexOf('?') + 1).split('&');
	for ( var i = 0; i < hashes.length; i++) {
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}
	return vars;
};
function reloadUrlVars(){ // /function necesary for reloading page without url
							// vars for recording
	var loc = location.href;
	var pos = loc.search("&op=");
	var newLoc = loc.substring(0,pos);
	window.location = newLoc;
}

function resendConfrimationEmail(email){
	var resp = SjaxSendRequest('sendemailconfim', 'POST',
			'system/ajaxRequest.ajax.php', "email=" + email);
	$('.formMessage').eq(0).html("<div class='succesMailMesage'>"+resp+"</div>");
}
function resendConfrimationEmaillostPwd(email){
	var resp = SjaxSendRequest('sendemailconfim', 'POST',
			'system/ajaxRequest.ajax.php', "email=" + email);
	$('.FrmlostPwd').children($('.formMessage')).eq(0).html("<div class='succesMailMesage'>"+resp+"</div>");
}
function resendConfrimationEmailCompany(email){
	var resp = SjaxSendRequest('sendmailconfimcompany','POST',
			'system/ajaxRequest.ajax.php','email=' + email);
	$('.formMessage').eq(0).html("<div class='succesMailMesage'>"+resp+"</div>");
}

function refreshRegions(obj) {
	var CountryID = $(obj).val();
	var resp = SjaxSendRequest('countryregions', 'POST',
			'system/ajaxRequest.ajax.php', "id=" + CountryID);
	var ArrOptCombo = resp.split("#");
	var ArrID;
	var i = 0;
	var option = "<option value=''>" + $("#comboRegions option:first").text() + "</option>";
	if (ArrOptCombo.length > 1) {
		for (i = 0; i < ArrOptCombo.length; i++) {
			ArrID = ArrOptCombo[i].split("/");
			option += "<option value='" + ArrID[0] + "'>" + ArrID[1]
					+ "</option>";
		}
	}
	$("#comboRegions").html(option);
}

function onloadRegions(obj) {
	var CountryID = parseInt($(obj).val());
	if (!CountryID > 0) {
		var resp = SjaxSendRequest('countryregions', 'POST',
				'system/ajaxRequest.ajax.php', "id=" + CountryID);
		var ArrOptCombo = resp.split("#");
		var ArrID;
		var i = 0;
		var option = "<option value=''>" + $("#comboRegions option:first").text() + "</option>";
		if (ArrOptCombo.length > 1) {
			for (i = 0; i < ArrOptCombo.length; i++) {
				ArrID = ArrOptCombo[i].split("/");
				option += "<option value='" + ArrID[0] + "'>" + ArrID[1] + "</option>";
			}
		}
		$("#comboRegions").html(option);
	}
}

function bookmarkus() {
	var title = "FaceCV";
	var msg = "Press Ctrl+D to bookmark our site.";
	var loc = location.href;
	var pos = loc.search("index.php");
	var url = loc;
	if (pos>1){
		url = loc.substring(0,pos);
	}
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if (window.opera && window.print) { // opera
		//
	} else if (document.all){// ie
		window.external.AddFavorite(url, title);
	} else {
		msg=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=bookmark.alert');
		alert(msg);
	}	
		
}

function ValidateEmail(email) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if (reg.test(email) == false) {
		alert('Invalid Email Address');
		return false;
	} else {
		return true;
	}
}

function getMeetingDate(date,inst){
	//alert(date);
	if (document.location.href.indexOf("&ondate=")>0){
		window.location = document.location.href.replace(document.location.href.substr(document.location.href.indexOf("&ondate=")),"")+"&ondate="+date;
	}else{
		window.location = document.location.href + "&ondate=" + date;
	}
}
function getArrDateMeetings(datesString){// format string eg:
											// 08/06/2010|16/06/2010
	var i=0;
	var arrDateMeeting = datesString.split("|");
	for (i=0;i<arrDateMeeting.length;i++){
		arrDateMeeting[i] = arrDateMeeting[i].split("/");	
	}
	return arrDateMeeting;
}
function isDayMonthInArr(day,month,arr){
	var i=0;
	var ret = false;
	for (i=0;i<arr.length;i++){
		if (arr[i][1]==month && arr[i][0]==day){
			ret = true;
		}	
	}
	return ret;
}
function var_dump(obj) {
	   if(typeof obj == "object") {
	      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
	   } else {
	      return "Type: "+typeof(obj)+"\nValue: "+obj;
	   }
}
function setMeetingsDays(inst){
	if ($("#isCalUpdated").val()!='updated'){	
		var monthname = $(inst).find("span[class=ui-datepicker-month]").html();
		var month = parseInt(SjaxSendRequest('getnrmonth','POST','system/ajaxRequest.ajax.php','monthn='+monthname));
		var year = $(inst).find("span[class=ui-datepicker-year]").html();
		var meetingsDay = SjaxSendRequest('getMeetingsDay', 'POST','system/ajaxRequest.ajax.php', 'month='+month+'&year='+year);
		var arrDateMeeting = getArrDateMeetings(meetingsDay);
		// alert(arrDateMeeting[0][0]);
		var arrDayColors = [];
		arrDayColors[0] = "calendar_day_green";
		arrDayColors[1] = "calendar_day_orange";
		arrDayColors[2] = "calendar_day_blue";
		arrDayColors[3] = "calendar_day_gold";
		var i = 0;
		if (arrDateMeeting.length>0){
			$(inst).find("tr").each(function(){
				$(this).find("td").each(function(){// returnInteger(val)
					var day = returnInteger($(this).find("a:first").html());
					if (isDayMonthInArr(day,month,arrDateMeeting)){
						
						$(this).find("a:first").attr('class',arrDayColors[i]);
						i = (i+1)>3 ? 0 : (i+1);
					}	
				});
			});
		}
		$("#isCalUpdated").val('updated');
	}
}

$(".company_db_view,.company_search_profiles,.candidate_jobsSearch").ready(function(){
	var urlVars = getUrlVars();
	$("#accordion_form_search").show();
	if($("#CandSearchResults").children("div[id=pgNav]").length==0)
	{
		$(".clsaRefreshPage").hide();
	}
	if (returnInteger(urlVars["searchCode"]) > 0 && urlVars["content"] == "candidate_jobssearch"){
		$("#accordion_form_search").accordion({
			collapsible: true,
			active: false,
			autoHeight: false
		});
	}else 
	if (urlVars["bsSect"] != undefined || urlVars["specCat"] != undefined  || urlVars["jobSit"] != undefined  || 
		urlVars["optLang"] != undefined || urlVars["age"] != undefined || urlVars["edcField"] != undefined  || 
		urlVars["orgLevel"] != undefined || urlVars["keywordsSearch"] != undefined || urlVars["ocp1"] != undefined || 
		urlVars["ocp2"] != undefined || urlVars["ocp3"] != undefined || urlVars["pst1"] != undefined || urlVars["pst2"] != undefined || 
		urlVars["pst3"] != undefined || urlVars["yExp"] != undefined || urlVars["reggrp"] != undefined || urlVars["cities"] != undefined || urlVars["jobCtType"] != undefined
		|| urlVars["jobWhours"] != undefined || urlVars["edcOrgType"] != undefined  || ($("#Frm_candidate_jobs_search").attr("action") != undefined && $("#Frm_candidate_jobs_search").attr("action") != null)){
			$("#accordion_form_search").accordion({
				collapsible: true,
				active: false,
				autoHeight: false
			});
	}else{
		$("#accordion_form_search").accordion({
			collapsible: true,
			autoHeight: false
		});
	}
	if (urlVars["ra"] != undefined)
	{
		$("#accordion_form_search").accordion("option","collapsible",true);
		$("#accordion_form_search").accordion("option","active",0);	
	}
	if (urlVars["searchCode"] != undefined){
		//getSavedResults(urlVars["searchCode"]);
	}	
	$("#pgNav").tabs();
	$(".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *") 
		.removeClass("ui-corner-all ui-corner-top") 
		.addClass("ui-corner-bottom");
});
function giveStar(points){
	$("#HdnfeedbackPoints").val(points);
	var i = 1;
	$(".starControl").each(function(){
		if (i<=parseInt(points)){
			$(this).css("background-position","0 0");
		}else{
			$(this).css("background-position","0 -20px");
		}
		i++;
	});
}
function giveStarHover(points){
	var i = 1;
	$(".starControl").each(function(){
		if (i<=parseInt(points)){
			$(this).css("background-position","0 0");
		}else{
			$(this).css("background-position","0 -20px");
		}
		i++;
	});
}
function giveStarOut(){
	points = $("#HdnfeedbackPoints").val();
	var i = 1;
	$(".starControl").each(function(){
		if (i<=parseInt(points)){
			$(this).css("background-position","0 0");
		}else{
			$(this).css("background-position","0 -20px");
		}
		i++;
	});
}
function stopBrandsAnimation()
{
	if ($("#txthidenSpeedAnim").val()!="stop"){
		$("#txthidenSpeedAnim").val(0);
	}
}
function startAnimation()
{
	if ($("#txthidenSpeedAnim").val()!="stop"){
		$("#txthidenSpeedAnim").val(2);
	}
}
function bandAnimation(ContainerId,ChildrenClass,limitDown)
{
	if (($("#"+ContainerId).html() != undefined || $("#"+ContainerId).html() != null) && $("#"+ContainerId).find("div[class="+ChildrenClass+"]").length >limitDown)
	{
		//$("#brands_moving_band").css("width",parseInt($("#brands_moving_band").find("div[class=brand_line]").length)*100);
		$("#txthidenBigestPos").val(0);
		$("#txthidenSpeedAnim").val(2);
		var container = $("#"+ContainerId);
		var hddBigPos = $("#txthidenBigestPos");
		var hddSpeed = $("#txthidenSpeedAnim");
		setInterval(function(){
			var lastPos = 0;
			container.children("div[class="+ChildrenClass+"]").each(function(){
				if(parseInt($(this).css("left"))<-100){
					$(this).css("left",parseInt(hddBigPos.val()));
				}else{
					$(this).css("left",parseInt($(this).css("left"))-parseInt(hddSpeed.val()));
				}
				//set the bigest position
				if (parseInt(hddBigPos.val()) <= parseInt($(this).css("left")))
				{
					hddBigPos.val($(this).css("left").replace("px",""));
				}
			});
		},40);
	}
}
function bandAnimationHome(ContainerId,ChildrenClass)
{
	if (($("#"+ContainerId).html() != undefined || $("#"+ContainerId).html() != null))
	{
		//$("#brands_moving_band").css("width",parseInt($("#brands_moving_band").find("div[class=brand_line]").length)*100);
		$("#txthidenBigestPos").val(0);
		if ($("#txthidenSpeedAnim").val()!="stop"){
			$("#txthidenSpeedAnim").val(2);
		}
		var container = $("#"+ContainerId);
		var width = parseInt($("#logosContainer_1").find("div[class=img_horiz_banner_holder]").length)*101;
		var container1 = $("#logosContainer_1");
		var container2 = $("#logosContainer_2");
		var hddBigPos = 0;//$("#txthidenBigestPos");
		var hddSpeed = $("#txthidenSpeedAnim");
		setInterval(function(){
			if (hddSpeed.val()!="stop"){
				if(parseInt(container1.css("left"))<-width){
					container1.css("left",parseInt(hddBigPos));
				}else{
					//console.log(container1.attr("id")+container1.css("left"));
					container1.css("left",parseInt(container1.css("left"))-parseInt(hddSpeed.val()));
				}
				if(parseInt(container2.css("left"))<-width){
					container2.css("left",parseInt(hddBigPos));
				}else{
					//console.log(container2.attr("id")+container2.css("left"));
					container2.css("left",parseInt(container2.css("left"))-parseInt(hddSpeed.val()));
				}
				if (parseInt(hddBigPos) <= parseInt(container1.css("left")))
				{
					//hddBigPos.val(container1.css("left").replace("px",""));
					hddBigPos = container1.css("left").replace("px","");
				}else if (parseInt(hddBigPos) <= parseInt(container2.css("left")))
				{
					//hddBigPos.val(container2.css("left").replace("px",""));
					hddBigPos = container2.css("left").replace("px","");
				}
			}
		},40);
	}
}
$(document).ready(
		function() {
			var requestVars = getUrlVars();
			//selectDropDownIEbehavior(); for craps of selectbox in IE
			 addTooltipToSelect(); //needed to populate select box tooltips for IE
			/*$(".accordionSelect").accordion({
				autoHeight: false,
				navigation: true,
				collapsible: true
			});*/
			
			//script for brands band animation
			if(($("#company_brandsBand").html() != undefined && $("#company_brandsBand").html() != null) && $("#company_brandsBand").find("div[class=brand_line]").length >0)
			{
				$("#company_brandsBand").find("img[class=thumbnail]").each(function(){
					var top = Math.floor((60 - $(this).attr("height"))/2);
					$(this).css({"top":top+"px"});
				});
			}
			//remove from brands page mesage for no brands
			//align verticaly the pictures
			if($("#CandSearchResults").html() != undefined && $("#CandSearchResults").html() != null && $("#CandSearchResults").find("div[class=searchRow]").length >0)
			{
				$("#pgNav").find("img[class=thumbnail]").each(function(){
					var top = Math.floor((50 - $(this).attr("height"))/2);
					$(this).css({"top":top+"px"});
				});
			}
			if($("#list_companies").html() != undefined && $("#list_companies").html() != null && $("#list_companies").find("div[class=list_companies_li]").length >0)
			{
				$("#list_companies").find("img[class=thumbnail]").each(function(){
					var top = Math.floor((40 - $(this).attr("height"))/2);
					$(this).css({"top":top+"px"});
				});
			}
			if(($('#brandsList').html() != undefined && $('#brandsList').html() != null) && $('.noRecords').html() != undefined && $('.noRecords').html() != null )
			{
				$('.noRecords').hide();
				$('#langHelpbrandvisibility').hide();
			}
			hideHelpBtnBrandvisibility();
			bandAnimation("company_brandsBand","brand_line",6);
			//end script for brands band animation
			//script for home logos animation
			if(($(".logosContainer").html() != undefined && $(".logosContainer").html() != null) && $(".logosContainer").find("div[class=img_horiz_banner_holder]").length >9){
				$(".logosContainer").find("div[class=img_horiz_banner_holder]:last").css("border-right","1px solid #999999");
			}
			bandAnimationHome("hp_horiz_banner","logosContainer");
			//end script for home logos animation
			//script for provincia and regione on company search cand form
			if((requestVars["content"]=="company_db_view") && (requestVars["reg"]!=undefined && requestVars["reg"].length>0))
			{
				$("#regionSelect").addClass("acctiveSearch");
				$("#provinceSelect").removeClass("acctiveSearch");
				$("#seldb_view_Region").css("display","");
				$("#seldb_view_Region").removeClass("inacctive");
				$("#seldb_view_Provincia").addClass("inacctive");
				
			}
			//end script for provincia and regione on company search cand form
			//script for regiongroup and region on candidate jobs search form

			if((requestVars["content"]=="quicksearch" || requestVars["content"]=="candidate_jobssearch" || requestVars["content"]=="candidate_job_alert"))
			{
				if (requestVars["reggrp"]!=undefined && requestVars["reggrp"].length>0){
				$("#regionGroupSelect").addClass("acctiveSearch");
				$("#regionSelect").removeClass("acctiveSearch");
				$("#seljobs_search_RegionGroup").css("display","");
				$("#seljobs_search_RegionGroup").removeClass("inacctive");
				$("#seljobs_search_Region").addClass("inacctive");
				$("#citySelect").removeClass("acctiveSearch");
				$("#txtjobs_search_WorkplaceDescription").addClass("inacctive");
				}else if (requestVars["cities"]!=undefined && requestVars["cities"].length>0){
					
				$("#regionGroupSelect").removeClass("acctiveSearch");
				$("#regionSelect").removeClass("acctiveSearch");
				$("#seljobs_search_RegionGroup").addClass("inacctive");
				$("#seljobs_search_Region").addClass("inacctive");
				$("#citySelect").addClass("acctiveSearch");
				$("#txtjobs_search_Workplace").removeClass("inacctive");
				$("#txtjobs_search_WorkplaceDescription").css("display","");
				}else{
					$("#txtjobs_search_WorkplaceDescription").val('Torino [Piemonte], Milano [Lombardia],ecc. ');
					$("#txtjobs_search_WorkplaceDescription").css("color","#999999");
				}
			}
			//end script for regiongroup and region on candidate jobs search form
			if($("#CandSearchResults").html != undefined && $("#CandSearchResults").html != null && $("#CandSearchResults").find("[class=noRecords]").length>0)
			{
				$(".headerSearchResults").hide();
			}
			if ($(".img_horiz_banner_holder").html != undefined && $(".img_horiz_banner_holder").html != null)
			{
				$(".img_horiz_banner").each(function(){
					//alert($(this).attr("height"));
					var top = Math.floor((60 - $(this).attr("height"))/2);
					$(this).css({"top":top+"px"});
				});
			}
			if ($("#ServerClock").html() != undefined && $("#ServerClock").html() != null){
				var serverTime = SjaxSendRequest('getservertime', 'POST','system/ajaxRequest.ajax.php', 'month=1');
				serverTime = serverTime.split("/");
				if (serverTime[4][0]=="0"){
					serverTime[4] = serverTime[4][1];
				}
				if (serverTime[5][0]=="0"){
					serverTime[5] = serverTime[5][1];
				}
				var dt = new Date(serverTime[0], parseInt(serverTime[1])-1, parseInt(serverTime[2]), serverTime[3], parseInt(serverTime[4]),parseInt(serverTime[5]),0);
				var startDate = new Date();
				var now = "";
				setInterval(function(){
					now = new Date();
					dt.setTime(dt.getTime()+(now.getTime()-startDate.getTime()));
					$("#serverHour").html(dt.getHours()); 
					if (dt.getMinutes()<10){
						$("#serverMinutes").html("0"+dt.getMinutes()); 
					}else{
						$("#serverMinutes").html(dt.getMinutes()); 
					}
					
					startDate = new Date();
					now = null;
				},1000);
			}
			var urlVars = getUrlVars();
			
			//remove the header of tabel in appliedjobs page
			if(($('#Frmcandidate_appliedjobs').html() != undefined && $('#Frmcandidate_appliedjobs').html() != null) && $('#Frmcandidate_appliedjobs').find('span[class=noRecords]').html() != undefined
				||($('#Frmcandidate_savedjobs').html() != undefined && $('#Frmcandidate_savedjobs').html() != null && $('#Frmcandidate_savedjobs').find('span[class=noRecords]').html() != undefined))
			{
				$('.headerSearchResults').hide();
			}
			
			$("body").after("<div style='display:none'><img src='../images/loading_btn.gif'/></div>");
			if (window.opera && window.print){	
				var loc = location.href;
				var pos = loc.search("index.php");
				var url = loc;
				if (pos>1){
					url = loc.substring(0,pos);
				}
				$("#addBookmark_container").html("<a href='"+url+"' rel='sidebar' id='btnBookmarkUs' title='Bookmark FaceCV'></a>");
			}
			if ($('#comboCountry').val() != undefined) {
				onloadRegions($('#comboCountry'));
			}
			hideOnLoadEducation();
			hideOnLoadWorkexperience();
			hideOnLoadLanguages();
			
			SlideDivs();
			
			
			if ($('#widget_profile_status').length > 0)
			{
				displayProgressBar();
			}
			
			if ($('#myfacecv_profile_statusid').length > 0)
			{
				displayProgressBar2();
			}
			
			if ($('#candidate_Raiting').length > 0)
			{
				displayRaiting();
			}
			if($('#starsControlPoints')){
				$("#HdnfeedbackPoints").val(1);
				var i = 1;
				$(".starControl").each(function(){
					if (i<=1){
						$(this).css("background-position","0 0");
					}
					i++;
				});
			}
			
			if ($('.userVideos').length>0) {
				var videoPolicy = SjaxSendRequest('getVideoPolicy', 'POST',
						'system/ajaxRequest.ajax.php', 'mss=1');
				if (videoPolicy != 1) {
					DisplayVideoPolicy();
				}
			}
			/*
			 * if (navigator.appVersion.toLowerCase().indexOf("mac")!=-1){
			 * DisplayVideoGuideMac(); }
			 */
			// set focus to txtEmail field on click login from feedback
			$("#feedback_login").click(function(){
				$("#txtEmail").focus();
			});
				
			$(function() {
				var btns = {};
				btns[jq_dialog_close]=function(){$(this).dialog("close");};
				$("#videohelp").dialog(
						{
						buttons:btns,
						autoOpen: false,
						closeOnEscape:true,
						closeText:""+jq_dialog_close,
						dialogClass:'highlight',
						draggable:true,
						minHeight:200,
						maxHeight:640,
						minWidth:300,
						maxWidth:960,
						width:800,
						height:600,
						modal:true,
						title:'title'
						});
				$("#langHelpa").dialog(
						{
						buttons:btns,
						//{"Chiudi": function(){$(this).dialog("close");}},
						autoOpen: false,
						closeOnEscape:true,
						closeText:""+jq_dialog_close,
						dialogClass:'highlight',
						draggable:true,
						minHeight:200,
						maxHeight:640,
						minWidth:300,
						maxWidth:960,
						width:400,
						height:600,
						modal:true,
						title:'title'
						});
				
				$("#langHelpaoldbrowser").dialog(
						{
						buttons:btns,
						autoOpen: false,

						closeOnEscape:true,
						closeText:""+jq_dialog_close,
						dialogClass:'highlight',
						draggable:true,
						minHeight:200,
						maxHeight:640,
						minWidth:300,
						maxWidth:960,
						width:400,
						height:600,
						modal:true,
						title:'title'
						});
				
				$("#langHelpacompatbrowser").dialog(
						{
						buttons:btns,
						autoOpen: false,

						closeOnEscape:true,
						closeText:""+jq_dialog_close,
						dialogClass:'highlight',
						draggable:true,
						minHeight:200,
						maxHeight:640,
						minWidth:300,
						maxWidth:960,
						width:400,
						height:600,
						modal:true,
						title:'title'
						});
				
				$("#loginmediumannouncemessage").dialog(
						{
						autoOpen: false,

						closeOnEscape:true,
						closeText:""+jq_dialog_close,
						dialogClass:'highlight',
						draggable:true,
						minHeight:200,
						maxHeight:640,
						minWidth:300,
						maxWidth:960,
						width:400,
						height:600,
						modal:true,
						title:'title'
						});
				
				$("#logincompatbrowsermessage").dialog(
						{
						buttons:btns,
						autoOpen: false,

						closeOnEscape:true,
						closeText:""+jq_dialog_close,
						dialogClass:'highlight',
						draggable:true,
						minHeight:200,
						maxHeight:640,
						minWidth:300,
						maxWidth:960,
						width:400,
						height:600,
						modal:true,
						title:'title'
						});
				
				$("#applytojob").dialog(
						{
						buttons:btns,
						autoOpen: false,

						closeOnEscape:true,
						closeText:""+jq_dialog_close,
						dialogClass:'highlight',
						draggable:true,
						minHeight:200,
						maxHeight:640,
						minWidth:300,
						maxWidth:960,
						width:400,
						height:600,
						modal:true,
						title:'title'
						});

				$("#applydirectly").dialog(
						{
						buttons:btns,
						autoOpen: false,
						closeOnEscape:true,
						closeText:""+jq_dialog_close,
						dialogClass:'highlight',
						draggable:true,
						minHeight:200,
						maxHeight:640,
						minWidth:300,
						maxWidth:960,
						width:400,
						height:600,
						modal:true,
						title:'title'
						});
				
				$("#helpripublicajob").dialog(
						{
						
						autoOpen: false,
						closeOnEscape:false,
						closeText:""+jq_dialog_close,
						dialogClass:'highlight',
						draggable:true,
						minHeight:200,
						maxHeight:640,
						minWidth:300,
						maxWidth:960,
						width:400,
						height:600,
						modal:true,
						title:'title'
						});
				$(".copyCVtoannunci").dialog(
						{	
						autoOpen: false,
						closeOnEscape:false,
						closeText:""+jq_dialog_close,
						dialogClass:'highlight',
						draggable:true,
						minHeight:200,
						maxHeight:640,
						minWidth:300,
						maxWidth:960,
						width:400,
						height:600,
						modal:true,
						title:'title'
						});
			
				var lang18n = libAWS.lang;
				if(lang18n == "en")
				{
					lang18n = "en-GB";
				}
				$.datepicker.setDefaults($.datepicker.regional[lang18n]);
				$("#MeetingsCalendar").datepicker({
						changeMonth: false,
						changeYear: false,
						showButtonPanel: false,
						stepMonths: 1,
						onSelect: function(dateText, inst) { getMeetingDate(dateText,inst);},
						onChangeMonthYear: function(year, month, inst) { 
							//console.log(inst);
							//alert(inst.dpDiv[0].childNodes[0].childNodes[2].childNodes[0].innerHTML);//setAttribute('class','calendar_day_green')
							//inst.dpDiv[0].setAttribute('onclick','setMeetingsDays("#MeetingsCalendar",0,0);');
							$("#isCalUpdated").val("");
						}
					});
				if ($('#MeetingsCalendar').html() != null){
					setMeetingsDays("#MeetingsCalendar");
				}
				$('#MeetingsCalendar').find("div:first").mouseover(function(){
					setMeetingsDays("#MeetingsCalendar");
				});
				$(".clsdetBirthDate, .clsBirthDate").datepicker({
					showOn: 'button',
					dateFormat:"dd/mm/yy",
					defaultDate: '01/01/1965',
					buttonImage: 'images/calendar.gif',
					buttonImageOnly: true,
					showButtonPanel: true,
					showMonthAfterYear:false,
					changeMonth:true,
					changeYear:true,
					stepMonths:120,
					minDate: new Date(1900,1,1),
					maxDate: '-15y'
					});
				// set datepicker for dates field for job search
				$("#txtcomManageJobs_toDate, #txtcomManageJobs_fromDate, #txthistoryStartDate, #txthistoryEndDate, .clsdetFromDate ,.clsdetToDate").datepicker({
					showOn: 'button',
					dateFormat:"dd/mm/yy",
					buttonImage: 'images/calendar.gif',
					buttonImageOnly: true,
					showButtonPanel: true,
					showMonthAfterYear:false,
					changeMonth:true,
					changeYear:true,
					stepMonths:120,
					minDate: new Date(2000,1,1)
					})	;
				
				$(".clsetFromDate,.clsetToDate,.clswe_fromdate,.clswe_todate").datepicker({
					showOn: 'button',
					dateFormat:"dd/mm/yy",
					buttonImage: 'images/calendar.gif',
					buttonImageOnly: true,
					showButtonPanel: true,
					showMonthAfterYear:false,
					changeMonth:true,
					changeYear:true,
					stepMonths:120,
					minDate: new Date(1900,1,1),
					maxDate: new Date()
					});
				
				
				$(".clsdetAvailableDate").datepicker({
					showOn: 'button',
					dateFormat:"dd/mm/yy",
					buttonImage: 'images/calendar.gif',
					buttonImageOnly: true,
					showButtonPanel: true,
					showMonthAfterYear:false,
					changeMonth:true,
					changeYear:true,
					stepMonths:120,
					minDate: new Date(),
					maxDate: '+10y'
				});
			});

			if ($('#txtwe_todate').val()==''){
				$('#txtwe_todate').attr('disabled', true);
				$('#txtwe_todate').datepicker("disable");
				$('#chkwe_notodate').attr('checked',true);
			}
			if ($('#txtetToDate').val()==''){
				$('#txtetToDate').attr('disabled', true);
				$('#txtetToDate').datepicker("disable");
				$('#chknoetToDate').attr('checked',true);
			}
			
			if ($('#txtdetDesiredSalary').val()==''){
				$('#txtdetDesiredSalary').attr('disabled', true);
				$('#chkdetSalaryConfidential').attr('checked',true);
			}
			if ($('#selcomAddJobs_Brand').val()==''){
				$('#selcomAddJobs_Brand').attr('disabled', true);
				$('#chkcomAddJobs_UseBrands').attr('checked',false);
			}
			if ($('#selcomAddJobs_RegionGroup').val()==''){
				$('#selcomAddJobs_RegionGroup').attr('disabled', true);
				$('#chkcomAddJobs_UseRegionGroup').attr('checked',false);
			}else{
				$('#txtcomAddJobs_WorkplaceDescription').attr('disabled',true);
			}
			if ($('#selcomAddJobs_Region').val()==''){
				$('#selcomAddJobs_Region').attr('disabled', true);
				$('#chkcomAddJobs_UseRegion').attr('checked',false);
			}else{
				$('#txtcomAddJobs_WorkplaceDescription').attr('disabled',true);
			}
			if ($('#txtdetAvailableDate').val()==''){
				$('#txtdetAvailableDate').attr('disabled', true);
				$('#txtdetAvailableDate').datepicker("disable");
				$('#chkdetAvailableAny').attr('checked',true);
			}
			$("#btnSubmit").click(function() {
				$(this).hide();
					$(this).after("<div class='loading_gif'><img width='50' height='50' src='../images/loading_btn.gif'/></div>");
			});
			
			checkifexistsComboValue();// function that populates the secondary
										// combo when editing an work experience
										// record.
			
			setProvinces('selcomReg_Country','selcomReg_Province');
			// setProvinces('selcomDetails_Country','selcomDetails_Province');
			if ($("#selcomDetails_Country").val()!="ITA")
			{
				var allvalues="<option class=\"selOptionOne\" value=\"\">"+selopttxt+"</option>";
				$("#selcomDetails_Province").html(allvalues);
					addTooltipToSelect();
			}
			if ($("#txtcomAddJobs_Days").val() != null || $("#selcomAddJobs_Months").val() != null || $("#selcomAddJobs_Year").val() != null){
				updateOffertToDate("offert_to_date");// update the offer of the
													// job announce
			}
			if ($("#txtcomAddTraining_Days").val() != null || $("#selcomAddTraining_Months").val() != null || $("#selcomAddTraining_Year").val() != null){
				updateTrainingToDate("training_to_date");// update the offer of the
													// job announce
			}
			includeTinyMCE();// includes the tinyMCE vars
			showManageJobFormOnLoad();// shows the job search form when is
										// needed.
			showmessageannunci();
			
			
			//following lines are needed in Conto FaceCV section for companies
			$('#recharge_promoc').hide();
			if ($('#recharge_promoc').html()!=null || $('#recharge_promoc').html()!=undefined){
			$('#toggle_promo').click(function() {
				$('.see_details').toggleClass("opened_div");
			   $('#recharge_promoc').toggle(400);
				    return false;
			  });
			}
			//following lines are needed in Altri Servizi section for companies
			
			$('.os_detail_list').hide();
			if ($('.os_detail_list').html()!=null || $('.os_detail_list').html()!=undefined){
				$('div[class=see_details]').click(function() {
					$('.see_details').toggleClass("opened_div");
					   $('.os_detail_list').toggle(400);
						    return false;
					  });	
			}

			//code for quick search on home page
			$("#txtLocationRegionGroupDescription").addClass("inacctive");
			mouseRegioneClick();
			mouseRegionGroupClick();
			mouseCityClick();
			mouseProvinceClick();
			setInterval(function(){
				
				if($(".pagerefreshcand").val() != null)
				{
					refreshcandidate();				
				}
				if($(".pagerefreshcandw").val() != null)
				{
					refreshwidgetcandidate();	
					$("#candidate_meetings_acordion").accordion({
						collapsible: true,
						autoHeight: false,
						active: false

					});
				}
				if($(".pagerefreshcomp").val() != null)
				{
					refreshcompany();	
				}
				if($(".pagerefreshcompw").val() != null)
				{
					refreshwidgetcompany();
					
					
						$("#company_meetings_acordion").accordion({
									collapsible: true,
									autoHeight: false,
									active: false

								});

					
				}
			},2*60*1000);
			
			showmessagebrowsercomp();
			showmessagefilialefirstlogin();
			showmessagemediumannouncelogin();
			showmessageoldbrowseronlogin();
			hideOnLoadFrmByVar("company_ag_area_merceologica_form","amid");
			hideOnLoadFrmByVar("company_ag_area_business_form", "abid");
			hideOnLoadFrmByVar("company_ag_project_form","pid");
			//back to top
			$('a[href=#top]').click(function(){
				 $('html, body').animate({scrollTop:0}, 'slow');
				 return false;
				});
			if ($(".home_job_title_link").html() != undefined && $(".home_job_title_link").html() != null){
			
			$(".home_job_title_link").tooltip({
				   offset: [2, 2],
				   effect: 'fade',
				   delay: 5,			   
				   events: {tooltip: "mouseenter,mouseleave"}				   
				}); 
			}
			//try to redirect the user back to the page from which started the shopping
			if ($(".company_pay_credits").html()!=undefined && $(".company_pay_credits").html()!=null ){
				var lnk_href=$(".company_pay_credits").find("#backToSearchLink a").attr("href");
				if (lnk_href==undefined){
					lnk_href=$(".company_pay_credits").find("#company_buy_back a").attr("href");
				}
				
				if (lnk_href!=undefined){
				var msgred1=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.redirect.msg1');
				var msgred2=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.redirect.msg2');
				var _urlvars=getUrlVars();
				if ((_urlvars["clearform"]!=undefined || _urlvars["clearform"]!=null)&& _urlvars["clearform"]==0){
					$(".content > div >ul:first").after("<div id='over_loading'>"+msgred1+" <a href='"+lnk_href+"'>"+msgred2+"</a></div>");
					setTimeout(function(){window.location = lnk_href;},3000);
				}
				}
			}

			candidateVideoRec();
			highlightProfilestateC();
			if ($("#selcomAddJobs_RegionGroup").html()!=undefined && $("#selcomAddJobs_RegionGroup").html()!=null){
				createListOfRegions($("#selcomAddJobs_RegionGroup"),$("#selcomAddJobs_RegionGroup").val());	
			}
			if ($("#selcomAddJobs_Region").html()!=undefined && $("#selcomAddJobs_Region").html()!=null){
			createListOfProvinces($("#selcomAddJobs_Region"),$("#selcomAddJobs_Region").val());
			}
	});//end of document.ready function

//generic function for redirect users back
function redirectBack(clsparent,idlnk){
	if ($("."+clsparent).html()!=undefined && $("."+clsparent).html()!=null ){
		var lnk_href=$("."+clsparent).find("#"+idlnk+" a").attr("href");
		if (lnk_href!=undefined){
			var msgred1=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.redirect.msg1');
			var msgred2=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.redirect.msg2');
			var _urlvars=getUrlVars();
			if ((_urlvars["clearform"]!=undefined || _urlvars["clearform"]!=null)&& _urlvars["clearform"]==0){
			$(".content > div >ul:first").after("<div id='over_loading'>"+msgred1+" <a href='"+lnk_href+"'>"+msgred2+"</a></div>");
			setTimeout(function(){window.location = lnk_href;},3000);
			}
		}
	}

}

function candidateVideoRec(){
	//candidate video questions:
	if ($("#cand_questions").html()!=null || $("#cand_questions").html()!=undefined){
	//	$(".customOrderList >div[id=customList"+$("#cand_questions").val()+"]").attr({style:'display:visible;'});
		var _urlvars=getUrlVars();
		var _1stvideo;
		if (_urlvars["question"]!=undefined || _urlvars["question"]!=null){
			$("#cand_questions").val(_urlvars["question"]);
			$(".customOrderList >div[id=customList"+_urlvars["question"]+"]").attr({style:'display:visible;'});
			$(".customOrderList >div[id=customList"+_urlvars["question"]+"] >div[class=customListContent]")
			.prepend("<div class='questText"+_urlvars["question"]+"'>"+$("#cand_questions option:selected").text()+"</div>");
			//if ((_urlvars["op"]!=undefined || _urlvars["op"]!=null)&& _urlvars["op"]=="video"){
				$("#cand_questions").attr({disabled:'disabled'});
			//}
		}else{
			_1stvideo=SjaxSendRequest('get1videocand', 'POST', 'system/ajaxRequest.ajax.php','none=NULL');
			if(_1stvideo!=""){
				_1stvideo = _1stvideo.slice(_1stvideo.lastIndexOf("_",0));
				$("#cand_questions").val(_1stvideo);
				$(".customOrderList >div[id=customList"+_1stvideo+"]").attr({style:'display:visible;'});
				$(".customOrderList >div[id=customList"+_1stvideo+"] >div[class=customListContent]")
					.prepend("<div class='questText"+_1stvideo+"'>"+$("#cand_questions option:selected").text()+"</div>");
				$("#cand_questions").attr({disabled:'disabled'});	
			} 
		}
		$("#cand_questions >option:selected").each(function(){
			$(this).addClass('selected');	
		});
		
	}
}
function changedCandidateQ(){
	if ($("#cand_questions").html()!=null || $("#cand_questions").html()!=undefined){

	$("#cand_questions >option").each(function(){
			$(this).removeClass('selected');
			
	});
	$("#cand_questions >option:selected").each(function(){
			$(this).addClass('selected');	
		});
	$(".customOrderList >div").each(function(){
			$(this).attr({style:'display:none;'});
	});
		
	$(".customOrderList >div[id=customList"+$("#cand_questions").val()+"]").attr({style:'display:visible;'});
	
	//window.location = window.location.protocol + "//" + window.location.host+ "/index.php?content=candidate_video&op=record&question="+$("#cand_questions").val();
	}
}
function highlightProfilestateC(){
	if ($(".iconlegend").html()!=undefined && $(".iconlegend").html()!=null){
		$(".iconlegend > div[class=form_input] > input[type=radio]").each(function(){
			if ($(this).attr("checked")==='checked'){
				$(this).parent().css("border","1px solid #999999");
				$(this).parent().css("background","#F7F7F7");
				$(this).parent().css("padding-bottom","5px");
			}else{
				$(this).parent().css("border","0");
				$(this).parent().css("background","#FFFFFF");
			};
		});
	}	
}

function refreshcompany() {
	//window.location.reload(true);
	var resp =SjaxSendRequest('refreshcompanymeetings', 'POST', 
			'system/ajaxRequest.ajax.php', "Refreshcompany=1");
	$(".company_meetings_list").eq(0).html(resp);
}


function refreshcandidate() {
	//window.location.reload(true);
	var resp =SjaxSendRequest('refreshcanidatemeetings', 'POST', 
			'system/ajaxRequest.ajax.php', "Refreshcompany=1");
	$(".company_meetings_list").eq(0).html(resp);
}


function refreshwidgetcandidate() {
	//window.location.reload(true);
	var resp =SjaxSendRequest('refreshwidgetcanidatemeetings', 'POST', 
			'system/ajaxRequest.ajax.php', "Refreshcompany=1");
	$("#candidate_accordion").eq(0).html(resp);
}

function refreshwidgetcompany() {
	//window.location.reload(true);
	var resp =SjaxSendRequest('refreshwidgetcompanymeetings', 'POST', 
			'system/ajaxRequest.ajax.php', "Refreshcompany=1");
	$("#company_accordion").eq(0).html(resp);
}

function unselectSelect(obj)
{
	if($(obj).find("option[selected=true]")!=undefined)
	{
		$(obj).find("option").each(function(){
			$(this).attr('selected', false);
			$(this).removeAttr('selected');
			$(this).attr('disabled', false);
			$(this).removeAttr('disabled');
		});
	}	
}

function clearACMCity(obj){
	var requestVars = getUrlVars();	
	if ((requestVars["cities"]=='' || requestVars["cities"]==null ||requestVars["cities"]==undefined) &&  $(obj).val()==''  )
	{		
	$(obj+'Description').css("color","");
	$(obj+'Description').val('');
	}
}


function checkRegSel(obj)
{
	if($(obj).find("option[selected=true]")!=undefined)
	{
		$("#seldb_view_Provincia").find("option").each(function(){
			$(this).attr('selected', false);
			$(this).removeAttr('selected');
			$(this).attr('disabled', false);
			$(this).removeAttr('disabled');
		});
		/*if($("#txtdb_view_ProvinciaPercent").val()>0)
		{
			$("#txtdb_view_RegionPercent").val($("#txtdb_view_ProvinciaPercent").val());
			//alert($("#txtdb_view_ProvinciaPercent").val());
			$("#txtdb_view_ProvinciaPercent").val(0);
		}*/
	}
}
function checkProvSel(obj)
{
	if($(obj).find("option[selected=true]")!=undefined)
	{
		$("#seldb_view_Region").find("option").each(function(){
			$(this).attr('selected', false);
			$(this).removeAttr('selected');
			$(this).attr('disabled', false);
			$(this).removeAttr('disabled');
		});
		/*if($("#txtdb_view_RegionPercent").val()>0)
		{
			$("#txtdb_view_ProvinciaPercent").val($("#txtdb_view_RegionPercent").val());
			$("#txtdb_view_RegionPercent").val(0);
		}*/
	}
}
function mouseRegioneClick()
{
	$("#regionSelect").click(function(){
		var requestVars = getUrlVars();
		var pagename="";
		if (requestVars["content"]!=null ||requestVars["content"]!=undefined)
		{
			pagename=requestVars["content"].toLowerCase();
		}else
		{
			pagename=window.location.pathname.toLowerCase();
		}
		if (pagename=="home" || pagename=="/home.html"){
			$("#regionSelect").addClass("acctiveSearchhp");
			$("#regionGroupSelect").removeClass("acctiveSearchhp");
		}else{
			$("#regionSelect").addClass("acctiveSearch");
			$("#regionGroupSelect").removeClass("acctiveSearch");	
			$("#citySelect").removeClass("acctiveSearch");		
		}
		switch (pagename)
		{
			case "company_db_view":
				$("#provinceSelect").removeClass("acctiveSearch");
				$("#seldb_view_Region").css("display","");
				$("#seldb_view_Region").removeClass("inacctive");
				$("#seldb_view_Provincia").addClass("inacctive");
				break;
			case "quicksearch":
			case "candidate_jobssearch":
			case "candidate_job_alert":
				$("#seljobs_search_Region").removeClass("inacctive");
				$("#seljobs_search_RegionGroup").addClass("inacctive");		
				$("#txtjobs_search_WorkplaceDescription").addClass("inacctive");
				break;
			default:
				$("#txtsearchWhat").val("reg");
				$("#txtLocationRegionGroupDescription").addClass("inacctive");
				$("#txtLocationRegionDescription").removeClass("inacctive");
				break;
		}
	});
}
function mouseRegionGroupClick()
{
	$("#regionGroupSelect").click(function(){
		var requestVars = getUrlVars();
		var pagename="";
		if (requestVars["content"]!=null ||requestVars["content"]!=undefined)
		{
			pagename=requestVars["content"].toLowerCase();
		}else
		{
			pagename=window.location.pathname.toLowerCase();
		}
		if (pagename=="home" || pagename=="/home.html"){
			$("#regionGroupSelect").addClass("acctiveSearchhp");
			$("#regionSelect").removeClass("acctiveSearchhp");	
		}else{
			$("#regionGroupSelect").addClass("acctiveSearch");
			$("#regionSelect").removeClass("acctiveSearch");
			$("#citySelect").removeClass("acctiveSearch");	
		}
		
		switch (pagename)
		{
			case "company_db_view":
				$("#seldb_view_Region").addClass("inacctive");
				$("#seldb_view_Provincia").removeClass("inacctive");
				break;
			case "quicksearch":
			case "candidate_jobssearch":
			case "candidate_job_alert":
				$("#seljobs_search_Region").addClass("inacctive");
				$("#txtjobs_search_WorkplaceDescription").addClass("inacctive");
				$("#seljobs_search_RegionGroup").css("display","");
				$("#seljobs_search_RegionGroup").removeClass("inacctive");
				
				break;
			default:
				$("#txtsearchWhat").val("reggrp");
				$("#txtLocationRegionDescription").addClass("inacctive");
				$("#txtLocationRegionGroupDescription").removeClass("inacctive");
				break;
		}
	});
}
function mouseCityClick()
{
	$("#citySelect").click(function(){
		var requestVars = getUrlVars();
		var pagename="";
		if (requestVars["content"]!=null ||requestVars["content"]!=undefined)
		{
			pagename=requestVars["content"].toLowerCase();
		}else
		{
			pagename=window.location.pathname.toLowerCase();
		}
		if (pagename=="home" || pagename=="/home.html"){
			$("#regionSelect").addClass("acctiveSearchhp");
			$("#regionGroupSelect").removeClass("acctiveSearchhp");
		}else{
			$("#regionSelect").removeClass("acctiveSearch");
			$("#regionGroupSelect").removeClass("acctiveSearch");	
			$("#citySelect").addClass("acctiveSearch");		
		}
		switch (pagename)
		{
			case "company_db_view":
				$("#seldb_view_Region").css("display","");
				$("#seldb_view_Region").removeClass("inacctive");
				$("#seldb_view_Provincia").addClass("inacctive");
				break;
			case "quicksearch":
			case "candidate_jobssearch":
			case "candidate_job_alert":
				$("#seljobs_search_Region").addClass("inacctive");
				$("#seljobs_search_RegionGroup").addClass("inacctive");
				$("#txtjobs_search_WorkplaceDescription").css("display","");
				$("#txtjobs_search_WorkplaceDescription").removeClass("inacctive");
				break;
			default:
				$("#txtsearchWhat").val("reg");
				$("#txtLocationRegionGroupDescription").addClass("inacctive");
				$("#txtLocationRegionDescription").removeClass("inacctive");
				break;
		}
	});
}

function mouseProvinceClick()
//to be removed after company consultazione database page is refactored
{
	$("#provinceSelect").click(function(){
		var requestVars = getUrlVars();
		var pagename="";
		if (requestVars["content"]!=null ||requestVars["content"]!=undefined)
		{
			pagename=requestVars["content"].toLowerCase();
		}else
		{
			pagename=window.location.pathname.toLowerCase();
		}
		if (pagename=="home" || pagename=="/home.html"){
		//	
		}else{
			$("#provinceSelect").addClass("acctiveSearch");
			$("#regionSelect").removeClass("acctiveSearch");	
		}
		
		switch (pagename)
		{
			case "company_db_view":
				$("#seldb_view_Region").addClass("inacctive");
				$("#seldb_view_Provincia").removeClass("inacctive");
				break;
			case "quicksearch":
			case "candidate_jobssearch":
			case "candidate_job_alert":
				//
				break;			
		}
	});
}



function displayProgressBar(){
	var value = parseInt($("#hiddenPoints").val());
	if (!value){
		value = 0;
	}	
	$(function() {
		$("#progressbar").progressbar({
			value: value
		});
	});
}

function displayProgressBar2(){
	var value = parseInt($("#hiddenPoints2").val());
	if (!value){
		value = 0;
	}	
	$(function() {
		$("#progressbar2").progressbar({
			value: value
		});
	});
}
function switchLanguage() {
	var currentLang = $("#languageLink").html();
	if (currentLang == "english") {
		var language = "eng";
		var changeLang = SjaxSendRequest('changelanguage', 'POST',
				'system/ajaxRequest.ajax.php', 'lang=' + language);
		if (changeLang == "OK") {
			$("#languageLink").html("italian");
			location.reload();
		} else {
		}
	} else if (currentLang == "italian") {
		var language = "ita";
		var changeLang = SjaxSendRequest('changelanguage', 'POST',
				'system/ajaxRequest.ajax.php', 'lang=' + language);
		if (changeLang == "OK") {
			$("#languageLink").html("english");
			location.reload();
		} else {
		}
	}
}

function loadVideo(videoName, questNr) {
	if (questNr <= 5 && questNr >= 1) {
		var uuid = SjaxSendRequest('getuuid', 'POST',
				'system/ajaxRequest.ajax.php', "mess=1");
		for (i = 1; i < 6; i++) {
			if (i != questNr) {
				$("#vidPlayerContent_q" + i).html(
						"<div id='vidPlayer_q" + i + "'></div>");
				$("#vidRecContent_q" + i).html(
						"<div id='vidRec_q" + i + "'></div>");
			}
		}
		swfobject.embedSWF("system/FlashComponents/videoPlayer.swf?uuid="
				+ uuid + '&filnm=' + videoName, "vidPlayer_q" + questNr, "350",
				"460", "8.0.0", "system/expressInstall.swf");
		$("#vidPlayerContent_q" + questNr).show();
		$("#vidRecContent_q" + questNr).hide();
	}
}

function toggleForm() {
	var pageName = requestVars['content'];
	window.location = window.location.protocol + "//" + window.location.host
			+ "/index.php?content=" + pageName + "&showform=1&clearform=1";
}

function toggleForm2() {
	var pageName = requestVars['content'];
	var sectionName =requestVars['section'];
	window.location = window.location.protocol + "//" + window.location.host
			+ "/index.php?content=" + pageName + "&section="+sectionName+"&showform=1&clearform=1";
}

function saveInvitationCode(){
	var ret;
	var resp =new Array() ;
	if ($('#invitationcode').length>0){
		var invc = $('#txtinvcode').attr('value');
		if (invc!=""){
			var ret = SjaxSendRequest('saveinvitationcode', 'POST', 
					'system/ajaxRequest.ajax.php', "invcode="+invc);
			resp = ret.split('#');// splitting response in order to get
									// messages from dictionary
				if ($('#invitationcode').children('#invitederr').length >0){
				$('#invitationcode').children('#invitederr').html(resp[1]);	
				}else{
					$('#invitationcode').append("<div id='invitederr'>"+resp[1]+"</div>");	
				}
				$('#invitederr').fadeIn();
				if (resp[0] == "1"){
					$('#invitationcode').children('#invitederr').removeClass('redNOT');
					$('#invitationcode').children('#invitederr').addClass('greenOK');
					$('#invitationcode').fadeOut(5000,function(){
						$('#invitationcode').html("<span class='wps_box_title1'>"+resp[2]+"</span>" +
						"<span class='wps_box_title1' id='invitername'>"+resp[3]+"</span>");
						$('#invitationcode').fadeIn(3000);
					});
				}else {
					$('#invitationcode').children('#invitederr').removeClass('greenOK');
					$('#invitationcode').children('#invitederr').addClass('redNOT');
					$('#txtinvcode').attr('value','');
					$('#invitederr').fadeOut(5000);
				}
		}else{ 
			var returnMessage="No value";
			// if ($("#languageLink").html()=="english"){
				//returnMessage="Si prega di inserire un valore!";
			returnMessage=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=candidate.invitationcode.novalue');
			// }else{
				// returnMessage="Please insert a value!";
			// }
			
			if ($('#invitationcode').children('#invitederr').length >0){
				$('#invitationcode').children('#invitederr').html(returnMessage);	
			}else{
				$('#invitationcode').append("<div id='invitederr' class='redNOT'>"+returnMessage+"</div>");	
			}
			$('#invitederr').fadeIn(3000,function (){
				$('#invitederr').fadeOut(5000);
			});
		}
	}
}

function hideOnLoadEducation() {
	requestVars = getUrlVars();
	if (requestVars['EdId'] == undefined)
		$("#FrmEducationTraining").hide();
	if (requestVars['showform'] == 1)
		$("#FrmEducationTraining").show();
}

function hideOnLoadWorkexperience() {
	requestVars = getUrlVars();
	if (requestVars['Feid'] == undefined)
		$("#FrmWorkExperience").hide();
	if (requestVars['showform'] == 1)
		$("#FrmWorkExperience").show();
}

function hideOnLoadLanguages() {
	requestVars = getUrlVars();
	if (requestVars['langid'] == undefined)
		$("#FrmCandidateLanguages").hide();
	if (requestVars['showform'] == 1)
		$("#FrmCandidateLanguages").show();
}
function SendToPdfCV(link, CVid) {
	var idCV = CVid;
	OpenReport(link, {
		idCV : idCV
	});
}

function deleteWorkexperience(idFormerEmployer, idCandidate){
	 var resp = SjaxSendRequest('deleteworkexperience', 'POST',
			'system/ajaxRequest.ajax.php', "IdFe="+parseInt(idFormerEmployer)+"&IdC="+parseInt(idCandidate));
	 var pageName = requestVars['content'];
	 window.location = window.location.protocol + "//" + window.location.host
		+ "/index.php?content=" + pageName + "&showform=0&clearform=1";
}
function deleteannounce(idannouncetype, idCompany){
	 var resp = SjaxSendRequest('deleteannounce', 'POST',
			'system/ajaxRequest.ajax.php', "IdAn="+parseInt(idannouncetype)+"&IdCom="+parseInt(idCompany));
	 var pageName = requestVars['content'];
	 window.location = window.location.protocol + "//" + window.location.host
		+ "/index.php?content=" + pageName + "&jobsSection=pay_credits&showform=0&clearform=1";
}

function deleteotherservices(idservice, idCompany){
	 var resp = SjaxSendRequest('deleteotherservices', 'POST',
			'system/ajaxRequest.ajax.php', "IdOs="+parseInt(idservice)+"&IdCom="+parseInt(idCompany));
	 var pageName = requestVars['content'];
	 window.location = window.location.protocol + "//" + window.location.host
		+ "/index.php?content=" + pageName + "&step=buy";
}

function deleteservices(idservice, idCompany,idCandidate){
	 var resp = SjaxSendRequest('deleteservices', 'POST',
			'system/ajaxRequest.ajax.php', "Ids="+parseInt(idservice)+"&IdCom="+parseInt(idCompany)+"&IdCand="+parseInt(idCandidate));
	 var pageName = requestVars['content'];
	 window.location = window.location.protocol + "//" + window.location.host
		+ "/index.php?content=" + pageName + "&section=pay_services&clearform=1";
}


function deleteEducation(idEducation, idCandidate){
	 var resp = SjaxSendRequest('deleteeducation', 'POST',
			'system/ajaxRequest.ajax.php', "IdEd=" + parseInt(idEducation)+"&IdC="+parseInt(idCandidate));
	 var pageName = requestVars['content'];
	 window.location = window.location.protocol + "//" + window.location.host
		+ "/index.php?content=" + pageName + "&showform=0&clearform=1";
}

function deleteLanguage(idLanguage, idCandidate){
	var resp = SjaxSendRequest('deletelanguage', 'POST',
			'system/ajaxRequest.ajax.php', "IdLang=" + parseInt(idLanguage)+"&IdC="+parseInt(idCandidate));
	 var pageName = requestVars['content'];
	 window.location = window.location.protocol + "//" + window.location.host
		+ "/index.php?content=" + pageName + "&showform=0&clearform=1";
}

function SendFriendAMail(id)
{
	if (id!=0){
		var result = SjaxSendRequest('sendinvitemail','POST','system/ajaxRequest.ajax.php','IdInvited=' + id);
		
		if  (result==1){
			var success="E-mail Sent!";
			success = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.email.sent');
			$("#u"+id+"").after("<p class='sentMailSucces'>"+success+"</p>");
			$(".sentMailSucces").fadeOut(15000);
		}else{
			$("#u"+id+"").after("<p class='sentMailError'>"+result+"</p>");
			$(".sentMailError").fadeOut(15000);
		}
	}
}

function DisplayVideoPolicy(){

}

function DisplayVideoGuideMac(){
	var msg_title="Videoregistrazioni";
	msg_title = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=candidate.videorec.guide.title');
	
	
	var content="";
	content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_videorec');
	
	$("#videohelp").html('<div id="help_videorec">'+content+'</div>');
	$("#videohelp").dialog("option","title",msg_title);
	$("#videohelp").dialog('open');


}
//to be checked for bugs:
$(function() {
	
	var accept = false;
	var title=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.videopolicy.title');
	var btns = {};
	btns[jq_dialog_yes]=function(){
		accept = true;
		$(this).dialog("close");
		};
	btns[jq_dialog_no]=function(){
		window.location = window.location.protocol + "//" + window.location.host
		+ "/index.php?content=candidateprofile&clearform=1";
		};
	
	$("#videoPolicy").dialog({
			buttons:btns,
			autoOpen: false,
			closeOnEscape:false,
			closeText:''+jq_dialog_close,
			dialogClass:'highlight',
			draggable:true,
			resizable:true,
			minHeight:200,
			maxHeight:640,
			minWidth:150,
			maxWidth:720,
			height:210,
			width:300,
			modal:true,
			title:''+title,
			close: function(event, ui) {
						var SaveVideoPolicy = SjaxSendRequest('saveVideoPolicy', 'POST',
							'system/ajaxRequest.ajax.php', 'vidpolicy='+accept);
						if (!accept) {
							window.location = window.location.protocol + "//" + window.location.host + "/index.php?content=candidateprofile";
						}else {
							$(this).dialog( 'destroy' );
						}	
					}
			});
});
function onVideoPolicyClose() {
	window.location = window.location.protocol + "//" + window.location.host
	+ "/index.php?content=candidateprofile";
}

function SlideDivs()
{
	if ($('.fadeSlide').length>0){
		$('.fadeSlide').cycle({fx: 'fade',timeout: 5000, delay:1000});
	}
}

function displayHelpLanguages(lang,type,height,optwidth,hidebtns)
{

	var title="Help";
	if ( optwidth === undefined ) {
	      optwidth = '500';
	   }
	if (hidebtns === undefined) {
		hidebtns = false;
	}
	var oldbtns;	
	var content="";
	content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_'+type);	
	$("#langHelpa").dialog('option','title',title);
	$("#langHelpa").dialog('option','height',height);
	$("#langHelpa").dialog('option','width',optwidth);
	//saving old buttons
	oldbtns = $("#langHelpa").dialog( "option", "buttons");
	//if needed, we hide buttons
	if (hidebtns === true){
		$("#langHelpa").dialog('option','buttons',{});	
	}
	
	$("#langHelpa").html('<div id="help_'+type+'">'+content+'</div>');
	$("#langHelpa").dialog('open');
	//restoring old buttons if we have different jquery dialogs on same page
	$("#langHelpa").dialog({
		   beforeClose: function(event, ui) { $("#langHelpa").dialog('option','buttons',oldbtns); }
	});
}


function toggleSelectBoxIE(id){
	var elem="#"+id;
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
if (isIE && isWin){
	if (id!=null || id!=''){
	var origWidth=$(elem).css("width");
		$(elem).mousedown(function () {
			$(this).css("position","absolute");
			$(this).css("overflow","hidden");
			$(this).css("width", "228px");
		}).blur(function () {
			$(this).css("position","relative");
			$(this).css("width", origWidth);
		}).change(function() {
			$(this).css("position","relative");
			$(this).css("width", origWidth);
		});
	}
}
}
function displayVideoContent(title,divWithVideo)
{
	$takeVideoContent= $("#"+divWithVideo).html();
	$(function(){
	var btns= {};
	btns[jq_dialog_close]=function()
	{
		$("#"+divWithVideo).html($takeVideoContent);
		$(this).dialog("close");
	};		
	$("#"+divWithVideo).dialog(
			{
				buttons:btns,
				autoOpen: false,
				closeOnEscape: true,
				closeText: ""+jq_dialog_close,
				dialogClass: "highlight",
				draggable: false,
				resizable: false,
				minWidth: 700,
				minHeight: 500,
				maxWidth: 700,
				maxHeight: 500,
				width: 700,
				height: 500,
				modal: true,
				title: title
			});
		$("#"+divWithVideo).dialog("option","title",title);
		$("#"+divWithVideo).dialog("open");
	});
}


function toggleDateInputState(chk,id){
	var ArrElem = id.split(",");
	var elem = "#"+id;
	var i = 0;
	if ($(chk).attr("checked")){
		// if ($(elem).attr('disabled')!=true){
			for (i=0;i<ArrElem.length;i++){
				$("#"+ArrElem[i]).attr('disabled', true);
		    }
			// $(elem).val('');
			$(elem).datepicker("disable");
		/*
		 * }else{ for (i=0;i<ArrElem.length;i++){
		 * $("#"+ArrElem[i]).attr('disabled', false); }
		 * //$(elem).attr('disabled', false); $(elem).datepicker("enable"); }
		 */
	}else{
		for (i=0;i<ArrElem.length;i++){
			$("#"+ArrElem[i]).attr('disabled', false);
	    }
		$(elem).datepicker("enable");
	}
}

function toggleTextInputState(chk,id){
	var elem = "#"+id;
	if ($(chk).val()=="on"){
		if ($(elem).attr('disabled')!='disabled'){
				$(elem).attr('disabled', true);
				$(elem).val('');
			}else{
				$(elem).attr('disabled', false);
			}
	}else{
		$(elem).attr('disabled', false);
	}
}

function returnValuesOcupation2(comboOcup,comboPos)
{
	//var selopttxt = "select";
	if ( comboOcup === undefined ) {
		comboOcup = "seloccupation";
	}
	if ( comboPos === undefined ) {
		comboPos = "selposition";
	}
	//selopttxt = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=lbl_choose');
	var valCombo=$("#"+comboPos).val();
	if (valCombo!=""){
	var allvalues=SjaxSendRequest('generateComboOcupation', 'POST','system/ajaxRequest.ajax.php', 'mainocupation='+valCombo);
	$("#"+comboOcup).html(allvalues);
	}
	else {
		$("#"+comboOcup).html("<option value=\"\">"+selopttxt+"</option>");
	}
	addTooltipToSelect();
}
function returnValuesOcupation3(comboOcup,comboPos)
{
	if ( comboOcup === undefined ) {
		comboOcup = "selcomOccupation";
	}
	if ( comboPos === undefined ) {
		comboPos = "selcomPosition";
	}
	var valCombo=$("#"+comboPos).val();
	if (valCombo!=""){
	var allvalues=SjaxSendRequest('generateComboOcupation', 'POST','system/ajaxRequest.ajax.php', 'mainocupation='+valCombo);
	$("#"+comboOcup).html(allvalues);
	}
	else {
		$("#"+comboOcup).html("<option value=\"\">"+selopttxt+"</option>");
	}
		addTooltipToSelect();
}

function returnValuesRegione()
{
	var valCombo=$("#selProvincia").val();
	if (valCombo!=""){
	var allvalues=SjaxSendRequest('generateComboregione', 'POST','system/ajaxRequest.ajax.php', 'provincia='+valCombo);
	$("#selRegione").html(allvalues);
	}
	else {
		$("#selRegione").html("<option value=\"\">"+selopttxt+"</option>");
	}
		addTooltipToSelect();
	
}
function returnValuesProvincia()
{
	
	var valCombo=$("#selProvincia").val();
	var parentcombo=$("#selCountry").val();
	
	if (parentcombo=="ITA"){
	var allvalues=SjaxSendRequest('generateComboprovincia', 'POST','system/ajaxRequest.ajax.php', 'country='+valCombo);
	$("#selProvincia").html(allvalues);
	}
	else {
		$("#selProvincia").html("<option value=\"\">"+selopttxt+"</option>");
		$("#selRegione").html("<option value=\"\">"+selopttxt+"</option>");
	}
		addTooltipToSelect();
}

function checkifexistsComboValue()
{
	requestVars = getUrlVars();
	if (requestVars['content'] == 'candidate_workexperience' && requestVars['Feid']== undefined)
	{
		var valCombo=$("#selposition").val();
		if (valCombo!="")
		{
			var allvalues=SjaxSendRequest('generateComboOcupation', 'POST','system/ajaxRequest.ajax.php', 'mainocupation='+valCombo);
			$("#seloccupation").html(allvalues);
		}
		// $("#selocupation_secondary").val();
	}
	else if (requestVars['content'] == 'candidate_workexperience' && requestVars['Feid']!= undefined)
	{
		var valCombo=$("#selposition").val();
		if (valCombo!="")
		{
			var allvalues=SjaxSendRequest('generatecomboocupationonload', 'POST','system/ajaxRequest.ajax.php', 'mainocupation='+valCombo+"&formempid="+requestVars['Feid']);
			$("#seloccupation").html(allvalues);
		}
	}
	if (requestVars['content'] == 'candidate_details' || requestVars['content'] == 'candidateProfile' ||requestVars['content'] == 'privatemaincand')
	{
		var valCombo=$("#selCountry").val();
		if (valCombo=="ITA")
		{
			var allvalues=SjaxSendRequest('generateComboprovinciaonload', 'POST','system/ajaxRequest.ajax.php', 'country='+valCombo );
			$("#selProvincia").html(allvalues);
			var allvalues=SjaxSendRequest('generateComboregioneonload', 'POST','system/ajaxRequest.ajax.php', 'country='+valCombo );
			$("#selRegione").html(allvalues);
		}
		// $("#selocupation_secondary").val();
	}
	if (requestVars['content'] == 'company_trainings')
	{
		var valCombo=$("#selcomAddTrainingCountry").val();
		if (valCombo=="ITA")
		{
			var allvaluesprov=SjaxSendRequest('generateComboprovinciaonload', 'POST','system/ajaxRequest.ajax.php', 'country='+valCombo );
			$("#selcomAddTraining_Provinces").html(allvaluesprov);
			var allvaluesreg=SjaxSendRequest('generateComboregioneonload', 'POST','system/ajaxRequest.ajax.php', 'country='+valCombo );
			$("#selcomAddTraining_Region").html(allvaluesreg);
		}
		else {
			$("#selcomAddTraining_Provinces").html("<option value=\"\">"+selopttxt+"</option>");
			$("#selcomAddTraining_Region").html("<option value=\"\">"+selopttxt+"</option>");
		}
		// $("#selocupation_secondary").val();
	}
	addTooltipToSelect();
}
function getProvinces(cmbRegion,cmbProvince)
{
	var valCombo=$(cmbRegion).val();
	// alert(valCombo);
	var allvalues=SjaxSendRequest('generateComboprovinciafromRegion', 'POST','system/ajaxRequest.ajax.php', 'region='+valCombo);
	$("#"+cmbProvince).html(allvalues);
	addTooltipToSelect();
}
function setProvinces(cmbId,provinceId)
{
	var countryVal=$("#"+cmbId).val();
	if (countryVal=="ITA")
	{
		var allvalues=SjaxSendRequest('generatecomboprovincia', 'POST','system/ajaxRequest.ajax.php', 'country='+countryVal );
		$("#"+provinceId).html(allvalues);
	}
	else {
		var allvalues="<option class=\"selOptionOne\" value=\"\">"+selopttxt+"</option>";
		$("#"+provinceId).html(allvalues);
	}
	addTooltipToSelect();
}
function updateOffertToDate(messBox)
{
	var requestVars = getUrlVars();
	if (parseInt(requestVars["announceId"])>0){
		var announceId = requestVars["announceId"];
		var valability = parseInt(SjaxSendRequest("getvalability","POST","system/ajaxRequest.ajax.php","announceid="+announceId));
	}else if(parseInt(requestVars["announcetype"])>0){
		var announceId = requestVars["announcetype"];
		var valability = parseInt(SjaxSendRequest("getvalability","POST","system/ajaxRequest.ajax.php","typeid="+announceId));
	}
	var nrDays = parseInt($("#txtcomAddJobs_Days").val());
	var nrMonths = parseInt($("#selcomAddJobs_Months").val());
	var nrYear = parseInt($("#selcomAddJobs_Year").val());
	var currentDate = new Date();
	var dateToShow = "00/00/0000";
	if (isNaN(nrDays) && isNaN(nrMonths) && isNaN(nrYear))
	{
		currentDate.setDate(currentDate.getDate()+30);
		// currentDate .setDate(currentDate.getDate());
		dateToShow = currentDate.getDate()+"/"+currentDate.getMonth()+"/"+currentDate.getFullYear();
	}
	else
	{
		var newdate = new Date();
		if (!isNaN(nrDays) && !isNaN(nrMonths) && !isNaN(nrYear))
		{
			newdate.setFullYear(nrYear, (nrMonths-1), nrDays);
		}
		newdate.setDate(newdate.getDate()+valability);
		dateToShow = newdate.getDate()+"/" + (newdate.getMonth()+1) + "/" + newdate.getFullYear();
	}
	$("#"+messBox).html(dateToShow);
}

function populateReferentsDp()
{
	$("#txtcrFirstName").val($("#txtcrComFirstName").val());
	$("#txtcrLastName").val($("#txtcrComLastName").val());
	$("#txtcrTelefono").val($("#txtcrComTelefono").val());
	$("#txtcrMobile").val($("#txtcrComMobile").val());
	$("#txtcrFax").val($("#txtcrComFax").val());
	//populate email address
	var email = SjaxSendRequest('getcompanyaddress', 'POST','system/ajaxRequest.ajax.php', "company=comp");
	$("#txtcrEmail").val(email);
}
function clearReferentsDp()
{
	$("#txtcrFirstName").val("");
	$("#txtcrLastName").val("");
	$("#txtcrTelefono").val("");
	$("#txtcrMobile").val("");
	$("#txtcrFax").val("");
	$("#txtcrEmail").val("");
}
function populateReferentsRa()
{
	$("#txtcrAmmFirstName").val($("#txtcrComFirstName").val());
	$("#txtcrAmmLastName").val($("#txtcrComLastName").val());
	$("#txtcrAmmTelefono").val($("#txtcrComTelefono").val());
	$("#txtcrAmmMobile").val($("#txtcrComMobile").val());
	$("#txtcrAmmFax").val($("#txtcrComFax").val());
	//populate email address
	var email = SjaxSendRequest('getcompanyaddress', 'POST','system/ajaxRequest.ajax.php', "company=comp");
	$("#txtcrAmmEmail").val(email);
}
function clearReferentsRa()
{
	$("#txtcrAmmFirstName").val("");
	$("#txtcrAmmLastName").val("");
	$("#txtcrAmmTelefono").val("");
	$("#txtcrAmmMobile").val("");
	$("#txtcrAmmFax").val("");
	$("#txtcrAmmEmail").val("");
}
function getDbViewTotalPercentage(){
	var pcTotal = 0;
	//pcTotal += returnInteger($("#txtdb_view_position1Percent").val());
	pcTotal += returnInteger($("#txtdb_view_bussines_sectorPercent").val());
	pcTotal += returnInteger($("#txtdb_view_YearsExperiencePercent").val());
	pcTotal += returnInteger($("#txtdb_view_OrganisationLevelPercent").val());
	pcTotal += returnInteger($("#txtdb_view_EducationFieldPercent").val());
	pcTotal += returnInteger($("#txtdb_view_LanguagePercent").val());
	pcTotal += returnInteger($("#txtdb_view_ProvinciaPercent").val());
	//pcTotal += returnInteger($("#txtdb_view_RegionPercent").val());
	pcTotal += returnInteger($("#txtdb_view_YearsPercent").val());
	pcTotal += returnInteger($("#txtdb_view_IsSpecialPercent").val());
	pcTotal += returnInteger($("#txtdb_view_JobSituationPercent").val());
	pcTotal += returnInteger($("#txtdb_view_keywordSearchPercent").val());
	pcTotal += returnInteger($("#txtdb_view_OrganisationTypePercent").val());
	return pcTotal;
}
function splitPercentage(obj,pcControl)
{
	var pcTotal = getDbViewTotalPercentage();
	if($(obj).attr("id")=="seldb_view_Provincia")
	{
		$("#seldb_view_Region").find("option").attr('selected', false);
		$("#seldb_view_Region").find("option").attr('disabled', false);
	}else if($(obj).attr("id")=="seldb_view_Region")
	{
		$("#seldb_view_Provincia").find("option").attr('selected', false);
		$("#seldb_view_Provincia").find("option").attr('disabled', false);
	}
	var pcToSplit = 100;
	//console.clear();
	$(".clsHiddenPcM[value=user]").each(function(){
		var cnt = $(this).attr("Id");
		cnt = cnt.substr(0,cnt.length-8);
		//console.log($("#"+cnt).val());
		pcToSplit -= returnInteger($("#"+cnt).val());
	});
	if ((typeof($(obj).val())=="string" || typeof($(obj).val())=="object" || typeof($(obj).val())=="number") && $(obj).val() != null && $(obj).val() != undefined && $(obj).val() != "" && $("#"+pcControl+"WhoModif").val() != "user"){
		var nrCnt = 1;
	}else {
		var nrCnt = 0;
	}
	var arrPcToModif = new Array();
	$(".clsHiddenPcM[value!=user]").each(function(){
		var cnt = $(this).attr("Id");
		cnt = cnt.substr(0,cnt.length-15);
		if (cnt.indexOf("keywordSearch")>0){
		}else{
			if($(this).attr("Id")=="txtdb_view_ProvinciaPercentWhoModif")
			{
				if($("#seldb_view_Region").find("option:selected").length>0)
				{
					cnt = "seldb_view_Region";
				}else{
					cnt = "seldb_view_Provincia";
				}
			}else{
				cnt = "sel"+cnt.substr(3);
			}
		}	
		//console.log(cnt+"-"+$("#"+cnt).val());
		if (($("#"+cnt).val()>0 || typeof($("#"+cnt).val())=="string" || typeof($("#"+cnt).val())=="object") && $("#"+cnt).attr("Id")!=$(obj).attr("Id") && $("#"+cnt).val() != null && $("#"+cnt).val() != undefined && $("#"+cnt).val() != ""){	
			if (typeof($("#"+cnt).val())=="string" || typeof($("#"+cnt).val())=="object"){
				if ($("#"+cnt).val().length>0){
					nrCnt += 1;
					arrPcToModif.push(cnt);
					//console.log(cnt);
				}	
			}else{	
				nrCnt += 1;
				arrPcToModif.push(cnt);
				//console.log(nrCnt);
			}
		}	
	});
	var i=0;
	for (i=0;i<arrPcToModif.length;i++){
		//console.log(arrPcToModif[i]);
		//start spliting the percentage
		var pcControlName = "";
		if(arrPcToModif[i].substr(3)=="db_view_Region")
		{
			pcControlName = "db_view_Provincia";
		}else{
			pcControlName = arrPcToModif[i].substr(3);
		}
		if (i==arrPcToModif.length-1){
			if ((typeof($(obj).val())=="string" || typeof($(obj).val())=="object" || typeof($(obj).val())=="number") && $(obj).val() != null && $(obj).val() != undefined && $(obj).val() != "" && $("#"+pcControl+"WhoModif").val() != "user"){
				//console.log("#txt"+pcControlName+"Percent");
				$("#txt"+pcControlName+"Percent").val(Math.floor(pcToSplit/nrCnt));
			}else {
				$("#txt"+pcControlName+"Percent").val(Math.floor(pcToSplit/nrCnt)+(pcToSplit-(Math.floor(pcToSplit/nrCnt)*nrCnt)));
			}
		}else{
			$("#txt"+pcControlName+"Percent").val(Math.floor(pcToSplit/nrCnt));
		}
	}	
	$("#"+pcControl).val(Math.floor(pcToSplit/nrCnt));
	if ((typeof($(obj).val())=="string" || typeof($(obj).val())=="object" || typeof($(obj).val())=="number") && $(obj).val() != null && $(obj).val() != undefined && $(obj).val() != "" && $("#"+pcControl+"WhoModif").val() != "user"){
		$("#"+pcControl).val(returnInteger($("#"+pcControl).val())+(100-getDbViewTotalPercentage()));
	}else {
		$("#"+pcControl).val(0);
	}
	$("#totalPercentValue").html(getDbViewTotalPercentage());
}
function regioneSplitPercentage(obj,pcControl)
{
	//alert($(obj).find("option:selected").length);
	$("#seldb_view_Provincia").attr("id","selNameModif");
	var idn = $(obj).attr("id");
	$(obj).attr("id","seldb_view_Provincia");
	splitPercentage(obj,pcControl);
	$(obj).attr("id",idn);
	$("#selNameModif").attr("id","seldb_view_Provincia");
}
function addPercentValue(percentValue)
{
	var pcVal = parseInt($(percentValue).val());
	if (isNaN(pcVal)){
		pcVal = 0;
	}
	var pcTotal = getDbViewTotalPercentage();
	if (100<pcTotal){
		pcTotal = pcTotal-pcVal;
		pcVal = 100-pcTotal;
		pcTotal = pcTotal + pcVal;
		$(percentValue).val(pcVal);
	}
	if (returnInteger($(percentValue).val())>0){
		$(percentValue).val(returnInteger($(percentValue).val()));
		$("#totalPercentValue").html(pcTotal);
		$("#"+$(percentValue).attr("Id")+"WhoModif").val("user");
	}else{
		$(percentValue).val(0);
	}
}
function removeSampleValue(input)
{
	if ($("#"+$(input).attr("Id")+"WhoModif").val()!="user" || $(input).val()==0){
		$(input).val("");
	}
	$(".clsHiddenPcM[value!=user]").each(function(){
		var cnt = $(this).attr("Id");
		cnt = cnt.substr(0,cnt.length-8);
		if ($("#"+cnt).attr("Id") != $(input).attr("Id")){
			$("#"+cnt).val(0);
			$(this).val("user");
		}
		//console.log($("#"+cnt).val());
	});
	if ($("#isShownPessoMessage").val()!="showed"){
		var content="bb";
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_pessoManualMessage');
		$("#pessoMessage").html(content);
		$("#pessoMessage").dialog({
			title: "",
			modal: true,
			resizable: false,
			height: 200,
			width: 300,
			autoOpen:true, //added when used .html instead .load
			close: function(event, ui) { $("#isShownPessoMessage").val("showed"); },
			buttons: {
				Ok: function() {
				$(this).dialog('close');
				}
			
			}
		});
		//$("#pessoMessage").load('../public/text.html #pessoManualMessage',
		/*
				function(){
					$("#pessoMessage").dialog({
						title: "",
						modal: true,
						resizable: false,
						height: 200,
						width: 300,
						close: function(event, ui) { $("#isShownPessoMessage").val("showed"); },
						buttons: {
							Ok: function() {
							$(this).dialog('close');
							}
						}
					});
			});*/
	}
}
function returnInteger(val)
{
	var ret = 0;
	ret = parseInt(val);
	if (isNaN(ret)){
		ret = 0;
	}
	return ret;
}
function saveCompanySearchProfile()
{
	var postVars = "";
	var count = 0;
	var profileName = $("#txtdb_view_SearchProfileName").val();
	url = document.location.href;
	postVars = url.substr(url.indexOf("company_db_view")+16);
	postVars = postVars.replace(/&/gi,"<#>");
	//if (profileName.length > 0 && postVars.length > 0){
		var srCodes = ""; 
		$(".hdnCandCode").each(function(){
			srCodes += "/"+$(this).val();
		});
		var srRanks = "";
		$(".cand_Rank").each(function(){
			srRanks += "/"+$(this).html();
		});
		srRanks = srRanks.substr(1);
		srCodes = srCodes.substr(1);
		var srccode = returnInteger($("#txtdb_view_SearchProfileId").val());
		var saveSearchProfile = SjaxSendRequest('saveSearchProfile', 'POST','system/ajaxRequest.ajax.php', "linkSearch="+postVars+"&profileName="+profileName+"&searchcode="+srccode+"&codesArr="+srCodes+"&ranksArr="+srRanks);
		if (saveSearchProfile > 0){
			//$("#succesProfileNameSaved").html("Profilo di ricerca salvata");
			//setTimeout(function() {$("#succesProfileNameSaved").fadeOut(3000);},5000);
			window.location = "index.php?content=company_search_profiles";
		}
	//}
	/*else{
		// display error mesage
		$("#errorsProfileName").html("Devi scegliere un nome per il profilo di ricerca");
		setTimeout(function() {$("#errorsProfileName").fadeOut(3000);},5000);
	}*/	
}
function getSavedResults(idSearch){
	var urlVars = getUrlVars();
	var retlink = document.location.href;
	retlink = retlink.replace("&","#");
	var pos_s = retlink.indexOf("?");
	retlink = retlink.substr(pos_s);
	if (urlVars["getProf"] != undefined){
		var SearchProfile = SjaxSendRequest('getSearchResults', 'POST','system/ajaxRequest.ajax.php', "searchCode="+idSearch+"&getProf="+urlVars["getProf"]+"&retlink="+retlink);
	}else{	
		var SearchProfile = SjaxSendRequest('getSearchResults', 'POST','system/ajaxRequest.ajax.php', "searchCode="+idSearch+"&retlink="+retlink);
	}
	$("#resultsTable"+idSearch).html(SearchProfile);
}
function includeTinyMCE()
{
	tinyMCE.init({
		mode : "exact",
		elements : "txtcomAddJobs_Position_description,txtcomAddJobs_Requirements_description,txtcomAddTrainingDescription,txtcomAddTrainingObjectives,txtcomAddTrainingProgram,txtcomAddTrainingAudience," +
				"txtcomAddTrainingCertification,txtcomAddTrainingStage,txtcomAddTrainingParticipationMode,txtcomAddTrainingScolarships,txtcomAddTrainingContact",
		theme : "advanced",
		plugins : "paste",
	    paste_remove_styles: true,
	    paste_auto_cleanup_on_paste : true,
	    paste_preprocess : function(pl, o) {
            //alert(o.content);
			//copy only text not tags.
            var contentText = "";
            var i=0;
            var posF = 0;
            var posL = 0;
            while(o.content.indexOf("<")>=0 && o.content.indexOf(">")>0){
            	posF = o.content.indexOf("<");
            	posL = o.content.indexOf(">");
            	if (posF>=0 && posL>0){
            		contentText = o.content.substr(posF,(posL+1-posF));
            		o.content = o.content.replace(contentText,"");
            	}
            }
            /*var words = o.content.match(/>([^><]*)<\//gi);//\w\W\s \.\'\"\â€™\`\@\(\)\â€ś\â€ť\:\,\+\=\Ă˛\Ăą\Ă©\Ă¨\Ă \Ă¬\\Â§\Ă§\&\;\/
            if(words!=null){
            	for(i=0;i<words.length;i++){
            		contentText += " "+words[i].substr(1,words[i].length-3);
            	}
            	o.content = contentText;
            }*/
            
            //alert(o.content);
        },
        paste_postprocess : function(pl, o) {
            // Content DOM node containing the DOM structure of the clipboard
            //alert(o.node.innerHTML);
            o.node.innerHTML = o.node.innerHTML;
        },
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,undo,redo,separator,link,unlink",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : ""

    });
}
function convertWord(type, content){
	alert(content);
	return content;
}
function deletecredit(idItem, qty){
	var link = window.location.protocol + "//" + window.location.host;
	var resp = SjaxSendRequest('deletecredit', 'POST',
			'system/ajaxRequest.ajax.php', "IdCredit="+parseInt(idItem)+"&qty="+parseInt(qty));
	 var pageName = requestVars['content'];
	 var step = requestVars['step'];
	     link = link+"/index.php?content="+pageName;
	 if (step!=undefined){
		 link = link+"&step="+step+"&clearform=1"; 
	 } 
	 window.location.href=link; 
	 
}

function showHideDiv(divToHide)
{
	if ($("#"+divToHide).is(":visible")){
		$("#"+divToHide).slideUp("slow");
	}else {
		$("#"+divToHide).slideDown("slow");
	}
}
function showManageJobFormOnLoad()
{
	if (requestVars["search"]==1)
	{
		$("#Frmcompany_manage_offert").show();
	}else{
		$("#Frmcompany_manage_offert").hide();
	}
}
/*function republicaAnnunci(button,nIdJob)
{
	var result = SjaxSendRequest('republicjob','POST','system/ajaxRequest.ajax.php','idjob='+parseInt(nIdJob));
	if (result!=0)
	{
		//$("#ripublicaResponse").after("The announce has been succesfull republished");
		window.location.href="index.php?content=company_jobs&jobsSection=company_add_offert&announcetype="+result+"&announceId="+nIdJob+"&clearform=1";
	}
	else {
		$(button).before("<div class='response_republica'>Non si dispone di sufficienti annunci</div>");
		$("#response").fadeOut(15000);
	}
}*/
function republicaAnnunci(button,nIdJob)
{
	var result = SjaxSendRequest('republicjob','POST','system/ajaxRequest.ajax.php','idjob='+parseInt(nIdJob));
	if (result==1)
	{
		//$("#ripublicaResponse").after("The announce has been succesfull republished");
		window.location.reload(true	);
		//$("#helptextforrepublicjobita").eq(0).html("OK!")
	}
	else {
		if ($("#help_ripublicajob").find("div[class=response_republica]").html() != null && $("#help_ripublicajob").find("div[class=response_republica]").html() != undefined){
			$("#help_ripublicajob").find("div[class=response_republica]").show();
		}else{
			$("#help_ripublicajob").append("<br/>"+result);
		}
		/*setTimeout(function(){
			$(button).parent().find("div[class=response_republica]").fadeOut(1000);
		},5000);
		$("#helptextforrepublicjobita").eq(0).html(result)*/
	}
}

function cloneObject(button,jobId)
{
	var msg_pre_link = "Per poter duplicare il Suo annuncio, è necessario ";
	var msg_link="ricaricare ";
	var msg_post_link=" il Suo conto FaceCV";
	
	var clonedObject = SjaxSendRequest("cloneannouncement","POST","system/ajaxRequest.ajax.php","idjob="+jobId);
	if (parseInt(clonedObject)>0)
	{
		window.location.href="index.php?content=company_jobs&jobsSection=company_add_offert&announcetype="+clonedObject+"&clone=1&announceId="+jobId+"&clearform=1";
	}
	else{
		if ($(button).parent().find("div[class=response_clone]").html() != null && $(button).parent().find("div[class=response_clone]").html() != undefined){
			$(button).parent().find("div[class=response_clone]").show();
		}else{
			msg_pre_link = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company.announce.clone.prelink');
			msg_link = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company.announce.clone.link');
			msg_post_link = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company.announce.clone.postlink');
			
			$(button).after("<div class='response_clone'>"+msg_pre_link+"<a href='index.php?content=company_contofacecv&amp;clearform=1'>"+msg_link+" </a>"+msg_post_link+"</div>");
			$(button).parent().find("div[class=response_clone]").show();
		}
		setTimeout(function(){
			$(button).parent().find("div[class=response_clone]").fadeOut(1000);
		},5000);
		//$("#response").fadeOut(15000);
	}
}
/*function republicaAnnunci(button,nIdJob)
{
	var result = SjaxSendRequest('republicjob','POST','system/ajaxRequest.ajax.php','idjob='+parseInt(nIdJob));
	if (result!=0)
	{
		//$("#ripublicaResponse").after("The announce has been succesfull republished");
		window.location.href="index.php?content=company_jobs&jobsSection=company_add_offert&announcetype="+result+"&announceId="+nIdJob+"&clearform=1";
	}
	else {
		$(button).after("Non si dispone di sufficienti annunci");
		$("#responseRecharge").fadeOut(15000);
	}
}*/
function saveVideoLink(videoLink,vidType)
{
	videoLink = $("#"+videoLink).val().replace("&","#and;");
	var saveVideoLink = SjaxSendRequest('saveVideoLink', 'POST','system/ajaxRequest.ajax.php', "videoType="+vidType+"&videolink="+videoLink);
	if (saveVideoLink == "Ok"){
		window.location.reload(true	);
	}else{
		alert(saveVideoLink);
	}	
}
function saveAnunnciVideoLink(fieldId){
	var videoLink = $("#"+fieldId).val().replace("&","#and;");
	var jobId = getUrlVars()["jobId"];
	var saveVideoLink = SjaxSendRequest('saveVideoAnunnciLink', 'POST','system/ajaxRequest.ajax.php', "videolink="+videoLink+"&jobId="+jobId);
	if (saveVideoLink == "Ok"){
		window.location.reload(true	);
	}else{
		alert(saveVideoLink);
	}	
}
function deleteAnunnciVideoLink(){
	var jobId = getUrlVars()["jobId"];
	var no_video = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company.video.nolink');
	var deleteVideo = SjaxSendRequest('deleteVideoAnunnciLink','POST','system/ajaxRequest.ajax.php','jobId='+jobId);
	if (deleteVideo == "ok")
	{
		window.location.reload(true);
	}else{
		$(button).after("<div id='youtube_noVideo'>"+no_video+"</div>");
		$("#youtube_noVideo").fadeOut(15000);
	}
}
function deleteVideoLink(button,vidType)
{
	var no_video = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company.video.nolink');
	var deleteVideo = SjaxSendRequest('deleteVideoLink','POST','system/ajaxRequest.ajax.php','videoType='+vidType);
	if (deleteVideo == "ok")
	{
		window.location.reload(true);
	}else{
		$(button).after("<div id='youtube_noVideo'>"+no_video+"</div>");
		$("#youtube_noVideo").fadeOut(15000);
	}
}
function goNavPage(navPage)
{
	if (navPage.lastIndexOf('-next')>0){
		var posLn = navPage.lastIndexOf('-');
		var navId = navPage.substring(3,posLn);
		var elementActive = $('#'+navId).find('li.ui-tabs-selected');// ui-tabs-selected
																		// ui-state-active
		if (elementActive != undefined || elementActive != null){
			// $(elementActive).find('a:first').html();
			var pgNr = returnInteger($(elementActive).find('a:first').html());
			if ($("#btn"+navId+"-"+(pgNr+1)) != undefined || $("#btn"+navId+"-"+(pgNr+1)) != null){
				$("#btn"+navId+"-"+(pgNr+1)).trigger('click');
			}else{
				$("#btn"+navId+"-"+pgNr).trigger('click');
			}	
		}	
	}else if(navPage.lastIndexOf('-prev')>0){
		var posLn = navPage.lastIndexOf('-');
		var navId = navPage.substring(3,posLn);
		var elementActive = $('#'+navId).find('li.ui-tabs-selected');// ui-tabs-selected
																		// ui-state-active
		if (elementActive != undefined || elementActive != null){
			// $(elementActive).find('a:first').html();
			var pgNr = returnInteger($(elementActive).find('a:first').html());
			if ($("#btn"+navId+"-"+(pgNr-1)) != undefined || $("#btn"+navId+"-"+(pgNr-1)) != null){
				$("#btn"+navId+"-"+(pgNr-1)).trigger('click');
			}else{
				$("#btn"+navId+"-"+pgNr).trigger('click');
			}	
		}	
	}else{	
		$("#"+navPage).trigger('click');
	}
}
function isElemtInArray(arr,elem)
{
	var i=0;
	var is=false;
	for(i=0;i<arr.length;i++){
		if (arr[i]==elem){
			is = true;
		}	
	}
	return is;
}
function LimitSelectionTo3(multiselect)
{
	/*
	 * its work with multi select and its limit the selected options to 3 its
	 * need and hiden with name like txt+id(- first 3 chars)+values
	 */
	var val = $(multiselect).val();
	if (typeof(val) == "string"){
		val = val.split(",");
	}	
	if (val!=null){
		if (val.length>=3){
			$(multiselect).find('option').each(function(){
				if($(this).val()!=val[0] && $(this).val()!=val[1] && $(this).val()!=val[2]){
					$(this).attr("disabled",true);
					$(this).attr("selected",false);
				}
			});
		}else if(val.length<3){
			$(multiselect).find('option').attr("disabled",false);
		}else{
			$("#txt"+id.substr(3)+"Values").val(val.toString());
		}
	}
	
}

function ViewPdfCV(link,InvCode) {
	var invCode = InvCode;
	OpenReport(link, {
		invCode:invCode
	});
}

function ViewPartPdfCV(link,InvCode) {
	var invCode = InvCode;
	OpenReport(link, {
		invCode:invCode
	});
}


function buygiuntitestforcandidate(chk,idCand){
	
	if ($(chk).attr("checked")){
		    
		var result = SjaxSendRequest('buygiuntitest1','POST','system/ajaxRequest.ajax.php','idCand='+parseInt(idCand));
		window.location.reload(true	);		
		}
		else{
			var result = SjaxSendRequest('buygiuntitest2','POST','system/ajaxRequest.ajax.php','idCand='+parseInt(idCand));
			window.location.reload(true	);
		}	
}
function buycvpresentationforcandidate(chk,cv_code){
	if ($(chk).attr("checked")){    
		var result = SjaxSendRequest('buycvpresentation1','POST','system/ajaxRequest.ajax.php','cv_code='+cv_code);
		window.location.reload(true	);		
	}else{	
		var result = SjaxSendRequest('buycvpresentation2','POST','system/ajaxRequest.ajax.php','cv_code='+cv_code);
		window.location.reload(true	);
	}
}
function buyvideopresentationforcandidate(chk,idCand){
	
	if ($(chk).attr("checked")){    
		var result = SjaxSendRequest('buyvideopresentation1','POST','system/ajaxRequest.ajax.php','idCand='+parseInt(idCand));
		window.location.reload(true	);		
	}else{	
		var result = SjaxSendRequest('buyvideopresentation2','POST','system/ajaxRequest.ajax.php','idCand='+parseInt(idCand));
		window.location.reload(true	);
	}	
}
function deleteSearchProfile(searchId){
	if(returnInteger(searchId)>0){
		var result = SjaxSendRequest('deleteSearchProfile','POST','system/ajaxRequest.ajax.php','idsearch='+searchId);
		window.location.reload(true	);
	}	
}
function displayDiffPayButton()
{
	//alert($("#selpaymentType").val());
	if ($("#selpaymentType").val() != "")
	{
		$("#btnchangePayment").show();
	}
	else 
	{
		$("#btnchangePayment").hide();
	}
}
function sendCandidateCompanyRequest(cand_code,doc){
	var brandid = "";
	if ($("#chkcomAddJobs_UseBrands").val()=='on')
		{
		brandid = $("#selcomAddJobs_Brand").val();
		}
	var resp = SjaxSendRequest('sendCandidateRequest','POST','system/ajaxRequest.ajax.php','cand_code='+cand_code+"&doc="+doc+"&brandId="+brandid);
	if (doc == 'testgiunti'){
		$('#sendMailToCandTest').eq(0).html(resp);
	}
	else if(doc=='videopresentation'){
		$('#sendMailToCand').eq(0).html(resp);
	}
	
}

function sendCandidateCompanyRequestAreaSel(cand_code,doc,jobId){
	var resp = SjaxSendRequest('sendCandidateRequest','POST','system/ajaxRequest.ajax.php','cand_code='+cand_code+"&doc="+doc+"&jobId="+jobId);
	if (doc == 'testgiunti'){
		$('#sendMailToCandTest').eq(0).html(resp);
	}
	else if(doc=='videopresentation'){
		$('#sendMailToCand').eq(0).html(resp);
	}
}

function associateCVtoSearch(cv_code){
	var message_err = "Devi selezionare una ricerca o inserire un nome per la nuova";
	message_err = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=candidate.facecvagent.createerr');
	if (returnInteger($("#selmore_info_searchProfiles").val())>0){
		var idSearch = $("#selmore_info_searchProfiles").val();//returnInteger
		var profState = 1;
		var urlVars = getUrlVars();
		//alert(urlVars['rank']);
		var result = SjaxSendRequest('associateCandidatetoSearch','POST','system/ajaxRequest.ajax.php','cand_code='+cv_code+"&rank="+urlVars["rank"]+"&profState="+profState+"&idSearch="+idSearch);
		if (result>0){
			window.location.reload(true	);
		}
	}else{
		alert(message_err);
	}
}
function showmessagebrowsercomp() {
	var msg_title = "Compatibilità  browser";
	msg_title = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=browsercompat.title');
	if ($("#oldBrowserMessage").val()=='1')
		{
		$("#langHelpaoldbrowser").load('../public/helpBrowsers.php', 
				function(){;
					$("#langHelpaoldbrowser").dialog("option","title",msg_title);
					$("#langHelpaoldbrowser").dialog('option','height',540);
					$("#langHelpaoldbrowser").dialog('option','width',640);
					$("#langHelpaoldbrowser").dialog('open');
				});
		}
}
function showmessageoldbrowser() {
	var msg_title = "Compatibilità  browser";
	msg_title = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=browsercompat.title');
	$("#langHelpacompatbrowser").load('../public/helpBrowsers.php', 
				function(){;
					$("#langHelpacompatbrowser").dialog("option","title",msg_title);
					$("#langHelpacompatbrowser").dialog('option','height',540);
					$("#langHelpacompatbrowser").dialog('option','width',640);
					$("#langHelpacompatbrowser").dialog('open');
				});
}
function showmessageoldbrowseronlogin() {
	var msg_title = "Compatibilità  browser";
	msg_title = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=browsercompat.title');
	var resp = SjaxSendRequest('showmessageonuserlogin','GET','system/ajaxRequest.ajax.php','Id=1');
	if (resp=='OK')
	{
	$("#logincompatbrowsermessage").load('../public/helpBrowsers.php', 
				function(){;
					$("#logincompatbrowsermessage").dialog("option","title",msg_title);
					$("#logincompatbrowsermessage").dialog('option','height',540);
					$("#logincompatbrowsermessage").dialog('option','width',640);
					$("#logincompatbrowsermessage").dialog('open');
				});
	}
}

function showmessageannunci() {
	var msg_title = "Offerte di lavoro";
	msg_title= SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=section_company_jobs');
	var content="";
	
	$("#langHelpa").dialog("option","title",msg_title);
	$("#langHelpa").dialog('option','height',200);
	$("#langHelpa").dialog('option','width',300);
	
	if ($("#hiddenlight").val()>=3)
		{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annuncilight');
		$("#langHelpa").html('<div id="help_annuncilight">'+content+'</div>');
		$("#langHelpa").dialog('open');
		}
	if ($("#hiddenlightvis").val()>=3)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annuncilightvis');
		$("#langHelpa").html('<div id="help_annuncilightvis">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}

	if ($("#hiddenmedium").val()>=3)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annuncimedium');
		$("#langHelpa").html('<div id="help_annuncimedium">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	 
	if ($("#hiddenmediumvis").val()>=3)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annuncimediumvis');
		$("#langHelpa").html('<div id="help_annuncimediumvis">'+content+'</div>');
		$("#langHelpa").dialog('open');	
	}
	
	if ($("#hiddentop").val()>=3)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annuncitop');
		$("#langHelpa").html('<div id="help_annuncitop">'+content+'</div>');
		$("#langHelpa").dialog('open');	
	}
	
	if ($("#hiddentopvis").val()>=3)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annuncitopvis');
		$("#langHelpa").html('<div id="help_annuncitopvis">'+content+'</div>');
		$("#langHelpa").dialog('open');	
	}
	 
	if ($("#hiddenill3").val()>=2)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annunciill3');
		$("#langHelpa").html('<div id="help_annunciill3">'+content+'</div>');
		$("#langHelpa").dialog('open');	
	}
	
	if ($("#hiddenill3vis").val()>=2)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annunciill3vis');
		$("#langHelpa").html('<div id="help_annunciill3vis">'+content+'</div>');
		$("#langHelpa").dialog('open');		
	}
	
	if ($("#hiddenill6").val()>=2)
	{
	content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annunciill6');
	$("#langHelpa").html('<div id="help_annunciill6">'+content+'</div>');
	$("#langHelpa").dialog('open');
	}
	if ($("#hiddenill6vis").val()>=2)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annunciill6vis');
		$("#langHelpa").html('<div id="help_annunciill6vis">'+content+'</div>');
		$("#langHelpa").dialog('open');	
	}
	if ($("#hiddenill36vis").val()>=2)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annunciill36vis');
		$("#langHelpa").html('<div id="help_annunciill36vis">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenill36").val()>=2)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annunciill36');
		$("#langHelpa").html('<div id="help_annunciill36">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	
	if ($("#hiddenill39").val()>=2)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annunciill39');
		$("#langHelpa").html('<div id="help_annunciill39">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	
	if ($("#hiddenill39vis").val()>=2)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_annunciill39vis');
		$("#langHelpa").html('<div id="help_annunciill39vis">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplilight3").val()>=6)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_light3');
		$("#langHelpa").html('<div id="help_light3">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplimedium3").val()>=6)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_medium3');
		$("#langHelpa").html('<div id="help_medium3">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplitop3").val()>=6)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_top3');
		$("#langHelpa").html('<div id="help_top3">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplilight3vis").val()>=6)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_light3vis');
		$("#langHelpa").html('<div id="help_light3vis">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplimedium3vis").val()>=6)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_medium3vis');
		$("#langHelpa").html('<div id="help_medium3vis">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplitop3vis").val()>=6)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_top3vis');
		$("#langHelpa").html('<div id="help_top3vis">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplilight6").val()>=12)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_light6');
		$("#langHelpa").html('<div id="help_light6">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplimedium6").val()>=12)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_medium6');
		$("#langHelpa").html('<div id="help_medium6">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplitop6").val()>=12)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_top6');
		$("#langHelpa").html('<div id="help_top6">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplilight6vis").val()>=12)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_light6vis');
		$("#langHelpa").html('<div id="help_light6vis">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplimedium6vis").val()>=12)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_medium6vis');
		$("#langHelpa").html('<div id="help_medium6vis">'+content+'</div>');
		$("#langHelpa").dialog('open');
	}
	if ($("#hiddenmultiplitop6vis").val()>=12)
	{
		content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_top6vis');
		$("#langHelpa").html('<div id="help_top6vis">'+content+'</div>');
		$("#langHelpa").dialog('open');		
	}
}
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    } else {
        return document[movieName];
    }
}
function ShowVideoHome(){
	var wmode = "wmode=\"transparent\" ";	
	/*if (isOpera){
		wmode = "";
	}*/
	//snowStorm.stop();
	$("#txthidenSpeedAnim").val("stop");
	if (isIE){
		$(".videoPresentation").eq(0).html("<object height=\"484\" width=\"740\" id='homeVideo' name='homeVideo' type=\"application/x-shockwave-flash\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\">"+
				"<param name=\"movie\" value=\"system/FlashComponents/homeVideo.swf\"></param>"+
				"<param name=\"allowScriptAccess\" value=\"always\"></param>"+
				"<param name=\"allowFullScreen\" value=\"true\"></param>"+
				"<param name=\"pluginspage\" value=\"http://www.adobe.com/go/getflashplayer\"></param>"+
				"<param name=\"wmode\" value=\"transparent\"></param>"+
			"</object>");
	}else{
		$(".videoPresentation").eq(0).html("<embed id='homeVideo'name='homeVideo' height=\"484\" width=\"740\" "+wmode+
				"type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" src=\"system/FlashComponents/homeVideo.swf\"></embed>");
	}
}
function deleteHomeVideo(){
	$(".videoPresentation").eq(0).html("");
	//snowStorm.init();
	$("#txthidenSpeedAnim").val(2);
}
function SendToPaymentPdf(link,PaymentId) {
	var idPayment = PaymentId;
	OpenReport(link,{idPayment : idPayment});
}
function SendToPdfJobStampa(link,jobId)
{
	var idJob = jobId;
	OpenReport(link,{jobId: idJob});
}
function SendPaymentHistory(link, fromDate, endDate)
{
	var fdate = fromDate;
	var edate = endDate;
	OpenReport(link,{fromDate: fdate, endDate: edate});
}
function companyViewCandVideo(uuid,videoName,qnr)
{
	wmode = "wmode=\"transparent\" ";	
	if (isOpera){
		wmode = "";
	}
	$("#vidPlayer_q"+qnr).eq(0).html("<object height=\"320\" width=\"350\" id='videoPlayer' type=\"application/x-shockwave-flash\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\">"+
			"<param name=\"movie\" value=\"system/FlashComponents/videoPlayer.swf?uuid="+uuid+"&filnm="+videoName+"\">"+
			"<param name=\"allowScriptAccess\" value=\"always\">"+
			"<param name=\"allowFullScreen\" value=\"true\">"+
			"<param name=\"pluginspage\" value=\"http://www.adobe.com/go/getflashplayer\">"+
			"<param name=\"wmode\" value=\"transparent\">"+
			"<embed height=\"320\" width=\"350\" align=\"middle\" "+wmode+" name='homeVideo' flashvars=\"\" scale=\"exactfit\" autostart=\"false\" autoplay=\"false\" loop=\"false\" pluginspage=\"http://www.adobe.com/go/getflashplayer\" "+
			"type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" quality=\"high\" src=\"system/FlashComponents/videoPlayer.swf?uuid="+uuid+"&filnm="+videoName+"\">"+
			"</object>");
}
function closeVideoComp(qnr){
	$("#vidPlayer_q"+qnr).html("");
}
function hideBrosure(){
	$("#companyBrPgFlip").hide();
}
function showBrosure()
{
	$("#companyBrPgFlip").show();
}
function displayCandVideos(candCode)
{
	var result = SjaxSendRequest('getCandVideos','POST','sections/company_candVideo.php','candCode='+candCode);
	$("#videoCand").html(result);
	//$("#videoCand").dialog("destroy");
	$("#videoCand").dialog({
		title: "Video presentatione candidato",
		modal: true,
		resizable: false,
		height: 440,
		width: 760
	});
}
function getJobsSearchCriteria(){
	var retlink = "";
	if($("#seljobs_search_position1").val() != null ) { 
		if ( $("#seljobs_search_position1").val().length>0){
			retlink += "#pst1="+$("#seljobs_search_position1").val();
		}
	}
	if($("#seljobs_search_bussines_sector").val() != null ) { 
		if ( $("#seljobs_search_bussines_sector").val().length>0){
			retlink += "#bsSect="+$("#seljobs_search_bussines_sector").val();
		}
	}
	if($("#seljobs_search_OrganisationType").val() != null ) { 
		if ( $("#seljobs_search_OrganisationType").val().length>0){
			retlink += "#edcOrgType="+$("#seljobs_search_OrganisationType").val();
		}
	}
	if($("#seljobs_search_RegionGroup").val() != null ) { 
		if ( $("#seljobs_search_RegionGroup").val().length>0){
			retlink += "#reggrp="+$("#seljobs_search_RegionGroup").val();
		}
	}
	if($("#txtjobs_search_Workplace").val() != null ) { 
		if ( $("#txtjobs_search_Workplace").val().length>0){
			var arrWp=new Array();
			arrWp=$("#txtjobs_search_Workplace").val().split(", ");
			arrWp.pop();
			retlink += "#cities="+arrWp.join("+");
		}
	}
	if($("#seljobs_searchContract_type").val() != null ) { 
		if ( $("#seljobs_searchContract_type").val().length>0){
			retlink += "#jobCtType="+$("#seljobs_searchContract_type").val();
		}
	}
	if($("#seljobs_search_Work_hours").val() != null ) { 
		if ( $("#seljobs_search_Work_hours").val().length>0){
			retlink += "#jobWhours="+$("#seljobs_search_Work_hours").val();
		}
	}
	if($("#txtjobs_search_keywordSearch").val() != null ) { 
		if ( $("#txtjobs_search_keywordSearch").val().length>0){
			retlink +="#keywordsSearch="+Base64.encode($("#txtjobs_search_keywordSearch").val());
		}
	}
	return retlink.replace(/,/gi,"+");
}

function saveJobSearch(){
	var msg_overwrite="È necessario eliminare uno cerca di salvare una nuova.";
	msg_overwrite= SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.savejob.overwritemsg');
	if (getUrlVars()["searchCode"] != undefined && getUrlVars()["searchCode"] != null){
		var searchCode = getUrlVars()["searchCode"];
	}else{
		var searchCode = 0;
	}
	var retlink = getJobsSearchCriteria();
	var result = SjaxSendRequest('saveCandSearch','POST','system/ajaxRequest.ajax.php','searchLink='+retlink+"&name="+$("#txtjobs_search_Name").val()+"&alerton="+$("#seljobs_search_Alerton").val()+"&editId="+searchCode);
	if (result == "limit"){
		$(".savejobsSrcMess").html(msg_overwrite);
	}else if (result>0){
		var link = document.location.href;
		//if (!document.location.href.indexOf("&searchCode=")>0){
			window.location.href = "index.php?content="+getUrlVars()["content"]+"&clearform=1"+retlink.replace(/#/gi,"&")+"&searchCode="+result;
		//}
	}
}
function deleteSearchjobs(element,id)
{
	var result = SjaxSendRequest('deleteCandSearch','POST','system/ajaxRequest.ajax.php','Idsearch='+id);
	if (result<1){
		$(element).parent().remove();
	}
}

function tellafriend(jobId)
{
	var title="Invia ad un amico questa offerta di lavoro!";
	title=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.sendjobtofriend.title');
	var result = SjaxSendRequest('tellafriendjob','POST','sections/tellafriend.php','jobId='+jobId);
	$("#tellafriend").html(result);
	//$("#videoCand").dialog("destroy");
	var btns={};
	btns[jq_dialog_close]=function(){$(this).dialog("close");};
	$("#tellafriend").dialog({
		buttons:btns,
		title: ""+title,
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 370,
		width: 550
	});
}

function tellafriendabouttraining(jobId)
{
	var title="Invia ad un amico questa corso!";
	title=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.sendtrainingtofriend.title');
	var result = SjaxSendRequest('tellafriendjob','POST','sections/tellafriend.php','jobId='+jobId+'&type=training');
	$("#tellafriend").html(result);
	//$("#videoCand").dialog("destroy");
	var btns={};
	btns[jq_dialog_close]=function(){$(this).dialog("close");};
	$("#tellafriend").dialog({
		buttons:btns,
		title: ""+title,
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 370,
		width: 550
	});
}
function sendtrainingtofriend(jobId)
{
	var yourname=$("#txtYourName").val();
	var youremail=$("#txtYourEmail").val();
	var friendname=$("#txtFriendName").val();
	var friendemail=$("#txtFriendEmail").val();
	var resp = SjaxSendRequest('sendtrainingtofriend','POST','system/ajaxRequest.ajax.php','jobId='+jobId+'&friendname='+friendname+'&friendemail='+friendemail+'&yourname='+yourname+'&youremail='+youremail);
	$('#sendmailmessage').eq(0).html(resp);
	$("#tellafriendinputs").hide();
	
}
function sendjobtofriend(jobId)
{
	var yourname=$("#txtYourName").val();
	var youremail=$("#txtYourEmail").val();
	var friendname=$("#txtFriendName").val();
	var friendemail=$("#txtFriendEmail").val();
	var resp = SjaxSendRequest('sendjobtofriend','POST','system/ajaxRequest.ajax.php','jobId='+jobId+'&friendname='+friendname+'&friendemail='+friendemail+'&yourname='+yourname+'&youremail='+youremail);
	$('#sendmailmessage').eq(0).html(resp);
	$("#tellafriendinputs").hide();
	
}
function changeProfileStatus()
{
	var txtDAE="Profili da esaminare";
	var txtSEL="Profili selezionati da acquistare";
	var txtACQ="Profili acquistati";
	var txtSHL="Profili in short list";
	var txtSCA="Non in linea con il profilo ricercato";
	var txtMsgRes = "Lo stato del candidato è stato cambiato";

	txtSEL = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company_manage_cvs.iconlegend.txtSEL');
	txtDAE = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company_manage_cvs.iconlegend.txtDAE');
	txtACQ = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company_manage_cvs.iconlegend.txtACQ');
	txtSHL = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company_manage_cvs.iconlegend.txtSHL');
	txtSCA = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company_manage_cvs.iconlegend.txtSCA');
	txtMsgRes = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company_manage_cvs.iconlegend.result');
	
	if (returnInteger(getUrlVars()["idSearch"])>0){
		var idSearch = returnInteger(getUrlVars()["idSearch"]);
		var state = 1;
		if (returnInteger($("input[name=radioisProf]:checked").val())>0){
			state = returnInteger($("input[name=radioisProf]:checked").val());
		}
		var resp = SjaxSendRequest('changeCandSearchState','POST','system/ajaxRequest.ajax.php','idSearch='+idSearch+"&State="+state+"&cv_code="+getUrlVars()["cv_code"]);
		if (resp>0){
			switch(state){
				case 1:
					$("#candidate_ProfileStatus").find("span[class=icontop]:first").attr("id","icon5");
					$("#candidate_ProfileStatus").find("span[class=icontop]:first").html(txtDAE);
					break;
				case 2:
					$("#candidate_ProfileStatus").find("span[class=icontop]:first").attr("id","icon2");
					$("#candidate_ProfileStatus").find("span[class=icontop]:first").html(txtSEL);
					break;
				case 3:
					$("#candidate_ProfileStatus").find("span[class=icontop]:first").attr("id","icon3");
					$("#candidate_ProfileStatus").find("span[class=icontop]:first").html(txtACQ);
					break;
				case 4:
					$("#candidate_ProfileStatus").find("span[class=icontop]:first").attr("id","icon1");
					$("#candidate_ProfileStatus").find("span[class=icontop]:first").html(txtSHL);
					break;
				case 5:
					$("#candidate_ProfileStatus").find("span[class=icontop]:first").attr("id","icon4");
					$("#candidate_ProfileStatus").find("span[class=icontop]:first").html(txtSCA);
					break;	
			}
			highlightProfilestateC();
			$(".iconlegend").find("div[class=formMessage]:first").html(txtMsgRes);
			$(".iconlegend").find("div[class=formMessage]:first").fadeOut(10000);
		}
	}
}
function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
}
function pauseMovie(movieName) 
{
	//console.log(movieName);
	//console.log($(getFlashMovie(movieName)).attr("classid"));
    getFlashMovie(movieName).pauseMovieComand();
}

function applytojob(jobId)
{
	  var result = SjaxSendRequest('applytojob','POST','system/ajaxRequest.ajax.php','jobId='+jobId);
        var content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_applytojob');
        var failed=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_applytojob_fail');
        var dlg_height=200;
        var dlg_width=400;

        if (result!="NOT_ALLOWED"){
        	if ($(".applyjobbtn")!=undefined){
                $(".applyjobbtn").removeAttr("onclick");
                $(".applyjobbtn").html(result);
        	
        	} 
        	if($("#applyjobbtn_"+jobId)!=undefined){		
                $("#applyjobbtn_"+jobId).removeAttr("onclick");
                $("#applyjobbtn_"+jobId).html(result);
             } 
                $("#applytojob").html('<div id="help_applytojob">'+content+'</div>');
        }else{
                dlg_height=260;
                dlg_width=400;
                $("#applytojob").html('<div id="help_applytojob">'+failed+'</div>');
        }
                $("#applytojob").dialog("option","title","");
                $("#applytojob").dialog('option','height',dlg_height);
                $("#applytojob").dialog('option','width',dlg_width);
                $("#applytojob").dialog('open');
}


function applydirectly(companyId)
{
	var texts = new Array();
	var serverData = SjaxSendRequest('getarraydictionary','GET','system/ajaxRequest.ajax.php','keys=jquery.directapply.dialogtitle-0-jquery.directapply.reason1-0-jquery.directapply.reason2-0-jquery.directapply.reason3-0-jquery.directapply.reason4-0-jquery.directapply.reason5'); ;
	var objTexts =jQuery.parseJSON(serverData); 
	//alert(objTexts["jquery.directapply.reason1"]);
	
	var frm=" <form id='directapplyfrm' name='directapplyfrm'>" +
			"<div id='form_textmsg'></div>"+	
			"<div class='form_input'><input id='chkReason1'  type='checkbox' name='reason' value='reason1'><label id='lblchkReason1'>"+objTexts['jquery.directapply.reason1']+"</label></div><br />" +
			"<div class='form_input'><input id='chkReason2'  type='checkbox' name='reason' value='reason2'><label id='lblchkReason1'>"+objTexts['jquery.directapply.reason2']+"</label></div><br />" +			
			"<div class='form_input'><input id='chkReason3'  type='checkbox' name='reason' value='reason3'><label id='lblchkReason1'>"+objTexts['jquery.directapply.reason3']+"</label></div><br />" +
			"<div class='form_input'><input id='chkReason4'  type='checkbox' name='reason' value='reason4'><label id='lblchkReason1'>"+objTexts['jquery.directapply.reason4']+"</label></div><br />" +
			"<div class='form_input'><input id='chkReason5'  type='checkbox' name='reason' value='reason5'><label id='lblchkReason1'>"+objTexts['jquery.directapply.reason5']+"</label></div><br />" +
			//"<div class='form_input'><input id='btnSubmit'   type='button' name='btnSubmit' value='Salva' onclick='process_applydirectly("+companyId+")'></div>" +
			"</form>";
	var btns_ad={};
	btns_ad[jq_dialog_salva]= function() {
		process_applydirectly(companyId);
	};
	btns_ad[jq_dialog_close]=function(){$(this).dialog("close");};
  
	$("#applydirectly").html('<div id="frm_directapply">'+frm+'</div>');
	$("#applydirectly").dialog({buttons:btns_ad});
	$("#applydirectly").dialog("option","title",""+objTexts['jquery.directapply.dialogtitle']+"");	
	$("#applydirectly").dialog('option','height',305);
	$("#applydirectly").dialog('option','width',540);
	$("#applydirectly").dialog('open');

}
function process_applydirectly(companyId){

	var reasons = new Array();
	var i=0;
	if ($("#applydirectly").find('form[id=directapplyfrm]').html()!=undefined && $("#applydirectly").find('form[id=directapplyfrm]').html()!=null){
		
		$("#directapplyfrm").find('input[name=reason]:checked').each(function(){
		reasons[i]=$(this).attr("value");
		i=i+1;
		});
		//alert($("#directapplyfrm").find('input[name=reason]:checked').val());	
	}
	
	if(reasons.length==0){
	$("#form_textmsg").attr("class",$("#form_textmsg").attr("class")+" clsFieldError");
	errormsg = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.directapply.error1');
	$("#form_textmsg").html(errormsg);	
	}else{

	$("#form_textmsg").html();
	if ($("#form_textmsg").attr("class")!=undefined){
	$("#form_textmsg").attr("class",$("#form_textmsg").attr("class").replace(/clsFieldError/gi,""));
	}
	var phpreasons=reasons.join('_');
	var result = SjaxSendRequest('applydirectly','POST','system/ajaxRequest.ajax.php','companyId='+companyId+'&reasons='+phpreasons);
	$("#applydirectly").dialog('close');
	$(".applyjobbtn").removeAttr("onclick");
	$(".applyjobbtn").html(result);	
		
	content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_applytojob');
	$("#applytojob").html('<div id="help_applytojob">'+content+'</div>');
	$("#applytojob").dialog("option","title","");
	$("#applytojob").dialog('option','height',125);
	$("#applytojob").dialog('option','width',380);
	$("#applytojob").dialog('open');
	}	
	
}

function savejob(jobId)
{
	var result = SjaxSendRequest('savejob','POST','system/ajaxRequest.ajax.php','jobId='+jobId);
	window.location.reload(true	);
	//$("#videoCand").dialog("destroy");
}
function changeselectmonth()
{
var valCombo=$("#selcomAddJobs_Year").val();
	if (valCombo!=""){
	var allvalues=SjaxSendRequest('generateComboMonth', 'POST','system/ajaxRequest.ajax.php', 'year='+valCombo);
	$("#selcomAddJobs_Months").html(allvalues);
	}
}
$("#widget_candidates_meetings").ready(function(){
	$("#candidate_meetings_acordion").accordion({
				collapsible: true,
				autoHeight: false,
				active: false
			});
});
$("#widget_company_meetings").ready(function(){
	$("#company_meetings_acordion").accordion({
				collapsible: true,
				autoHeight: false,
				active: false
			});
});

function saveCompanyVotes(){
	var resp_txt = "Feedback Candidato";
	//alert($("input[name=feedbackPoints]:checked").val());
	var points = ($("#HdnfeedbackPoints").val()<1 || $("#HdnfeedbackPoints").val()>5) ? 1 : $("#HdnfeedbackPoints").val();
	var res = SjaxSendRequest('saveCompanyVotes','POST','system/ajaxRequest.ajax.php','points='+points+"&meetingid="+getUrlVars()["meetingid"]);
	if (res){
		resp_txt = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.feedbackcandidate.txt');
		$("#votesForCandidate").html(resp_txt+" "+points);
	}
}
function saveCandidateVotes(){
	var resp_txt = "Feedback Azienda";
	var points = ($("#HdnfeedbackPoints").val()<1 || $("#HdnfeedbackPoints").val()>5) ? 1 : $("#HdnfeedbackPoints").val();
	var res = SjaxSendRequest('saveCandidatesVotes','POST','system/ajaxRequest.ajax.php','points='+points+"&meetingid="+getUrlVars()["meetingid"]);
	if (res){
		resp_txt = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.feedbackcompany.txt');
		$("#votesForCompany").html(resp+" "+points);
	}
}
function displayRaiting(){
	var value = parseFloat($("#hiddenRaiting").val());
	if (!value){
		value = 0;
	}	
	$(function() {
		$("#candidate_Raiting").progressbar({
			value: value*100/5
		});
	});
}
//functions for candidate confirm postpone or cancel meetings
function confirmmeetingdate(button,CandId,compId,MetId)
{
	var result_msg="";
	var meetingDate = $("input[name=radiodatemeeting]:checked").val();
	var result = SjaxSendRequest('confirmmeeting','POST','system/ajaxRequest.ajax.php','CompId='+compId+'&CandId='+CandId+'&ConfDate='+ meetingDate +'&metId='+MetId);
	if(result=='update'){
		result_msg=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingconfirm.update');;
		$("input[name=btnConfirmeDate_"+MetId+"]").hide();
		$(".candidate_meetings_dates_radiobtns_"+MetId).hide();
		$(".candidate_meetings_link_"+MetId).hide();
		$('.candidate_meetings_dates_message_'+MetId).eq(0).html(result_msg);
		setTimeout(function(){
			window.location.reload(true);
		},1000);
	}
	if(result=='postponed'){
		result_msg=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingconfirm.postponed');;
		$("input[name=btnConfirmeDate_"+MetId+"]").hide();
		$(".candidate_meetings_dates_radiobtns_"+MetId).hide();
		$('.candidate_meetings_dates_message_'+MetId).eq(0).html(result_msg);
	}
	if(result=='canceled'){
		result_msg=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingconfirm.canceled');;
		$("input[name=btnConfirmeDate_"+MetId+"]").hide();
		$(".candidate_meetings_dates_radiobtns_"+MetId).hide();
		$('.candidate_meetings_dates_message_'+MetId).eq(0).html(result_msg);
	}
}

function cancelorpostponemeeting(meetId,type,Idmet)
{
	var msg_dlg="Non puoi o non vuoi partecipare al video-colloquio";
	msg_dlg= SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.cancelpostponemeeting.msgdlg');
	var result = SjaxSendRequest('cancelorpostponemeeting','POST','sections/cancelorpostponemeeting.php','meetId='+meetId+"&type="+type);
	$("#cancelorpostponemeeting").html(result);
	//$("#videoCand").dialog("destroy");
	var btns={};
	btns[jq_dialog_salva]=function(){
		//$(".candidate_meetings_dates_message_"+Idmet).hide();
		sendreasontocompany(meetId,Idmet);
		hideinputsmeetings(Idmet);
		hidelimeetings(Idmet);};
	btns[jq_dialog_close]=function(){$(this).dialog("close");};
	$("#cancelorpostponemeeting").dialog({
		buttons:btns,
		title: ""+msg_dlg,
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 370,
		width: 550
	});
}

function candidatecancelmeetingafterconfirm(meetId,Idmet)
{
	var msg_dlg="Non puoi o non vuoi partecipare al video-colloquio";
	msg_dlg= SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.cancelpostponemeeting.msgdlg');
	var result = SjaxSendRequest('candidatecancelmeetingafterconfirm','POST','sections/cancelorpostponemeeting.php','meetId='+meetId+'&type=candcancelafterconfirm');
	$("#cancelorpostponemeeting").html(result);
	//$("#videoCand").dialog("destroy");
	var btns={};
	btns[jq_dialog_salva]=function(){
		sendreasontocompany(meetId);
		hidelimeetings(Idmet);};
	btns[jq_dialog_close]=function()
	{$(this).dialog("close");};
	$("#cancelorpostponemeeting").dialog({
		buttons:btns,
		title: ""+msg_dlg,
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 370,
		width: 550
	});
}

function sendreasontocompany(meetId,Idmet)
{
	var reason=$("#txtYourReason").val();
	var type=$("#hiddentype").val();
	var resp = SjaxSendRequest('sendreasontocompany','POST','system/ajaxRequest.ajax.php','meetId='+meetId+'&reason='+reason+'&type='+type);
	$('#sendmailmessage1').eq(0).html(resp);
	$(".cancelorpostponeinputs").hide();
}
function cancelorpostpone(button,CandId,compId,MetId)
{
	var res_txt = "Il candidato ha cancellato il video-colloquio";
	res_txt = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingconfirm.canceled'); 
	//var meetingDate = $("input[name=radiodatemeeting]:checked").val();
	var result = SjaxSendRequest('cancelorpostpone','POST','system/ajaxRequest.ajax.php','CompId='+compId+'&CandId='+CandId+'&metId='+MetId);
	if(result=='canceled'){
		$("input[name=btnConfirmeDate_"+MetId+"]").hide();
		$(".candidate_meetings_dates_radiobtns_"+MetId).hide();
		$('.candidate_meetings_dates_message_'+MetId).eq(0).html(res_txt);
	}
}
function hideinputsmeetings(MetId)
{
	var res_txt = "Il candidato ha cancellato il video-colloquio";
	res_txt = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingconfirm.canceled');
		$("input[name=btnConfirmeDate_"+MetId+"]").hide();
		$(".candidate_meetings_dates_radiobtns_"+MetId).hide();
		$(".candidate_meetings_link_"+MetId).hide();
		$(".candidate_meetings_dates_message_"+MetId).show();
		$(".candidate_meetings_dates_message_"+MetId).eq(0).html(res_txt);
	
}
function hidelimeetings(MetId)
{
	$("#meetings_li_"+MetId).hide();
	}

//functions for companies set meeting, cancel or cancel after candidate confirm meeting
function setanotherdate(button,CandCode,MetId){
	$("#txtmeetingDate1").datepicker({
		showOn: 'button',
		dateFormat:"dd/mm/yy",
		buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true,
		showMonthAfterYear:false,
		changeMonth:true,
		changeYear:true,
		stepMonths:120,
		minDate: new Date(),
		maxDate: '+10y'
	});
	$("#txtmeetingDate2").datepicker({
		showOn: 'button',
		dateFormat:"dd/mm/yy",
		buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true,
		showMonthAfterYear:false,
		changeMonth:true,
		changeYear:true,
		stepMonths:120,
		minDate: new Date(),
		maxDate: '+10y'
	});
	$("#txtmeetingDate3").datepicker({
		showOn: 'button',
		dateFormat:"dd/mm/yy",
		buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true,
		showMonthAfterYear:false,
		changeMonth:true,
		changeYear:true,
		stepMonths:120,
		minDate: new Date(),
		maxDate: '+10y'
	});
		
	var mf_msg ="<p>La proposta di video-colloquio è stata inviata correttamente.</p><p>Il candidato riceverà  un alert con la segnalazione del Suo appuntamento.</p>";
    mf_msg =SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingsched.msg');
    var jq_dialog_meetingprop =  SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingsched.btntxt');
    var btns_mf = {};
	btns_mf[jq_dialog_close]=function(){$(this).dialog("close");};
	
	btns_mf[jq_dialog_meetingprop]=function() {
		if (CandCode.length==5){
			var dateMeeting1 = $("#txtmeetingDate1").val();
			var hour1 = $("#selmeetingHour1").val()+":"+$("#selmeetingMinute1").val();
			var dateMeeting2 = $("#txtmeetingDate2").val();
			var hour2 = $("#selmeetingHour2").val()+":"+$("#selmeetingMinute2").val();
			var dateMeeting3 = $("#txtmeetingDate3").val();
			var hour3 = $("#selmeetingHour3").val()+":"+$("#selmeetingMinute3").val();
			var result = SjaxSendRequest('saveanmeeting','POST','system/ajaxRequest.ajax.php','candCode='+CandCode+"&metId="+MetId+"&date1="+dateMeeting1+"&hour1="+hour1+"&date2="+dateMeeting2+"&hour2="+hour2+"&date3="+dateMeeting3+"&hour3="+hour3);
			if(result != 1){//clsFieldError
				$("#txtmeetingDate1").attr("class",$("#txtmeetingDate1").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingHour1").attr("class",$("#selmeetingHour1").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingMinute1").attr("class",$("#selmeetingMinute1").attr("class").replace(/clsFieldError/gi,""));
				$("#txtmeetingDate2").attr("class",$("#txtmeetingDate2").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingHour2").attr("class",$("#selmeetingHour2").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingMinute2").attr("class",$("#selmeetingMinute2").attr("class").replace(/clsFieldError/gi,""));
				$("#txtmeetingDate3").attr("class",$("#txtmeetingDate3").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingHour3").attr("class",$("#selmeetingHour3").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingMinute3").attr("class",$("#selmeetingMinute3").attr("class").replace(/clsFieldError/gi,""));
				$("#frmMessage").html(result.split("<->")[0]);
				var err = result.split("<->")[1];
				err = err.split("/");
				for(var i=0;i<err.length;i++){
					switch(err[i]){
						case "0":
							$("#txtmeetingDate1").attr("class",$("#txtmeetingDate1").attr("class")+" clsFieldError");
							$("#txtmeetingDate2").attr("class",$("#txtmeetingDate2").attr("class")+" clsFieldError");
							$("#txtmeetingDate3").attr("class",$("#txtmeetingDate3").attr("class")+" clsFieldError");
							break;
						case "1":
							$("#selmeetingHour1").attr("class",$("#selmeetingHour1").attr("class")+" clsFieldError");
							$("#selmeetingMinute1").attr("class",$("#selmeetingMinute1").attr("class")+" clsFieldError");
							
							$("#selmeetingHour2").attr("class",$("#selmeetingHour2").attr("class")+" clsFieldError");
							$("#selmeetingMinute2").attr("class",$("#selmeetingMinute2").attr("class")+" clsFieldError");
							
							$("#selmeetingHour3").attr("class",$("#selmeetingHour3").attr("class")+" clsFieldError");
							$("#selmeetingMinute3").attr("class",$("#selmeetingMinute3").attr("class")+" clsFieldError");
							break;
						case "2":
							break;	
					}
				}
			}else{
				
				$("#frmMessage").html("");
				$("#txtmeetingDate1").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingHour1").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingMinute1").attr("class").replace(/clsFieldError/gi,"");
				
				$("#txtmeetingDate2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingHour2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingMinute2").attr("class").replace(/clsFieldError/gi,"");
				
				$("#txtmeetingDate2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingHour2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingMinute2").attr("class").replace(/clsFieldError/gi,"");
			}
			//alert(result);
			
		}
		if(result == 1){
		$("#firstDate").hide();
		$("#secondDate").hide();
		$("#thirdDate").hide();
		$("#frmMessage").eq(0).html(mf_msg);
		$('.ui-dialog-buttonpane button:contains('+jq_dialog_meetingprop+')').hide();
		}
	};
	$("#meetingForm").dialog({
		title: "",
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 300,
		width: 430,
		buttons:btns_mf
	});
}

function setMeetingDate(){
	$("#txtmeetingDate1").datepicker({
		showOn: 'button',
		dateFormat:"dd/mm/yy",
		buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true,
		showMonthAfterYear:false,
		changeMonth:true,
		changeYear:true,
		stepMonths:120,
		minDate: new Date(),
		maxDate: '+10y'
	});
	$("#txtmeetingDate2").datepicker({
		showOn: 'button',
		dateFormat:"dd/mm/yy",
		buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true,
		showMonthAfterYear:false,
		changeMonth:true,
		changeYear:true,
		stepMonths:120,
		minDate: new Date(),
		maxDate: '+10y'
	});
	$("#txtmeetingDate3").datepicker({
		showOn: 'button',
		dateFormat:"dd/mm/yy",
		buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true,
		showMonthAfterYear:false,
		changeMonth:true,
		changeYear:true,
		stepMonths:120,
		minDate: new Date(),
		maxDate: '+10y'
	});
	
	var btns_mf = {};
    var mf_msg ="<p>La proposta di video-colloquio è stata inviata correttamente.</p><p>Il candidato riceverà  un alert con la segnalazione del Suo appuntamento.</p>";
    mf_msg =SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingsched.msg');
    var jq_dialog_meetingprop =  SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingsched.btntxt');
	
    btns_mf[jq_dialog_close]=function(){$(this).dialog("close");};
	btns_mf[jq_dialog_meetingprop]= function() {
		if (getUrlVars()["cv_code"].length==5){
			var dateMeeting1 = $("#txtmeetingDate1").val();
			var hour1 = $("#selmeetingHour1").val()+":"+$("#selmeetingMinute1").val();
			var dateMeeting2 = $("#txtmeetingDate2").val();
			var hour2 = $("#selmeetingHour2").val()+":"+$("#selmeetingMinute2").val();
			var dateMeeting3 = $("#txtmeetingDate3").val();
			var hour3 = $("#selmeetingHour3").val()+":"+$("#selmeetingMinute3").val();
			var brandid = "";
			if ($("#chkcomAddJobs_UseBrands").val()=='on')
				{
				brandid = $("#selcomAddJobs_Brand").val();
				}
			var result = SjaxSendRequest('savemeeting','POST','system/ajaxRequest.ajax.php','candCode='+getUrlVars()["cv_code"]+"&date1="+dateMeeting1+"&hour1="+hour1+"&date2="+dateMeeting2+"&hour2="+hour2+"&date3="+dateMeeting3+"&hour3="+hour3+"&brandid="+brandid);
			if(result != 1){//clsFieldError
				$("#txtmeetingDate1").attr("class",$("#txtmeetingDate1").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingHour1").attr("class",$("#selmeetingHour1").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingMinute1").attr("class",$("#selmeetingMinute1").attr("class").replace(/clsFieldError/gi,""));
				$("#txtmeetingDate2").attr("class",$("#txtmeetingDate2").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingHour2").attr("class",$("#selmeetingHour2").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingMinute2").attr("class",$("#selmeetingMinute2").attr("class").replace(/clsFieldError/gi,""));
				$("#txtmeetingDate3").attr("class",$("#txtmeetingDate3").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingHour3").attr("class",$("#selmeetingHour3").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingMinute3").attr("class",$("#selmeetingMinute3").attr("class").replace(/clsFieldError/gi,""));
				$("#frmMessage").html(result.split("<->")[0]);
				var err = result.split("<->")[1];
				err = err.split("/");
				for(var i=0;i<err.length;i++){
					switch(err[i]){
						case "0":
							$("#txtmeetingDate1").attr("class",$("#txtmeetingDate1").attr("class")+" clsFieldError");
							$("#txtmeetingDate2").attr("class",$("#txtmeetingDate2").attr("class")+" clsFieldError");
							$("#txtmeetingDate3").attr("class",$("#txtmeetingDate3").attr("class")+" clsFieldError");
							break;
						case "1":
							$("#selmeetingHour1").attr("class",$("#selmeetingHour1").attr("class")+" clsFieldError");
							$("#selmeetingMinute1").attr("class",$("#selmeetingMinute1").attr("class")+" clsFieldError");
							
							$("#selmeetingHour2").attr("class",$("#selmeetingHour2").attr("class")+" clsFieldError");
							$("#selmeetingMinute2").attr("class",$("#selmeetingMinute2").attr("class")+" clsFieldError");
							
							$("#selmeetingHour3").attr("class",$("#selmeetingHour3").attr("class")+" clsFieldError");
							$("#selmeetingMinute3").attr("class",$("#selmeetingMinute3").attr("class")+" clsFieldError");
							break;
						case "2":
							break;	
					}
				}
			}else{
				
				$("#frmMessage").html("");
				$("#txtmeetingDate1").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingHour1").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingMinute1").attr("class").replace(/clsFieldError/gi,"");
				
				$("#txtmeetingDate2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingHour2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingMinute2").attr("class").replace(/clsFieldError/gi,"");
				
				$("#txtmeetingDate2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingHour2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingMinute2").attr("class").replace(/clsFieldError/gi,"");
			}
			//alert(result);
			
		}
		if(result == 1){
		$("#firstDate").hide();
		$("#secondDate").hide();
		$("#thirdDate").hide();
		$("#frmMessage").eq(0).html(mf_msg);
		$('.ui-dialog-buttonpane button:contains('+jq_dialog_meetingprop+')').hide();
		}
	};
	
	$("#meetingForm").dialog({
		title: "",
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 300,
		width: 430,
		buttons: btns_mf
	});
}

function setMeetingDateAreaSel(jobId){
	$("#txtmeetingDate1").datepicker({
		showOn: 'button',
		dateFormat:"dd/mm/yy",
		buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true,
		showMonthAfterYear:false,
		changeMonth:true,
		changeYear:true,
		stepMonths:120,
		minDate: new Date(),
		maxDate: '+10y'
	});
	$("#txtmeetingDate2").datepicker({
		showOn: 'button',
		dateFormat:"dd/mm/yy",
		buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true,
		showMonthAfterYear:false,
		changeMonth:true,
		changeYear:true,
		stepMonths:120,
		minDate: new Date(),
		maxDate: '+10y'
	});
	$("#txtmeetingDate3").datepicker({
		showOn: 'button',
		dateFormat:"dd/mm/yy",
		buttonImage: 'images/calendar.gif',
		buttonImageOnly: true,
		showButtonPanel: true,
		showMonthAfterYear:false,
		changeMonth:true,
		changeYear:true,
		stepMonths:120,
		minDate: new Date(),
		maxDate: '+10y'
	});
	
	var btns_mf = {};
    var mf_msg ="<p>La proposta di video-colloquio è stata inviata correttamente.</p><p>Il candidato riceverà  un alert con la segnalazione del Suo appuntamento.</p>";
    mf_msg =SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingsched.msg');
    var jq_dialog_meetingprop =  SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingsched.btntxt');
	
    btns_mf[jq_dialog_close]=function(){$(this).dialog("close");};
	btns_mf[jq_dialog_meetingprop]= function() {
		if (getUrlVars()["cv_code"].length==5){
			var dateMeeting1 = $("#txtmeetingDate1").val();
			var hour1 = $("#selmeetingHour1").val()+":"+$("#selmeetingMinute1").val();
			var dateMeeting2 = $("#txtmeetingDate2").val();
			var hour2 = $("#selmeetingHour2").val()+":"+$("#selmeetingMinute2").val();
			var dateMeeting3 = $("#txtmeetingDate3").val();
			var hour3 = $("#selmeetingHour3").val()+":"+$("#selmeetingMinute3").val();
			
			var result = SjaxSendRequest('savemeetingareasel','POST','system/ajaxRequest.ajax.php','candCode='+getUrlVars()["cv_code"]+"&date1="+dateMeeting1+"&hour1="+hour1+"&date2="+dateMeeting2+"&hour2="+hour2+"&date3="+dateMeeting3+"&hour3="+hour3+"&jobId="+jobId);
			if(result != 1){//clsFieldError
				$("#txtmeetingDate1").attr("class",$("#txtmeetingDate1").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingHour1").attr("class",$("#selmeetingHour1").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingMinute1").attr("class",$("#selmeetingMinute1").attr("class").replace(/clsFieldError/gi,""));
				$("#txtmeetingDate2").attr("class",$("#txtmeetingDate2").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingHour2").attr("class",$("#selmeetingHour2").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingMinute2").attr("class",$("#selmeetingMinute2").attr("class").replace(/clsFieldError/gi,""));
				$("#txtmeetingDate3").attr("class",$("#txtmeetingDate3").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingHour3").attr("class",$("#selmeetingHour3").attr("class").replace(/clsFieldError/gi,""));
				$("#selmeetingMinute3").attr("class",$("#selmeetingMinute3").attr("class").replace(/clsFieldError/gi,""));
				$("#frmMessage").html(result.split("<->")[0]);
				var err = result.split("<->")[1];
				err = err.split("/");
				for(var i=0;i<err.length;i++){
					switch(err[i]){
						case "0":
							$("#txtmeetingDate1").attr("class",$("#txtmeetingDate1").attr("class")+" clsFieldError");
							$("#txtmeetingDate2").attr("class",$("#txtmeetingDate2").attr("class")+" clsFieldError");
							$("#txtmeetingDate3").attr("class",$("#txtmeetingDate3").attr("class")+" clsFieldError");
							break;
						case "1":
							$("#selmeetingHour1").attr("class",$("#selmeetingHour1").attr("class")+" clsFieldError");
							$("#selmeetingMinute1").attr("class",$("#selmeetingMinute1").attr("class")+" clsFieldError");
							
							$("#selmeetingHour2").attr("class",$("#selmeetingHour2").attr("class")+" clsFieldError");
							$("#selmeetingMinute2").attr("class",$("#selmeetingMinute2").attr("class")+" clsFieldError");
							
							$("#selmeetingHour3").attr("class",$("#selmeetingHour3").attr("class")+" clsFieldError");
							$("#selmeetingMinute3").attr("class",$("#selmeetingMinute3").attr("class")+" clsFieldError");
							break;
						case "2":
							break;	
					}
				}
			}else{
				
				$("#frmMessage").html("");
				$("#txtmeetingDate1").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingHour1").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingMinute1").attr("class").replace(/clsFieldError/gi,"");
				
				$("#txtmeetingDate2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingHour2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingMinute2").attr("class").replace(/clsFieldError/gi,"");
				
				$("#txtmeetingDate2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingHour2").attr("class").replace(/clsFieldError/gi,"");
				$("#selmeetingMinute2").attr("class").replace(/clsFieldError/gi,"");
			}
			//alert(result);
			
		}
		if(result == 1){
		$("#firstDate").hide();
		$("#secondDate").hide();
		$("#thirdDate").hide();
		$("#frmMessage").eq(0).html(mf_msg);
		$('.ui-dialog-buttonpane button:contains('+jq_dialog_meetingprop+')').hide();
		}
	};
	
	$("#meetingForm").dialog({
		title: "",
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 300,
		width: 430,
		buttons:btns_mf
	});
}

function setInstantMeeting(){
	var btns_mf = {};
    var mf_msg ="<p></p>";
    mf_msg =SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company_selected_cv.instmeet.txt2');
    var jq_dialog_meetingprop =  SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingsched.btntxt');
	
    btns_mf[jq_dialog_close]=function(){$(this).dialog("close");};
	btns_mf[jq_dialog_meetingprop]= function() {
		if (getUrlVars()["cv_code"].length==5){				
			var brandid = "";
			if ($("#chkcomAddJobs_UseBrands").val()=='on')
				{
				brandid = $("#selcomAddJobs_Brand").val();
				}
			var result = SjaxSendRequest('instantmeeting','POST','system/ajaxRequest.ajax.php','candCode='+getUrlVars()["cv_code"]+"&brandid="+brandid);
			if(result != 1){//clsFieldError				
				$("#frmMessage").html(result.split("<->")[0]);
				var err = result.split("<->")[1];
				err = err.split("/");
				for(var i=0;i<err.length;i++){
					switch(err[i]){
						case "0":			
							break;
						case "1":
							break;
						case "2":
							break;	
					}
				}
			}else{				
				$("#frmMessage").html("");			
			}			
		}
		if(result == 1){		
		$("#meetingInstant").eq(0).html(mf_msg);
		$('.ui-dialog-buttonpane button:contains('+jq_dialog_meetingprop+')').hide();
		}
	};
	
	$("#meetingInstant").dialog({
		title: "",
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 150,
		width: 430,
		buttons: btns_mf
	});
}

function setInstantMeetingAreaSel(jobId){
	var btns_mf = {};
    var mf_msg ="<p></p>";
    mf_msg =SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company_selected_cv.instmeet.txt2');
    var jq_dialog_meetingprop =  SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingsched.btntxt');
	
    btns_mf[jq_dialog_close]=function(){$(this).dialog("close");};
	btns_mf[jq_dialog_meetingprop]= function() {
		if (getUrlVars()["cv_code"].length==5){
	
			var result = SjaxSendRequest('instantmeetingareasel','POST','system/ajaxRequest.ajax.php','candCode='+getUrlVars()["cv_code"]+"&jobId="+jobId);
			if(result != 1){//clsFieldError
				
				$("#frmMessage").html(result.split("<->")[0]);
				var err = result.split("<->")[1];
				err = err.split("/");
				for(var i=0;i<err.length;i++){
					switch(err[i]){
						case "0":
							break;
						case "1":							
							break;
						case "2":
							break;	
					}
				}
			}else{
				
				$("#frmMessage").html("");
			}		
		}
		if(result == 1){
		$("#meetingInstant").eq(0).html(mf_msg);
		$('.ui-dialog-buttonpane button:contains('+jq_dialog_meetingprop+')').hide();
		}
	};
	
	$("#meetingInstant").dialog({
		title: "",
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 150,
		width: 430,
		buttons:btns_mf
	});
}

function cancelmeeting(meetId,type,Idmet)
{
	var result = SjaxSendRequest('cancelorpostponemeeting','POST','sections/cancelorpostponemeeting.php','meetId='+meetId+"&type="+type);
	$("#cancelorpostponemeeting").html(result);
	//$("#videoCand").dialog("destroy");
	var msg_dlg="Non puoi o non vuoi partecipare al video-colloquio";
	msg_dlg= SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.cancelpostponemeeting.msgdlg');
	var btns={};
	btns[jq_dialog_close]=function(){$(this).dialog("close");};
	btns[jq_dialog_salva]=function(){
		sendreasontocompany(meetId);
		hidecancelcomp(Idmet);
	};

	$("#cancelorpostponemeeting").dialog({
		buttons:btns,
		title: ""+msg_dlg,
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 370,
		width: 550
	});
	
}

function hidecancelcomp(MetId)
{
	var msg_dlg="L'Azienda ha cancellato il video-colloquio";
	msg_dlg = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.meetingazconfirm.canceled');
	$(".company_meeting_btn_anmeeting_"+MetId).eq(0).html(msg_dlg);
	$(".cancelmeeting_"+MetId).hide();
}

function companycancelmeetingafterconfirm(meetId,compId,idCandidate)
{
	var result = SjaxSendRequest('candidatecancelmeetingafterconfirm','POST','sections/cancelorpostponemeeting.php','meetId='+meetId+'&compId='+compId+'&candId='+idCandidate+'&type=compcancelmeetingaftercandconfirm');
	$("#cancelorpostponemeeting").html(result);
	//$("#videoCand").dialog("destroy");
	var msg_dlg="Non puoi o non vuoi partecipare al video-colloquio";
	msg_dlg = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.cancelpostponemeeting.msgdlg');
	var btns={};
	btns[jq_dialog_close]=function(){$(this).dialog("close");};
	$("#cancelorpostponemeeting").dialog({
		buttons:btns,
		title: ""+msg_dlg,
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: false,
		height: 370,
		width: 550
	});
	
}
function loadCompSearchResults(){
	//alert(document.location.href.substr(document.location.href.indexOf("?content")));
	var result = SjaxSendRequest('companycandsearch','POST','system/ajaxRequest.ajax.php',document.location.href.substr(document.location.href.indexOf("?content")).replace(/ /gi,"+")+"&srcLink="+document.location.href.substr(document.location.href.indexOf("?content")).replace(/ /gi,"+").replace(/&/gi,"#"));
	$("#CandSearchResults").removeAttr("style");
	$("#CandSearchResults").html("<a href='"+document.location.href+"' class='clsaRefreshPage'></a>"+result);
	$("#pgNav").tabs();
	if ($("#pgNav").children("#noRecordsDiv").html() != undefined && $("#pgNav").children("#noRecordsDiv").html() != null){
		$("#pgNav").children(".clsButtonsWhiteOrange").hide();
		$("#pgNav").children(".headerSearchResults").hide();
		$("#pgNav").children("#navContainerDiv").hide();
		$(".clsaRefreshPage").hide();
	}
}
function exitMeeting()
{
	var usertype = SjaxSendRequest('getusertype', 'POST','system/ajaxRequest.ajax.php', 'country=1');;
	switch (usertype.toLowerCase()){
		case "candidate":
			window.location.href = "index.php?content=candidate_meetings&clearform=1";
			break;
		case "employer":
			window.location.href = "index.php?content=company_meetings&clearform=1";
			break;	
	}
}
function returnValuesRegions()
{
	
	var parentcombo=$("#selcomAddTrainingCountry").val();
	
	if (parentcombo=="ITA"){
	var allvalues=SjaxSendRequest('generatecomaddtrainingregions', 'POST','system/ajaxRequest.ajax.php', 'country='+parentcombo);
	$("#selcomAddTraining_Region").html(allvalues);
	}
	else {
		$("#selcomAddTraining_Provinces").html("<option value=\"\">"+selopttxt+"</option>");
		$("#selcomAddTraining_Region").html("<option value=\"\">"+selopttxt+"</option>");
	}
		addTooltipToSelect();
}
function getTipologies(cmbCategory,cmbTipologies)
{
	var valCombo=$(cmbCategory).val();
	// alert(valCombo);
	var allvalues=SjaxSendRequest('generateCombotipologiafromcategory', 'POST','system/ajaxRequest.ajax.php', 'category='+valCombo);
	$("#"+cmbTipologies).html(allvalues);
	addTooltipToSelect();
}
function reloadCandVideoPage(){
	window.location.href = "index.php?content=candidate_video";
}

function republicaTrainingAnnunci(button,nIdJob)
{
	var result = SjaxSendRequest('republictraining','POST','system/ajaxRequest.ajax.php','idjob='+parseInt(nIdJob));
	if (result==1)
	{
		//$("#ripublicaResponse").after("The announce has been succesfull republished");
		window.location.reload(true	);
	}
	else {
		$(button).after(result);
		//$("#responseRecharge").fadeOut(15000);
	}
}

function clonetraining(button,jobId,category)
{
	var err_msg = "Non si dispone di sufficienti ????";
  err_msg = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=company.addTrainings.clone_error');
  var clonedObject = SjaxSendRequest("clonetrainingannouncement","POST","system/ajaxRequest.ajax.php","idjob="+jobId);
	if (parseInt(clonedObject)>0)
	{
		window.location.href="index.php?content=company_trainings&section=company_add_trainings&announcetype="+clonedObject+"&clone=1&announceId="+jobId+"&trainingtype="+category+"&clearform=1";
	}
	else{
		$(button).after("<div class='response_clone'>"+err_msg+"</div>");
		$("#response").fadeOut(15000);
	}
}

function updateTrainingToDate(messBox)
{
	var requestVars = getUrlVars();
	var announceId = requestVars["announcetype"];
	var valability = parseInt(SjaxSendRequest("gettrainingvalability","POST","system/ajaxRequest.ajax.php","typeid="+announceId));
	var nrDays = parseInt($("#txtcomAddTraining_Days").val());
	var nrMonths = parseInt($("#selcomAddTraining_Months").val());
	var nrYear = parseInt($("#selcomAddTraining_Year").val());
	var currentDate = new Date();
	var dateToShow = "00/00/0000";
	if (isNaN(nrDays) && isNaN(nrMonths) && isNaN(nrYear))
	{
		currentDate.setDate(currentDate.getDate()+30);
		// currentDate .setDate(currentDate.getDate());
		dateToShow = currentDate.getDate()+"/"+currentDate.getMonth()+"/"+currentDate.getFullYear();
	}
	else
	{
		var newdate = new Date();
		if (isNaN(nrDays))
			nrDays = newdate.getDate();
		if (isNaN(nrMonths))
			nrMonths = newdate.getMonth()+1;
		if (isNaN(nrYear))
			nrYear = newdate.getFullYear();
		
		newdate.setFullYear(nrYear, nrMonths, nrDays);
		newdate.setDate(newdate.getDate()+valability);
		dateToShow = newdate.getDate()+"/" + newdate.getMonth() + "/" + newdate.getFullYear();
	}
	$("#"+messBox).html(dateToShow);
}

function PrintTraining(link,trainingId)
{
	var idJob = trainingId;
	OpenReport(link,{jobId: idJob});
}

function savetraining(trainingId)
{
	var result = SjaxSendRequest('savetraining','POST','system/ajaxRequest.ajax.php','trainingId='+trainingId);
	window.location.reload(true	);
	//$("#videoCand").dialog("destroy");
	
}
$("#candidate_search_trainings").ready(function(){
	$("#candidate_search_training_accordion").accordion({
				collapsible: true,
				autoHeight: false,
				active: false
			});

});

function republicjobhelp(button,jobId)
{
	var content="";
	content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_ripublicajob');
	var btns = {};
	btns[jq_dialog_confirm]=function(){republicaAnnunci(button,jobId);};
	btns[jq_dialog_cancel]= function(){$(this).dialog("close");};
	var title="Help";
	$("#helpripublicajob").dialog('option','title',title);
	$("#helpripublicajob").dialog('option','height',300);
	$("#helpripublicajob").dialog('option','width',650);
	$("#helpripublicajob").dialog('option','buttons',btns);
	$("#helpripublicajob").html('<div id="help_ripublicajob">'+content+'</div>');
	$("#helpripublicajob").dialog('open');
	
	$( "#helpripublicajob" ).bind( "dialogbeforeclose", function() {
		//republicaAnnunci(button,jobId);
		window.location.reload(true);
	});
}

function deletetrainingannounce(idannouncetype, idCompany){
	 var resp = SjaxSendRequest('deletetrainingannounce', 'POST',
			'system/ajaxRequest.ajax.php', "IdAn="+parseInt(idannouncetype)+"&IdCom="+parseInt(idCompany));
	 var pageName = requestVars['content'];
	 window.location = window.location.protocol + "//" + window.location.host
		+ "/index.php?content=" + pageName + "&section=pay_training_announcements&showform=0&clearform=1";
}
var Base64 = {
		// private property
		_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
	 
		// public method for encoding
		encode : function (input) {
			var output = "";
			var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
			var i = 0;
	 
			input = Base64._utf8_encode(input);
	 
			while (i < input.length) {
	 
				chr1 = input.charCodeAt(i++);
				chr2 = input.charCodeAt(i++);
				chr3 = input.charCodeAt(i++);
	 
				enc1 = chr1 >> 2;
				enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
				enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
				enc4 = chr3 & 63;
	 
				if (isNaN(chr2)) {
					enc3 = enc4 = 64;
				} else if (isNaN(chr3)) {
					enc4 = 64;
				}
	 
				output = output +
				this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
				this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
	 
			}
	 
			return output;
		},
	 
		// public method for decoding
		decode : function (input) {
			var output = "";
			var chr1, chr2, chr3;
			var enc1, enc2, enc3, enc4;
			var i = 0;
	 
			input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
	 
			while (i < input.length) {
	 
				enc1 = this._keyStr.indexOf(input.charAt(i++));
				enc2 = this._keyStr.indexOf(input.charAt(i++));
				enc3 = this._keyStr.indexOf(input.charAt(i++));
				enc4 = this._keyStr.indexOf(input.charAt(i++));
	 
				chr1 = (enc1 << 2) | (enc2 >> 4);
				chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
				chr3 = ((enc3 & 3) << 6) | enc4;
	 
				output = output + String.fromCharCode(chr1);
	 
				if (enc3 != 64) {
					output = output + String.fromCharCode(chr2);
				}
				if (enc4 != 64) {
					output = output + String.fromCharCode(chr3);
				}
	 
			}
	 
			output = Base64._utf8_decode(output);
	 
			return output;
	 
		},
	 
		// private method for UTF-8 encoding
		_utf8_encode : function (string) {
			string = string.replace(/\r\n/g,"\n");
			var utftext = "";
	 
			for (var n = 0; n < string.length; n++) {
	 
				var c = string.charCodeAt(n);
	 
				if (c < 128) {
					utftext += String.fromCharCode(c);
				}
				else if((c > 127) && (c < 2048)) {
					utftext += String.fromCharCode((c >> 6) | 192);
					utftext += String.fromCharCode((c & 63) | 128);
				}
				else {
					utftext += String.fromCharCode((c >> 12) | 224);
					utftext += String.fromCharCode(((c >> 6) & 63) | 128);
					utftext += String.fromCharCode((c & 63) | 128);
				}
	 
			}
	 
			return utftext;
		},
	 
		// private method for UTF-8 decoding
		_utf8_decode : function (utftext) {
			var string = "";
			var i = 0;
			var c = c1 = c2 = 0;
	 
			while ( i < utftext.length ) {
	 
				c = utftext.charCodeAt(i);
	 
				if (c < 128) {
					string += String.fromCharCode(c);
					i++;
				}
				else if((c > 191) && (c < 224)) {
					c2 = utftext.charCodeAt(i+1);
					string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
					i += 2;
				}
				else {
					c2 = utftext.charCodeAt(i+1);
					c3 = utftext.charCodeAt(i+2);
					string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
					i += 3;
				}
	 
			}
	 
			return string;
		}
	 
	};
function generateRandomString(length){
	var str = "";
	var chars = "qwertyuiopasdfghjklzxcvbnm";
	for(i=0;i<length;i++){
		str += chars.charAt(Math.floor(Math.random()*26));
	}
	return str;
}
function checkUserBandwidth(){
	var url = document.location.href.substr(0,document.location.href.indexOf("/"));
	var Str_package = "";
	var packSize = 97.6;
	var dStart = new Date();
	var resp = "";
	var dFinnish = new Date();
	var time = 0;
	var band = [];
	var nrTests = 10;
	for (var i=0;i<nrTests;i++){
		dStart = new Date();
		Str_package = generateRandomString(100000);
		resp = SjaxSendRequest('detectbandwidth', 'POST',url+'/system/ajaxRequest.ajax.php', "package="+Str_package);
		dFinnish = new Date();
		time = dFinnish.getTime()-dStart.getTime();
		band[i] = (packSize * 1000)/time;
	}
	var bandMed = 0;
	for(i=0;i<nrTests;i++){
		bandMed += band[i];
	}
	bandMed = bandMed/nrTests;
	return Math.floor(bandMed);
}
function addOrderBy(nr)
{
	if (document.location.href.indexOf("orderby=1")>0)
	{
		var url = document.location.href.replace("orderby=1","orderby="+nr);
	}else if (document.location.href.indexOf("orderby=2")>0){
		var url = document.location.href.replace("orderby=2","orderby="+nr);
	}else{
		var url = document.location.href+"&orderby="+nr;
	}
	window.location.href = url;	
}

function select_logo_in_hp()
{
		$("#selectLogoinHP").slideDown("slow");	
}
function setAsMainBrand(obj,id)
{
	//alert($(obj).attr("id"));
	var this_id=$(obj).attr("id");
	$("input[name=rdMainBrand]").each(function(){
		if ($(this).attr("id")!=this_id){
			$(this).removeAttr("checked");		
		}
	});
	if ($(obj).attr("checked")=='checked'){
		var resp = SjaxSendRequest('setmainbrand', 'POST','system/ajaxRequest.ajax.php', "brandid="+id+"&act=set");
	}else{
		var resp = SjaxSendRequest('setmainbrand', 'POST','system/ajaxRequest.ajax.php', "brandid="+id+"&act=unset");
	}
	
	//var resp = SjaxSendRequest('setmainbrand', 'POST','system/ajaxRequest.ajax.php', "brandid="+id);
	//alert(resp);
}
function deleteCompanyBrand(id)
{
	var resp = SjaxSendRequest('deletebrand', 'POST','system/ajaxRequest.ajax.php', "brandid="+id);
	//if (resp > 0){
		window.location.reload(true);
	//}
}

function toggleselBrand(chk,id)
{
	var elem = "#"+id;
	if ($(chk).val()=="on"){
		if ($(elem).attr('disabled')=='disabled'){
				$(elem).attr('disabled', false);
				//$(elem).val('');
			}else{
				$(elem).attr('disabled', true);
				$(elem).val('');
			}
	}else{
		$(elem).attr('disabled', true);
		$(elem).val('');
	}
}
function setAsVisible(obj,id)
{
 var visible=0;
 	if ($(obj).attr('checked')=='checked'){
 		visible=1;
 	}
	var resp = SjaxSendRequest('setbrandvisible', 'POST','system/ajaxRequest.ajax.php', "brandid="+id+"&visible="+visible);
}

function addTooltipToSelect(){
	if (!$.browser.msie)
		return;
	$("select").each(function(index){
		$(this).children("option").each(function(i){
			$(this).attr("title",$(this).html());
		});
		
		$(this).children("optgroup").each(function(i){
			$(this).attr("title",$(this).attr("label"));
			$(this).children("option").each(function(i){
				$(this).attr("title",$(this).html());
			});
		});		
	});
}	


function selectDropDownIEbehavior() {
	if (!$.browser.msie)
		return;
	$("select").each(function(index){
	var width=$(this).css("width");
	var div = '<div class="seldivs" style="width:'+width+';overflow:hidden;margin-right:20px;"></div>';
		$(this).wrap(div);
    $(this)
        .mousedown(function(){
            $(this)
               .data("origWidth", width)
               .css("width", "auto");
            if ($(this).width()<$(this).data("origWidth", width)){
            	$(this).css("width", $(this).data("origWidth", width));
            }
        })
        .blur(function(){
            $(this).css("width", width);
        })
        .change(function(){
            $(this).css("width", width);
        });
	});
}

function setCandidateNewsletter(obj,idCandidate)
{
	var active=0;
	if ($(obj).attr('checked')=='checked'){
		active=1;
	}
	var resp = SjaxSendRequest('setCandNewsletter', 'POST','system/ajaxRequest.ajax.php', "idCandidate="+idCandidate+"&active="+active);
}

function canceljob(button,jobid)
{
	var resp = SjaxSendRequest('canceljob', 'POST','system/ajaxRequest.ajax.php', "jobid="+jobid);
	//if (resp == '1')
	//{
		$('.joblist_id_'+jobid).eq(0).html("");
	//}
}
function showdetailedcredit(compId)
{
	var title_dlg_cp="Credito Promozionale";
	title_dlg_cp= SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.dlgcreditdetail.title');
	var btns= {};
	btns[jq_dialog_close]=function(){$(this).dialog("close");};
	$("#detailedcredit").dialog({
		buttons:btns,
		title: "",
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: true,
		height: 250,
		width: 400
	});
}

function showmessagemediumannouncelogin(){
	var resp = SjaxSendRequest('showmessagefreeannounce','GET','system/ajaxRequest.ajax.php','Id=1');
	if (resp=='OK')
	{
	var content="";
	content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_loginmediumannouncemessage');
	$("#loginmediumannouncemessage").html('<div id="help_loginmediumannouncemessage">'+content+'</div>');
	$("#loginmediumannouncemessage").dialog("option","title","Help!");
	$("#loginmediumannouncemessage").dialog('option','height',300);
	$("#loginmediumannouncemessage").dialog('option','width',500);
	$("#loginmediumannouncemessage").dialog('open');	
	}
}

function showmessagefilialefirstlogin(){
	
	if ($("#filialefirstlogin").html()!=null ||$("#filialefirstlogin").html()!=undefined ){

	var resp = SjaxSendRequest('showmessagefilialefirstlogin','GET','system/ajaxRequest.ajax.php','Id=1');
	
		if (resp=='OK')
		{
			var title=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.dlgbranchfirstlogin.title');
			var content="";
			content=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=help_filialefirstlogin');
			var btns={};
			btns[jq_dialog_close]=function(){$(this).dialog("close");};
	
			$("#filialefirstlogin").dialog({
				buttons:btns,
				title: ""+title,
				modal: true,
				closeOnEscape: true,
				closeText: ""+jq_dialog_close,
				resizable: true,
				height: 260,
				width: 550
			});
			$("#filialefirstlogin").html('<div id="help_filialefirstlogin">'+content+'</div>');
			$("#filialefirstlogin").dialog("option","title",title);
			$("#filialefirstlogin").dialog('option','height',300);
			$("#filialefirstlogin").dialog('option','width',500);
			$("#filialefirstlogin").dialog('open');
		}
	}
}

function generatepassword(button,compUserId)
{
	var msg_pwd="<span class='filiali_notacctive'>Password generata! Filiale non attivo!</span>";
	msg_pwd=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.branchpwd.msg');
	var resp = SjaxSendRequest('generatepasswordforfiliale','POST','system/ajaxRequest.ajax.php','compUserId='+compUserId);
	$(button).hide();
	$("#btnGeneratePassword_"+compUserId).eq(0).html(msg_pwd);
}

function disableCombos(combo)
{
	for(i=1;i<=6;i++)
	{
		if($("#selagRepcombo"+combo).val()!="")
		{
			if(i != combo)
				{
				$("#selagRepcombo"+i).attr("disabled",true);
				}
		}
		else
			{
			$("#selagRepcombo"+i).attr("disabled",false);
			}
	}
}

function setCanBuy(obj,id)
{
	var canbuy=0;
	if ($(obj).attr('checked')=='checked'){
		canbuy=1;
	}
	$(obj).parent().find('span[class=msgresp]').html();
	var msg=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.branchmgmt.opt');
	var resp = SjaxSendRequest('setcanbuy', 'POST','system/ajaxRequest.ajax.php', "compuserid="+id+"&canbuy="+canbuy);
	if (resp==true){
		//$(obj).parent().find('span[class=msgresp]').show();
		$(obj).parent().find('span[class=msgresp]').attr("style","float:left;color:green");
		$(obj).parent().find('span[class=msgresp]').html(msg);
		$(obj).parent().find('span[class=msgresp]').slideToggle(2500,'linear');
		
	}
}
function setFCanUseVideo(obj,id){
	var fuv=0;
	if ($(obj).attr('checked')=='checked'){
		fuv=1;
	}
	$(obj).parent().find('span[class=msgresp]').html();
	var msg=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.branchmgmt.opt');
	var resp = SjaxSendRequest('setfilialecanusevideo', 'POST','system/ajaxRequest.ajax.php', "compuserid="+id+"&canusevideo="+fuv);
	if (resp==true){
		//$(obj).parent().find('span[class=msgresp]').show();
		$(obj).parent().find('span[class=msgresp]').attr("style","float:left;color:green");
		$(obj).parent().find('span[class=msgresp]').html(msg);
		$(obj).parent().find('span[class=msgresp]').slideToggle(2500,'linear');
	}
}


function DisableCompany(compid)
{
	var title=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.dlg.title');
	var msg=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.branchmgmt.msg');
	//alert($(obj).attr('checked'));
	var btns = {};
	btns[jq_dialog_yes]=function(){
		var resp = SjaxSendRequest('disablecompany', 'POST','system/ajaxRequest.ajax.php', "compuserid="+compid);
		$(".filiali_tabel").eq(0).html(resp);
		$(this).dialog("close");
		};
	btns[jq_dialog_no]=function(){
		$(this).dialog("close");
		};	
	$("#msgDialogAPL").dialog({
		buttons:btns,
		title: ""+title,
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: true,
		height: 150,
		width: 400
	});
	$("#msgDialogAPL").html(msg);
}
function confirmAPL(compid){
	var resp = SjaxSendRequest('confirmapl', 'POST','system/ajaxRequest.ajax.php', "compid="+compid);
	window.location.reload(true);
}
function EnableCompany(compid)
{
	//alert($(obj).attr('checked'));
	var resp = SjaxSendRequest('enablecompany', 'POST','system/ajaxRequest.ajax.php', "compuserid="+compid);
	$(".filiali_tabel").eq(0).html(resp);
}

function hideHelpBtnBrandvisibility()
{
	var requestVars = getUrlVars();
	if(requestVars["content"]=='company_brands' && requestVars["opt"]=='modify' && $('.cell_brandDisabled').html() != undefined && $('.cell_brandDisabled').html() != null)
		{
			$('#langHelpbrandvisibility').hide();
		}
}

function viewfilialeannouncements(IdComp)
{
	var btns={};
	var title=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.branchann.title');
	btns[jq_dialog_close]=function(){$(this).dialog("close");};
	$("#viewannouncementsdetails_"+IdComp).dialog({
		buttons:btns,
		title: ""+title,
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: true,
		height: 250,
		width: 400
	});

}

function showHideDivTable(divToHide)
{
	if ($("#"+divToHide).is(":visible")){
		$("#"+divToHide).slideUp("slow");
		SjaxSendRequest('setsessionvariable', 'POST','system/ajaxRequest.ajax.php', "status=disable");
	}else {
		$("#"+divToHide).slideDown("slow");
		SjaxSendRequest('setsessionvariable', 'POST','system/ajaxRequest.ajax.php', "status=enable");
	}
}

function toggleExpansion(divToHide,parent)
{
	if ($("#"+divToHide).is(":visible")){
		$("#"+divToHide).slideUp("slow");
		$(parent).html("(+)");
		//SjaxSendRequest('setsessionvariable', 'POST','system/ajaxRequest.ajax.php', "status=disable");
	}else {
		$("#"+divToHide).slideDown("slow");
		//SjaxSendRequest('setsessionvariable', 'POST','system/ajaxRequest.ajax.php', "status=enable");
		$(parent).html("(-)");
	}
}

function deletejobAlert(element,id)
{
	var result = SjaxSendRequest('deleteCandSearch','POST','system/ajaxRequest.ajax.php','Idsearch='+id);
	if (result<1){
		$('.jobalert_list_'+id).remove();
	}
}
function displayVideoAnnunci(jobId)
{
	var title=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.videpres.title');
	var result = SjaxSendRequest('getVideoAnnunci','POST','sections/company_VideoAnnunci.php','jobId='+jobId);
	$("#videoAnnunci").html(result);
	//$("#videoCand").dialog("destroy");
	$("#videoAnnunci").dialog({
		title: ""+title,
		modal: true,
		resizable: false,
		height: 540,
		width: 760
	});
}

function hideOnLoadFrmByVar(frmid, varname) {
	requestVars = getUrlVars();
	if (requestVars[varname] == undefined)
		$("#"+frmid).hide();
	if (requestVars['showform'] == 1)
		$("#"+frmid).show();
}

function deleteItemBranchSettings(type, id)
{  
	//type = {AMC,AB,AP}
	var title=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.dlg.title');
	var msg=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.branchsetmgmt.confirm');
	var msginuse=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.branchmgmt.recinuse');
	//alert($(obj).attr('checked'));
	var btns = {};
	btns[jq_dialog_yes]=function(){
		var resp = SjaxSendRequest('deleteitembranchset', 'POST','system/ajaxRequest.ajax.php', "itmbstype="+type+"&itmbsid="+id);
		if (resp=="in_use"){
			$(".content div >ul:last").after("<div class='jquery_msginpage'>"+msginuse+"</div>");
		}else{
			window.location.reload(true);
		}
		$(this).dialog("close");
		};
	btns[jq_dialog_no]=function(){
		$(this).dialog("close");
		};	
	$("#msgDialogAPL").dialog({
		buttons:btns,
		title: ""+title,
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: true,
		height: 150,
		width: 300
	});
	$("#msgDialogAPL").html(msg);
}
function undoTransferItem(idTransfer){
	
	var title=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.dlg.title');
	var msg=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.branchsetmgmt.confirm');
	var msginuse=SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.branchmgmt.recinuse');
	//alert($(obj).attr('checked'));
	var btns = {};
	btns[jq_dialog_yes]=function(){
		var resp = SjaxSendRequest('undotransferitem', 'POST','system/ajaxRequest.ajax.php', "idTr="+idTransfer);
		if (resp=="in_use"){
			$(".content div >ul:last").after("<div class='jquery_msginpage'>"+msginuse+"</div>");
		}else{
			window.location.reload(true);
		}
		
		$(this).dialog("close");
		};
	btns[jq_dialog_no]=function(){
		$(this).dialog("close");
		};	
	$("#msgDialogTransfer").dialog({
		buttons:btns,
		title: ""+title,
		modal: true,
		closeOnEscape: true,
		closeText: ""+jq_dialog_close,
		resizable: true,
		height: 150,
		width: 300
	});
	$("#msgDialogTransfer").html(msg);

}
function toggleselOpts(chke,ide,chkd,idd,todisable){
	var eleme = "#"+ide;
	var elemd = "#"+idd;
	
	if ($(chke).attr('checked')=='checked'){
		$(todisable).attr('disabled',true);
		if ($(eleme).attr('disabled')=='disabled'){
				$(eleme).attr('disabled', false);
				$(elemd).attr('disabled', true);
				$(elemd).val('');
				$(elemd).parent().next('ul').html('');// cleanup detail list
				$(chkd).attr('checked', false);
			}else{
				$(eleme).attr('disabled', true);
				$(eleme).val('');
				$(eleme).parent().next('ul').html('');// cleanup detail list
				$(elemd).attr('disabled', false);
			}
	}else{
		//$(chkd).attr('checked', true);
		//$(elemd).attr('disabled', false);
		$(todisable).attr('disabled',false);
		$(eleme).attr('disabled', true);
		$(eleme).val('');
		$(elemd).val('');
		$(eleme).parent().next('ul').html('');// cleanup detail list
		$(elemd).parent().next('ul').html('');// cleanup detail list
	}
}
function toggleWorkplaceACM(acm){
	var filter= acm+"Filter";
	var descr = acm+"Description";
	$(filter).val('');
	$(descr).val('');
	$(acm).val('');
	
}
function createListOfRegions(obj,id){
	var countryVal='IT';
		
	if (countryVal=="IT")
	{
		var allvalues=SjaxSendRequest('getlistofregions', 'POST','system/ajaxRequest.ajax.php', 'idrg='+id);
		$(obj).parent().next('ul').html(allvalues);
	}
	else {
		
		$(obj).parent().next('ul').html('');
	}
	addTooltipToSelect();
	
}
function createListOfProvinces(obj,id){
	var countryVal='IT';
	if (countryVal=="IT")
	{
		var allvalues=SjaxSendRequest('getlistofprovinces', 'POST','system/ajaxRequest.ajax.php', 'idr='+id);
		$(obj).parent().next('ul').html(allvalues);
	}
	else {
		
		$(obj).parent().next('ul').html('');
	}
	addTooltipToSelect();
}

function filterCompanySearch(){
	requestVars = getUrlVars();	
	if ($("#FrmCompanySearch") != null && $("#FrmCompanySearch") != undefined){
	window.location.href = "index.php?content=list_companies"+"&compId="+$("#txtCompanySearchKeyword").val();
	}
}

function copyDirectCV(cvcode) {
	var msg_title = "Associate CV to annunci";
	msg_title = SjaxSendRequest('gettxtdictionary','GET','system/ajaxRequest.ajax.php','key=jquery.copyDirectCV.title');
	$("#copyCVtoannunci_"+cvcode).load('../sections/widget_copycvdirect.php?cvcode='+cvcode, 
				function(){;
					var btns_ad={};
					btns_ad[jq_dialog_salva]= function() {
						process_copyDirectCV(cvcode);
					};
					btns_ad[jq_dialog_close]=function(){$(this).dialog("close");};
					$("#copyCVtoannunci_"+cvcode).dialog({buttons:btns_ad});
					$("#copyCVtoannunci_"+cvcode).dialog("option","title",msg_title);
					$("#copyCVtoannunci_"+cvcode).dialog('option','height',540);
					$("#copyCVtoannunci_"+cvcode).dialog('option','width',640);
					$("#copyCVtoannunci_"+cvcode).dialog('open');

				});
}
function process_copyDirectCV(cvcode) {
	var jobs = new Array();
	var jobsr = new Array();
	var i=0;
	//$("#FrmcopyDirectCV").find('input[class=clschkCopyCv]:checked').each(function(){
	$('input.clschkCopyCv.clsmodified:checked').each(function(){
		jobs[i]=$(this).attr("name").substring(7);
		i++;
	});
	i=0;
	$('input.clschkCopyCv.clsmodified:not(:checked)').each(function(){
		jobsr[i]=$(this).attr("name").substring(7);
		i++;
	});
	/*$('input.clsmodified').each(function(){
		if($(this).not('checked')){
			jobsr[j]=$(this).attr("name").substring(7);
			j++;
		}
	});*/
	if (jobs.length!=0 || jobsr.length!=0){
		var phpjobs = jobs.join('-');
		var phpjobsr = jobsr.join('-');
		var result = SjaxSendRequest('copydirectcv','POST','system/ajaxRequest.ajax.php','cvcode='+cvcode+'&jobs='+phpjobs+'&jobsr='+phpjobsr);
		$('input.clschkCopyCv.clsmodified').each(function(){$(this).removeClass('clsmodified');});
		$("#copyCVtoannunci_"+cvcode).dialog('close');
		$("#btnCopyCV_"+cvcode).html(result);	
	}else{
		$("#copyCVtoannunci_"+cvcode).dialog('close');
	}
}

