function onOffLanguageSwitcher() {
	
	var langSwitcher = document.getElementById('langSwitchList');
	if (langSwitcher.style.display=='none') langSwitcher.style.display='block'; else langSwitcher.style.display='none';
	
}

// function for displaying/hiding wait icon (div is defined in corex_FOOTER) 
function waitIcon(status) {
	
	if   (status=='show')
		document.getElementById('ajaxProcess_waitIcon').style.display = 'block';
	else
		document.getElementById('ajaxProcess_waitIcon').style.display = 'none';
			
}

function submitLogonForm(log,pas)   { 
	
	var l = document.getElementById(log).value;
	var p = document.getElementById(pas).value;
	
	xajax_checkUser(l,p); 

}
function showDefault(inputId) {
	
	var inputId_def = inputId + '_def';
	
	if (document.getElementById(inputId).value=='') 
		document.getElementById(inputId).value = document.getElementById(inputId_def).value;
	
}
function hideDefault(inputId) {
	
	var inputId_def = inputId + '_def';
	
	if (document.getElementById(inputId).value == document.getElementById(inputId_def).value)
		document.getElementById(inputId).value = '';
	
}

function submitLogoffForm()  { document.forms.FORM__userLogoffArea.submit();  }
function submitContactForm() {
	
	var mustBeFilled = new Array('name','email','comment');
	
	if      (checkIfFieldsFilled(mustBeFilled)==false) alert(document.getElementById('NOT_ALL_FILLED_ERRORMESSAGE').value);
	else if (checkMail('email')==false)                alert(document.getElementById('NOT_VALID_EMAIL_ERRORMESSAGE').value);
	else {
		xajax_submitContactForm(xajax.getFormValues('FORM__contact'));
	}
	
}
function submitSearchBox() {
	
	if (document.getElementById('search_textbox_def').value!=document.getElementById('search_textbox').value && document.getElementById('search_textbox').value!='')
		document.getElementById('sBA_searchbox').submit();
	
}

function addToNewsletter() {
	
	var email = document.getElementById('nl_email').value;
	var name  = document.getElementById('nl_name').value;
	
	if (name == document.getElementById('nl_name_def').value) name = '';
	    
	if (corex.checkMail(email)) {
	
		document.getElementById('nl_em').value = email;
		document.getElementById('nl_nm').value = name;
		document.getElementById('nl_ac').value = 'add';  

		xajax_corex_templateLoader('newsletter','NL_ADD_AREA',xajax.getFormValues('nl'));
		
	} 
	
}
function updateShirttextBox() {

	document.getElementById('shirttext_box').innerHTML = document.getElementById('shirttext_text').value;
	
}
function openShirttextInCreator(text) {
	
	if (text!='') {
		
		document.getElementById('shirttext_text').value  = text;
		document.getElementById('shirttext_form').action = document.getElementById('shirttext_form').action + '?sq='+text+'&sc=creator';
		document.getElementById('shirttext_form').submit();
		
	}
	
}

function getSelectedValueText(inputBoxId) {
	
	var tmp    = document.getElementById(inputBoxId);
	
	var retVal = '';
	
	for (i=0;i<tmp.length;i++) {
		if (tmp[i].value==tmp.value) {
			
			retVal = tmp[i].text; 
			
		}
	}
	
	return(retVal);
	
}

// ---------------> misc global functions <--------------------------------------------------------------------------------------------------------------------
function in_array(val,a)
{
  for(var i=0;i<a.length;i++)
  {
    if (a[i]==val) return true;
  }
  return false;
}
function array_search(val,a) 
{
  for(var i=0;i<a.length;i++)
  {
    if (a[i]==val) return i;
  }
  return 0;
}


function iconBigOver(n) { 
	document.getElementById("btn"+n).className = "btn1On" ;  
}
function iconBigOut(n)  { 
	document.getElementById("btn"+n).className = "btn1Off" ; 
}

function checkIfFieldsFilled(fieldsList) {
	
	allFilled = true;
	
	for(i=0;i<fieldsList.length;i++) {
		if (document.getElementById(fieldsList[i]).value=='') allFilled = false;
	}
	
	return(allFilled);
}
function checkMail(email) {
	 var regExpEmail=/^.+@.+\..+$/;
	 var o = document.getElementById(email);
	 if(!regExpEmail.exec(o.value)) return(false); 
	 						   else return(true);
}

function get_ed_text(editor_name) {

    var oEditor = FCKeditorAPI.GetInstance(editor_name) ;
    if (oEditor.EditorDocument.body.innerHTML) {
	  	  return oEditor.GetXHTML();
          // return oEditor.EditorDocument.body.innerHTML;
    }
    else return '';
}

function replaceSubstring(inputString, fromString, toString) {
	return corex.replaceSubstring(inputString, fromString, toString);
}

// --------- POPUP BOX HANDLER -----------------------------------------------------
function showPopup(contentElementId,boxWidth,boxHeight) {

	var popupBox = document.getElementById('POPUP_TEXTBOX');
	var content  = document.getElementById(contentElementId);
	
	if(boxWidth>0)  popupBox.style.width  = boxWidth + 'px';
	if(boxHeight>0) popupBox.style.height = boxHeight + 'px';
	
	popupBox.innerHTML     = content.innerHTML;
	
	popupBox.style.top     = parseInt(corex.mouseY) + 10 + 'px';
	popupBox.style.left    = parseInt(corex.mouseX) + 10 + 'px';
	
	popupBox.style.display = 'block';
	
}
function hidePopup() {
	
	document.getElementById('POPUP_TEXTBOX').style.display='none';
	
	updatePopupBoxPosition = 0;
	
}
// ------------------------------------------------------------------------------------

function getElementHeight(Elem) {	
	return corex.getElementHeight(Elem);
}

function getElementWidth(Elem) {
	return corex.getElementWidth(Elem);
}

function findPos(obj) {
	return(corex.findPos(obj));
}

function is_int( mixed_var ) {
    // *     example 1: is_int(23)
    // *     returns 1: true
    // *     example 2: is_int('23')
    // *     returns 2: false
    // *     example 3: is_int(23.5)
    // *     returns 3: false
    // *     example 4: is_int(true)
    // *     returns 4: false
 
    if (typeof mixed_var !== 'number') {
        return false;
    }
 
    if (parseFloat(mixed_var) != parseInt(mixed_var, 10)) {
        return false;
    }
    
    return true;
}