function trim(text){
	text = text.replace(/^\s+/, "");
	text = text.replace(/\s+$/, "");
	text = text.replace(/\s+/g, " ");
	return text;
}

function preloader() 
{

var i = 0;  

imageObj = new Image();
images = new Array();     
images[0]="graphics/elements/font_size_mo.png"  
images[1]="graphics/elements/font_size_first_mo.png"   
images[2]="graphics/fillers/button_mo.png"  
images[3]="graphics/fillers/menu_mo.png"     
images[4]="graphics/widgets/day_mo.png"  
for(i=0; i<=4; i++)      
{imageObj.src=images[i];}

}

function loadMonth(strMonth, strYear){
	
	var myAjax = new Ajax('code/modules/calendar_include.asp?month=' + strMonth + '&year=' + strYear + '&_r='+Math.random(), {update: 'calendar', onComplete: okok, method:'get'});
	myAjax.request();
	
}

function okok(responseText){
	/* Tips 1 */
	var Tips1 = new Tips($$('.Tips1'));
				
	/* Tips 2 */
	var Tips2 = new Tips($$('.today'), {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});

	/* Tips 3 */
	var Tips3 = new Tips($$('.Tips3'), {
		showDelay: 500,
		hideDelay: 500,
		fixed: true
	});

	/* Tips 4 */
	var Tips4 = new Tips($$('.Tips4'), {
		className: 'custom'
	});
}

function checkLen(Target, intLen, strChars){

	StrLen = Target.value.length;
	if (StrLen > intLen){
		Target.value = Target.value.substring(0, intLen);
		charsLeft = 0;
	}
	else{
		charsLeft = intLen - StrLen;
	}
	document.getElementById(strChars).innerHTML = charsLeft;
	
}

function showHide(strObject){
	if(document.getElementById(strObject).style.display == 'none'){
		document.getElementById(strObject).style.display = 'block';
	}else{
		document.getElementById(strObject).style.display = 'none';
	}
}

function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

function popupWindow(strURL){		
	window.open(strURL);
}

function copyText(strText)
{
document.getElementById('holdtext').innerText = strText;
Copied = holdtext.createTextRange();
Copied.execCommand("Copy");
}

function checkSearchForm(strAbsURL){		
	
	var objKW = document.getElementById("frm_search_box");
	var objFilt = document.getElementById("frm_searchitems");
	
	if (trim(objKW.value).length < 3 || trim(objKW.value) == "Type your keyword here"){
		alert("Please enter your keyword(s).");
		objKW.value = trim(objKW.value);
		objKW.focus();
	}else{
		// search/{page number}/{search what: 0 = all}/{keywords}
		window.location.href=strAbsURL + "search/1/" + objFilt.value + "/" + objKW.value;
	}
	
	
}

function checkNewsroomSearchForm(){		
	
	var objForm = document.getElementById("srch_frm2");
	
	if (trim(objForm.keywords.value).length < 3){
		alert("Please enter your keyword(s).");
		objForm.keywords.value = trim(objForm.keywords.value);
		objForm.keywords.focus();
		return false;
	}
	
	return true;
}

function checkSubscribeForm(){		
	
	var objForm = document.getElementById("subscribeForm");
	
	if (trim(objForm.frm_name.value).length < 2){
		alert("Please enter your first name.");
		objForm.frm_name.value = trim(objForm.frm_name.value);
		objForm.frm_name.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim(objForm.frm_email.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.frm_email.value = trim(objForm.frm_email.value);
		objForm.frm_email.focus();
		return false;
	}
	
	return true;
}

function checkUnSubscribeForm(){		
	
	var objForm = document.getElementById("subscribeForm");
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim(objForm.frm_email.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.frm_email.value = trim(objForm.frm_email.value);
		objForm.frm_email.focus();
		return false;
	}
	
	return true;
}

function checkFeedbackForm(){		
	
	var objForm = document.getElementById("feedbackForm");
	
	if (trim(objForm.frm_name.value).length < 2){
		alert("Please enter your name.");
		objForm.frm_name.value = trim(objForm.frm_name.value);
		objForm.frm_name.focus();
		return false;
	}
	
	if (trim(objForm.frm_surname.value).length < 2){
		alert("Please enter your surname.");
		objForm.frm_surname.value = trim(objForm.frm_surname.value);
		objForm.frm_surname.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim(objForm.frm_email.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.frm_email.value = trim(objForm.frm_email.value);
		objForm.frm_email.focus();
		return false;
	}
	
	if (trim(objForm.frm_message.value).length < 2){
		alert("Please enter your message.");
		objForm.frm_message.value = trim(objForm.frm_message.value);
		objForm.frm_message.focus();
		return false;
	}
	
	return true;
	
}

function checkSTFF(){		
	
	var objForm = document.getElementById("stfForm");
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim(objForm.r1.value)))){
		alert("Please enter a valid email address for your friend.");
		objForm.r1.value = trim(objForm.r1.value);
		objForm.r1.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim(objForm.r2.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.r2.value = trim(objForm.r2.value);
		objForm.r2.focus();
		return false;
	}
	
	return true;
}



function loadSubCategories(intParent){
	var myAjax = new Ajax('code/includes/documents_sub_categories_listbox.asp?p=' + intParent + '&_r='+Math.random(), { update: 'zone_loader_area'});
	myAjax.request();
}

function loadSubCategoriesAndSelect(intParent, intSelect){
	var myAjax = new Ajax('code/includes/documents_sub_categories_listbox.asp?p=' + intParent + '&select=' + intSelect + '&_r='+Math.random(), {  update: 'zone_loader_area'});
	myAjax.request();
}
