/***********************************************************/
/* Site wide parameter                                     */
/***********************************************************/
// need to set this manually in order to show the calendar buttons
var PF_WEB_ROOT = '/images/layout/'; // Used by calendarDateInput.js 


/* Check textare string size
** obj: form field to check
** obj_counter: form field to display counter
** max_len: max length of the text
*/
function intro_counter(obj, obj_counter, max_len) {
	var max_len = typeof(max_len) != 'undefined' ? max_len : 400;
	var text_len = obj.value.length;
	var text_len_left = max_len - text_len;
	var text_var = obj.value;
	obj_counter.value = text_len_left;
	/* Change counter text style */
	if(text_len_left <= 10) {
		obj_counter.style.color = '#FF0000';
		obj_counter.style.fontSize = '14px';
	} else {
		obj_counter.style.color = '#002771';
		obj_counter.style.fontSize = '12px';
	}
	if(text_len >= max_len) {
		obj.value = text_var.substring(0, max_len);
		obj_counter.value = 0;
	}
}

function decision(message, url){
if(confirm(message)) document.location.href = url;
}

function print_ok(){
	if(confirm('Is printing correctly?')) {
		alert('Thank You!');
	} else {
		alert('Please try again!');
	}
	window.close();
}

function delete_promotion() {
	if(confirm('Are you sure you want to delete this promotion forever?')) {
		return true;
	} else {
		return false;
	}
}


function open_promotion(url) {
	popup_win = window.open(url, 'promotion_window', 'status=no,toolbar=no,location=no,resizable=no,scrollbars=1,width=660,height=480');
	if (window.focus) {popup_win.focus()}	
}
/*
function goto(gotourl) {
		document.location = gotourl;
}
*/
function showObj(obj) {
	document.getElementById(obj).style.display='';
}

function hideObj(obj) {
	document.getElementById(obj).style.display='none';
}

function showLoc(obj, img_plus, img_minus) {
	var collapsetext = document.getElementById('collapsetext_' + obj);
	var collapseicon = document.getElementById('collapseicon_' + obj);
	//var divbrief 	 = document.getElementById('brief_' + obj);
	var divdetail 	 = document.getElementById('detail_' + obj);
	if(collapsetext.innerHTML == 'Expand') {
		collapsetext.innerHTML = 'Collapse';
		collapseicon.innerHTML = '<img src="' + img_minus + '" border="0">';
		//divbrief.style.display = 'none';
		divdetail.style.display = '';		
	} else {
		collapsetext.innerHTML = 'Expand';
		collapseicon.innerHTML = '<img src="' + img_plus + '" border="0">';
		//divbrief.style.display = '';
		divdetail.style.display = 'none';
	}	
}

function showChildDiv(obj, img_plus, img_minus) {
	var collapsetext = document.getElementById('collapsetext_' + obj);
	var collapseicon = document.getElementById('collapseicon_' + obj);
	var divdetail 	 = document.getElementById('child_' + obj);
	if(collapsetext.innerHTML == 'Expand') {
		collapsetext.innerHTML = 'Collapse';
		collapseicon.innerHTML = '<img src="' + img_minus + '" border="0">';
		divdetail.style.display = '';		
	} else {
		collapsetext.innerHTML = 'Expand';
		collapseicon.innerHTML = '<img src="' + img_plus + '" border="0">';
		divdetail.style.display = 'none';
	}	
}


function checkSearch(){
	if (document.topnav_search.search_keyphrase.value.length <= 3) {
		alert('Search text is empty or less than 4 characters!');
		document.topnav_search.search_keyphrase.select();
		document.topnav_search.search_keyphrase.focus();
		return false;
	}
	else {
		return true;
	}
}

