﻿function ModulePrintPage() {
  lochref = '' + this.location;
	if (lochref.indexOf('?') > 0) {
		lochref = '?' + lochref.substring((lochref.indexOf('?')) + 1);
	} else {
		lochref = '';
	}

	w_width = 790;
	w_height = 500;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=yes';

	fparam = 'print_mod.php'+lochref;
  window.showPrintWindow = open(fparam, 'showPrintWindow', theWindowParam);
	setTimeout('if(showPrintWindow&&!showPrintWindow.closed)showPrintWindow.focus()',100);
}

function VerifyItemPurchasing(theCredits,theUrl)
{
	if (window.confirm('Για να αποκτήσετε πρόσβαση θα σας αφαιρεθούν ' +theCredits+ 'βαθμοί. Θέλετε να συνεχίσετε;')) {
		actionFileAndParams = theUrl;
		location.replace(actionFileAndParams);
	}
}


function ValidateForgotPasswordForm(theForm) {
  var email = theForm.email.value;
	
	if (!email) {
		alert("Πρέπει να γράψετε το email σας.");
		return false;
	} else if ((email.indexOf('@') == -1) || (email.indexOf('.') == -1)) {
		alert("Λανθασμένος τύπος email.");
		return false;
	} else {
		return true;
	}
}

function ValidateRepLoginForm(theForm) {
  var username = theForm.usr_log_username.value;
  var password = theForm.usr_log_password.value;
	
	if (!username) {
		alert("Πρέπει να γράψετε το Όνομα Χρήστη.");
		return false;
	} else if (!password) {
			alert("Πρέπει να γράψετε τον Κωδικό Πρόσβασης.");
			return false;
	} else {
		return true;
	}
}

function ValidateForm_CanPeronal_General(theForm) {
  var can_fname = theForm.can_fname.value;
  var can_lname = theForm.can_lname.value;
  var can_nickname = theForm.can_nickname.value;
  var can_nationality = theForm.can_nationality_cbv_id.value;
  var can_log_username = theForm.can_log_username.value;
  var can_log_password = theForm.can_log_password.value;
  var verifycan_log_password = theForm.verifycan_log_password.value;
	
	if (!can_fname) {
		alert("Πρέπει να γράψετε το Όνομα σας.");
		return false;
	} else if (!can_lname) {
		alert("Πρέπει να γράψετε το Επώνυμο σας.");
		return false;
	} else if (!can_nickname) {
		alert("Πρέπει να γράψετε το Ψευδώνυμο σας.");
		return false;
	} else if (!can_nationality) {
		alert("Πρέπει επιλέξετε την εθνικοτητά σας.");
		return false;
	} else if (!can_log_username) {
		alert("Πρέπει να γράψετε το Όνομα Χρήστη.");
		return false;
	} else if ((can_log_username.length < 4) && (can_log_username != ' ')) {
		alert("Το Όνομα Χρήστη πρέπει να είναι τουλάχιστο 4 χαρακτήρες.");
		return false;
	} else if (!can_log_password) {
		alert("Πρέπει να γράψετε τον Κωδικό Πρόσβασης.");
		return false;
	} else if ((can_log_password.length < 4) && (can_log_password != ' ')) {
		alert("Ο Κωδικός Πρόσβασης πρέπει να είναι τουλάχιστο 4 χαρακτήρες.");
		return false;
	} else if ((can_log_password.indexOf(' ') != -1) && (can_log_password != ' ')) {
		alert("Λανθασμένος τύπος Κωδικού Πρόσβασης.");
		return false;
	} else if (can_log_password != verifycan_log_password) {
		alert("Ο Κωδικός Πρόσβασης δεν είναι ο ίδιος με την Επαλήθευση του.");
		return false;
	} else {
		return true;
	}
}

function ValidateForm_EmpPersonal_General(theForm) {
  var emp_fname = theForm.emp_fname.value;
  var emp_lname = theForm.emp_lname.value;
  var emp_nickname = theForm.emp_nickname.value;
  var emp_pers_email = theForm.emp_pers_email.value;
  var emp_log_username = theForm.emp_log_username.value;
  var emp_log_password = theForm.emp_log_password.value;
  var verifyemp_log_password = theForm.verifyemp_log_password.value;
	
	if (!emp_fname) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!emp_lname) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!emp_nickname) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!emp_pers_email) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if ((emp_pers_email.indexOf('@') == -1) || (emp_pers_email.indexOf('.') == -1)) {
		alert("Λανθασμένος τύπος email.");
		return false;
	} else if (!emp_log_username) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if ((emp_log_username.length < 4) && (emp_log_username != ' ')) {
		alert("Το Όνομα Χρήστη πρέπει να είναι τουλάχιστο 4 χαρακτήρες.");
		return false;
	} else if (!emp_log_password) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if ((emp_log_password.length < 4) && (emp_log_password != ' ')) {
		alert("Ο Κωδικός Πρόσβασης πρέπει να είναι τουλάχιστο 4 χαρακτήρες.");
		return false;
	} else if ((emp_log_password.indexOf(' ') != -1) && (emp_log_password != ' ')) {
		alert("Λανθασμένος τύπος Κωδικού Πρόσβασης.");
		return false;
	} else if (emp_log_password != verifyemp_log_password) {
		alert("Ο Κωδικός Πρόσβασης δεν είναι ο ίδιος με την Επαλήθευση του.");
		return false;
	} else {
		return true;
	}
}

function ValidateForm_EmpContact_General(theForm) {
  var emp_country_cbv_id = theForm.emp_country_cbv_id.value;
  var emp_email = theForm.emp_email.value;

	if (!emp_country_cbv_id) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!emp_email) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if ((emp_email.indexOf('@') == -1) || (emp_email.indexOf('.') == -1)) {
		alert("Λανθασμένος τύπος Email.");
		return false;
	} else {
		return true;
	}
}
function ValidateForm_EmpJop_General(theForm) {
  var jse_id = theForm.jse_id.value;
 	var jserol_id = theForm.jserol_id.value;
	var empjop_title = theForm.empjop_title.value;
	
	var lan_1 = theForm.empjop_lan_language_1_cbv_id.value;
	var	lan_2 = theForm.empjop_lan_language_2_cbv_id.value;
	var	lan_3 = theForm.empjop_lan_language_3_cbv_id.value;
	
	var from_dd = theForm.empjop_available_from_date_dd.value;
  var from_mm = theForm.empjop_available_from_date_mm.value;
  var from_yy = theForm.empjop_available_from_date_yy.value;
  var to_dd = theForm.empjop_available_to_date_dd.value;
  var to_mm = theForm.empjop_available_to_date_mm.value;
  var to_yy = theForm.empjop_available_to_date_yy.value;
	
	var fromdate1 = new Date(from_yy,(from_mm-1),from_dd);
	var todate1 = new Date(to_yy,(to_mm-1),to_dd);
	
	var today = new Date();

	fromdate=from_dd+from_mm+from_yy;
	todate=to_dd+to_mm+to_yy;

	if ((!jse_id)||(!jserol_id)) {
		//alert("Πρέπει να επιλέξετε τομέα και θέση εργασίας.");
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!empjop_title) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (((lan_1 != '')&&(lan_2 != '')&&(lan_1 == lan_2))||((lan_2 != '')&&(lan_3 != '')&&(lan_2 == lan_3))||((lan_1 != '')&&(lan_3 != '')&&(lan_1 == lan_3))) {
		alert("Επιλέξτε διαφορετικές Γλώσσες");
		return false;
	} else if (!fromdate) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!todate) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
  } else if (((from_dd != fromdate1.getDate()) || (from_mm != fromdate1.getMonth()+1) || (from_yy != fromdate1.getFullYear())) && (fromdate != '') ) {
		alert("Λανθασμένη Ημερομηνία");
		return false;
	} else if ( ((to_dd != todate1.getDate()) || (to_mm != todate1.getMonth()+1) || (to_yy != todate1.getFullYear())) && (todate != '') ) {
		alert("Λανθασμένη Ημερομηνία.");
		return false;
	} else if ((fromdate1 > todate1) && (todate != ''))  {
		alert("Οι ημερομηνίες που δώσατε είναι λανθασμένες");
		return false;
	} else {
		return true;
	}
}
function ValidateForm_Art_General(theForm) {
	var cat_id = theForm.cat_id.options[theForm.cat_id.selectedIndex].value;
  var art_title = theForm.art_title.value;

	if (!art_title) {
		alert("Πρέπει να γράψετε τον Τίτλο.");
		return false;
	} else if (!cat_id) {
		alert("Πρέπει να επιλέξετε Κατηγορία.");
		return false;
	} else {
		return true;
	}
}

function ValidateCanLoginForm(theForm) {
  var username = theForm.can_log_username.value;
  var password = theForm.can_log_password.value;
	
	if (!username) {
		alert("Πρέπει να γράψετε το Όνομα Χρήστη.");
		return false;
	} else if (!password) {
			alert("Πρέπει να γράψετε τον Κωδικό Πρόσβασης.");
			return false;
	} else {
		return true;
	}
}
function ValidateEmpLoginForm(theForm) {
  var username = theForm.emp_log_username.value;
  var password = theForm.emp_log_password.value;
	
	if (!username) {
		alert("Πρέπει να γράψετε το Όνομα Χρήστη.");
		return false;
	} else if (!password) {
			alert("Πρέπει να γράψετε τον Κωδικό Πρόσβασης.");
			return false;
	} else {
		return true;
	}
}

function ValidateForm_Can_General(theForm) {
  var can_fname = theForm.can_fname.value;
  var can_lname = theForm.can_lname.value;
  var can_nickname = theForm.can_nickname.value;
  var can_nationality = theForm.can_nationality_cbv_id.value;
  var can_country = theForm.can_country_cbv_id.value;
  var can_email = theForm.can_email.value;
  var can_log_username = theForm.can_log_username.value;
  var can_log_password = theForm.can_log_password.value;
  var verifycan_log_password = theForm.verifycan_log_password.value;
	
	if (!can_fname) {
		alert("Πρέπει να γράψετε το Όνομα σας.");
		return false;
	} else if (!can_lname) {
		alert("Πρέπει να γράψετε το Επώνυμο σας.");
		return false;
	} else if (!can_nickname) {
		alert("Πρέπει να γράψετε το Ψευδώνυμο σας.");
		return false;
	} else if (!can_nationality) {
		alert("Πρέπει να επιλέξετε την εθνικοτητά σας.");
		return false;
	} else if (!can_country) {
		alert("Πρέπει να επιλέξετε την χώρα σας.");
		return false;
	} else if (!can_email) {
		alert("Πρέπει να γράψετε το Email σας.");
		return false;
	} else if ((can_email.indexOf('@') == -1) || (can_email.indexOf('.') == -1)) {
		alert("Λανθασμένος τύπος Email.");
		return false;
	} else if (!can_log_username) {
		alert("Πρέπει να γράψετε το Όνομα Χρήστη.");
		return false;
	} else if ((can_log_username.length < 4) && (can_log_username != ' ')) {
		alert("Το Όνομα Χρήστη πρέπει να είναι τουλάχιστο 4 χαρακτήρες.");
		return false;
	} else if (!can_log_password) {
		alert("Πρέπει να γράψετε τον Κωδικό Πρόσβασης.");
		return false;
	} else if ((can_log_password.length < 4) && (can_log_password != ' ')) {
		alert("Ο Κωδικός Πρόσβασης πρέπει να είναι τουλάχιστο 4 χαρακτήρες.");
		return false;
	} else if ((can_log_password.indexOf(' ') != -1) && (can_log_password != ' ')) {
		alert("Λανθασμένος τύπος Κωδικού Πρόσβασης.");
		return false;
	} else if (can_log_password != verifycan_log_password) {
		alert("Ο Κωδικός Πρόσβασης δεν είναι ο ίδιος με την Επαλήθευση του.");
		return false;
	} else {
		return true;
	}
}

function ValidateForm_Emp_General(theForm) {
  var emp_fname = theForm.emp_fname.value;
  var emp_lname = theForm.emp_lname.value;
  var emp_nickname = theForm.emp_nickname.value;
  var emp_com_name = theForm.emp_com_name.value;
  var emp_country = theForm.emp_country_cbv_id.value;
  var emp_email = theForm.emp_email.value;
  var emp_log_username = theForm.emp_log_username.value;
  var emp_log_password = theForm.emp_log_password.value;
  var verifyemp_log_password = theForm.verifyemp_log_password.value;
	
	if (!emp_fname) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!emp_lname) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!emp_nickname) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!emp_com_name) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!emp_country) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!emp_email) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if ((emp_email.indexOf('@') == -1) || (emp_email.indexOf('.') == -1)) {
		alert("Λανθασμένος τύπος Email.");
		return false;
	} else if (!emp_log_username) {
		alert("Πρέπει να γράψετε το Όνομα Χρήστη.");
		return false;
	} else if ((emp_log_username.length < 4) && (emp_log_username != ' ')) {
		alert("Το Όνομα Χρήστη πρέπει να είναι τουλάχιστο 4 χαρακτήρες.");
		return false;
	} else if (!emp_log_password) {
		alert("Πρέπει να γράψετε τον Κωδικό Πρόσβασης.");
		return false;
	} else if ((emp_log_password.length < 4) && (emp_log_password != ' ')) {
		alert("Ο Κωδικός Πρόσβασης πρέπει να είναι τουλάχιστο 4 χαρακτήρες.");
		return false;
	} else if ((emp_log_password.indexOf(' ') != -1) && (emp_log_password != ' ')) {
		alert("Λανθασμένος τύπος Κωδικού Πρόσβασης.");
		return false;
	} else if (emp_log_password != verifyemp_log_password) {
		alert("Ο Κωδικός Πρόσβασης δεν είναι ο ίδιος με την Επαλήθευση του.");
		return false;
	} else {
		return true;
	}
}
function ValidateForm_CanContact_General(theForm) {
  var can_country_cbv_id = theForm.can_country_cbv_id.value;
  var can_email = theForm.can_email.value;

	if (!can_country_cbv_id) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!can_email) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if ((can_email.indexOf('@') == -1) || (can_email.indexOf('.') == -1)) {
		alert("Λανθασμένος τύπος Email.");
		return false;
	} else {
		return true;
	}
}
function ValidateForm_EmpCompany_General(theForm) {
  var emp_com_name = theForm.emp_com_name.value;
	var ise_id = theForm.ise_id.value;

	if (!emp_com_name) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else if (!ise_id) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else {
		return true;
	}
}

function ValidateForm_Mem_RegCredits(theForm) {
  var smscode = theForm.smscode.value;
	
	if (!smscode) {
		alert("Πρέπει να γράψετε το Κωδικό που λάβατε μέσω SMS.");
		return false;
	} else {
		return true;
	}
}

function ValidateForm_CanEdu_General(theForm) {
  var canedu_level = theForm.canedu_level_cbv_id.value;

	if (!canedu_level) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else {
		return true;
	}
}
function ValidateForm_CanSki_General(theForm) {
  var canski_title = theForm.canski_title.value;

	if (!canski_title) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else {
		return true;
	}
}
function ValidateForm_CanLan_General(theForm) {
  var canlan_language = theForm.canlan_language_cbv_id.value;

	if (!canlan_language) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else {
		return true;
	}
}
function ValidateForm_CanWex_General(theForm) {
  var jse_id = theForm.jse_id.value;
 	var jserol_id = theForm.jserol_id.value;
	
	if ((!jse_id)||(!jserol_id)) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		//alert("Πρέπει να επιλέξετε τομέα και θέση εργασίας.");
		return false;
	} else {
		return true;
	}
}
function ValidateForm_CanJin_General(theForm) {
  var jse_id = theForm.jse_id.value;
 	var jserol_id = theForm.jserol_id.value;
	
	if ((!jse_id)||(!jserol_id)) {
		alert("Πρέπει να επιλέξετε τομέα και θέση εργασίας.");
		return false;
	} else {
		return true;
	}
}
function ValidateForm_CanSem_General(theForm) {
  var cansem_title = theForm.cansem_title.value;

	if (!cansem_title) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else {
		return true;
	}
}
function ValidateForm_CanAff_General(theForm) {
  var canaff_title = theForm.canaff_title.value;

	if (!canaff_title) {
		alert("Όλα τα πεδία με αστερίσκο (*) πρέπει να συμπληρωθούν.");
		return false;
	} else {
		return true;
	}
}
function goToFindArticle(theform) {
  var ArtContains = theform.art_contains.value;
	var fdate_dd = theform.art_fdate_dd.options[theform.art_fdate_dd.selectedIndex].value;
	var fdate_mm = theform.art_fdate_mm.options[theform.art_fdate_mm.selectedIndex].value;
	var fdate_yy = theform.art_fdate_yy.options[theform.art_fdate_yy.selectedIndex].value;
	
	var tdate_dd = theform.art_tdate_dd.options[theform.art_tdate_dd.selectedIndex].value;
	var tdate_mm = theform.art_tdate_mm.options[theform.art_tdate_mm.selectedIndex].value;
	var tdate_yy = theform.art_tdate_yy.options[theform.art_tdate_yy.selectedIndex].value;
  
	
	if (fdate_dd < 10) {
		fdate_dd = '0'+fdate_dd;
	}
  if (fdate_mm < 10) {
		fdate_mm = '0'+fdate_mm;
	}
	fromdate = fdate_yy+'-'+fdate_mm+'-'+fdate_dd;

	if (tdate_dd < 10) {
		tdate_dd = '0'+tdate_dd;
	}
  if (tdate_mm < 10) {
		tdate_mm = '0'+tdate_mm;
	}
	todate = tdate_yy+'-'+tdate_mm+'-'+tdate_dd;

  lochref = 'index.php?pageaction=you&modid=SearchArticles&criteria=set';

		if (ArtContains != '') {	lochref += '&contains=' + ArtContains; }
		if (fromdate != '') {	lochref += '&fdate=' + fromdate; }
		if (todate != '') {	lochref += '&tdate=' + todate; }

	location = lochref;
}


function uploadAsset(theSection, theFolder, theId, theReturnURL) {
	w_width = 570;
	w_height = 150;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=yes';
	
	fparam = 'admin/modules/ws_mod_you_01/tools/upload_file.php?section='+theSection+'&folder='+theFolder+'&id='+theId+'&returnurl='+theReturnURL;
  window.uploadAssetWindow = open(fparam, 'uploadAssetWindow', theWindowParam);
	setTimeout('if(uploadAssetWindow&&!uploadAssetWindow.closed)uploadAssetWindow.focus()',100);
}

var browser = new checkBrowser();
var preloadInterval ="";

function checkBrowser() {
   var userAgent = navigator.userAgent.toLowerCase()
   this.isIE = (userAgent.indexOf('msie') != -1);
   this.isGecko = (userAgent.indexOf('gecko') != -1 && userAgent.indexOf('safari') == -1);
   this.isOpera = (userAgent.indexOf('opera') != -1)
   this.isRTECompatible= (this.isIE || this.isGecko);
}

function preloadImage(ImageID) {
// ---------------------------------------------------------------------------------------------------
// preloadImage([id of an img tag])
// ---------------------------------------------------------------------------------------------------
// This function can be used in the previewArea only!
// It tests if the download of an image is complete. On positive result it:
//  - displays the image by changing its display properties
//  - changes the size of large images
//  - removes its own interval
//
// Usage example:
// if(preloadInterval!="") clearInterval(preloadInterval);            // remove possible old interval
// preloadInterval = setInterval("preloadImage('"+ImageID+"')",100);  // start this function in an interval

//settings for height and width according to source of functioncall
var ImgWidth = 190;
var ImgHeight= 190;
//if(Caller == 1)
//{
//ImgWidth = 200;
//ImgHeight = 200;
//}


  if(document.getElementById(ImageID).complete) {                     // do nothing while the image is not uploaded yet

// create dummy image to get (non-cached) image width & height
    testImage=document.createElement("img");
    testImage.src=document.getElementById(ImageID).src;

    percent = 100;
    if(testImage.width != 0) {                                        // do nothing while the width is unset
      document.getElementById(ImageID).style.display="block";
      if(testImage.width> ImgWidth || testImage.height> ImgHeight) {
// resize large images
        horPercent = 100*ImgWidth/testImage.width;
        verPercent = 100*ImgHeight/testImage.height;
        if(horPercent > verPercent) {
            document.getElementById(ImageID).height =ImgHeight;
            document.getElementById(ImageID).width =testImage.width * verPercent / 100;
            percent = verPercent;
        }  else {
            document.getElementById(ImageID).width =ImgWidth;
            document.getElementById(ImageID).height =testImage.height * horPercent / 100;
            percent = horPercent;
        }
      } else {
// reset image sizes for 1:1 Images
        document.getElementById(ImageID).width = testImage.width;
        document.getElementById(ImageID).height = testImage.height;
      }
// calculate new postion
      newMarginLeft = document.getElementById(ImageID).width/2;
      newMarginTop = document.getElementById(ImageID).height/2;

      if (!browser.isOpera)
      {
        document.getElementById(ImageID).style.left="50%";
        document.getElementById(ImageID).style.top="50%";
        document.getElementById(ImageID).style.marginLeft="-"+newMarginLeft+"px";
        document.getElementById(ImageID).style.marginTop="-"+newMarginTop +"px";
      }
      else
      {
        document.getElementById(ImageID).style.margin='auto';
      }

      newTextnode= document.createTextNode("("+Math.floor(percent)+"%)");
      document.getElementById("Percentage").replaceChild(newTextnode, document.getElementById("Percentage").firstChild);
      document.getElementById("Loading").style.display="none";
      document.getElementById("Percentage").style.display="inline";
      clearInterval(preloadInterval);
    }
  }
}

function changePreviewImage(ImageID, ImageURL, ImageTitle) {
// changes the PreviewImage in the PreviewArea and starts the image preloader
  changeImage(ImageID, ImageURL, ImageTitle);
  document.getElementById(ImageID).style.display="none";      // hide preview image while loading
  document.getElementById("Loading").style.display="inline";  // display Loading info
  document.getElementById("Percentage").style.display="none"; // hide image size while loading

  if(preloadInterval!="") clearInterval(preloadInterval);
  preloadInterval = setInterval("preloadImage('"+ImageID+"')",100);
}

function changeImage(ImageID, ImageURL, ImageTitle) {
// changes the image url & title of an image element (specified by its id attribute)
  theTmpInterval = setInterval("document.getElementById('"+ImageID+"').src = '"+ImageURL+"';", 0);   // display image
//  document.getElementById(ImageID).src = ImageURL;
  if (ImageTitle) {
    document.getElementById(ImageID).alt = ImageTitle;
  }
}

function ShowImageNormalSize(theImage) {
	w_width = 100;
	w_height = 100;
	if (screen) {
		w_left = 10;
		w_top = 10;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=yes,scrollbars=yes';
	
	fparam = 'admin/modules/ws_mod_you_01/tools/show_normal_size.php?img=' + theImage;
  window.ShowImageNormalSizeWindow = open(fparam, 'ShowImageNormalSizeWindow', theWindowParam);
	setTimeout('if(ShowImageNormalSizeWindow&&!ShowImageNormalSizeWindow.closed)ShowImageNormalSizeWindow.focus()',100);
}

function UpdateJobSectorRolesCompoBox(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				var ajaxDisplay = document.getElementById('ShowJobSectorRoles');
				ajaxDisplay.innerHTML = ajaxRequest.responseText;
			}
		}
		var jse_id = document.getElementById('jse_id').value;
		var queryString = "?jseid=" +jse_id;
		ajaxRequest.open("GET", "modules/ws_mod_you_01/populate_roles_combobox/index.php" + queryString, true);
		ajaxRequest.send(null); 
}



function SearchJobResultsOrdering(theForm, theCurSort, theCanJinId) {
	  var theNewSort = theForm.sort_value.value;
		var theSortOrder = 'ASC';
		
		if (theNewSort == theCurSort) {
			theSortOrder = 'DESC';
		}


  lochref = 'index.php?pageaction=you&modid=CanSearchJobs&recaction=searchjobs&canjinid='+theCanJinId;

		if (theNewSort != '') {	lochref += '&sort=' + theNewSort; }
		if (theSortOrder != '') {	lochref += '&sortorder=' + theSortOrder; }

	location = lochref;
}

function SearchCandidatesResultsOrdering(theForm, theCurSort, theEmpJopId) {
	  var theNewSort = theForm.sort_value.value;
		var theSortOrder = 'ASC';
		
		if (theNewSort == theCurSort) {
			theSortOrder = 'DESC';
		}


  lochref = 'index.php?pageaction=you&modid=EmpSearchCandidates&recaction=searchcan&empjopid='+theEmpJopId;

		if (theNewSort != '') {	lochref += '&sort=' + theNewSort; }
		if (theSortOrder != '') {	lochref += '&sortorder=' + theSortOrder; }

	location = lochref;
}