//var server = 'http://127.0.0.1/bonafide/';
var server = 'http://www.thetraveleditor.com/';

function nop() {}

function parseSearch(formid) {

	if ($(formid)) {
		var v = document.search.location.value;
		
		if (v.length > 3) {
			
			if (v.substr(0,4) == 'list') {
				document.search.action = 'destinations/?' + v;
			} else {
				document.search.action = 'destinations/' + v + '/';
			}
			return;	
		}
	}
}

function getSizeOf(limit,sourceid,targetid) {

	var e;

	if (e = $(sourceid)) {
		var l = e.value.length;

		if ((limit - l) <= 1) {
			if (e = $(sourceid)) {
				e.value = e.value.substr(0,limit);
			}
		}

		var l = e.value.length;
		
		if (e = $(targetid)) {
			e.innerHTML = limit - l;
		}
	}
}

function openWindow(url,name,width,height,scrollbar,move) {
	var myWindow = window.open(url,name,"width=" + width + ", height=" + height + ",resizable=1,scrollbars=" + scrollbar + ",menubar=no");

	if (move == 1) {
		var winx = (screen.width - width) / 2;
		var winy = (screen.height - height) / 2;

		myWindow.moveTo(winx,winy);
	}
	myWindow.focus();
}

function showElement(showId,hideId) {
	if (Element.visible(showId) == 0) {
		Element.toggle(showId,hideId);
	}
}

function toggleElement(eId) {
		Element.toggle(eId);
}

function setCon(idName,activeCon,switchClass) {

	var e;
	var s;
	var c;
	
	c = 1;
	
	while (e = $(idName + '_' + c)) {
		if (activeCon == c) {
			Element.show(e);
		} else {
			Element.hide(e);
		}
		c++;
	}
	
	if (switchClass) {
		c = 1;
	
		while (e = $(idName + 's_' + c)) {
			if (activeCon == c) {
				Element.removeClassName(e,switchClass);
				Element.addClassName(e,switchClass + '_set');
			} else {
				Element.removeClassName(e,switchClass + '_set');
				Element.addClassName(e,switchClass);
			}
			c++;
		}
	}

}

function setTab(tabName,activeTab,numTabs) {
	var e;
	for (c = 1; c <= numTabs; c++) {
	
		if (e = $(tabName + '_' + c)) {
			if (activeTab == c) {
				Element.removeClassName(e,'inactive');
				Element.addClassName(e,'active');
			} else {
				Element.removeClassName(e,'active');
				Element.addClassName(e,'inactive');
			}
		}
	}

}

function changeProperty(objectId,propertyName,propertyValue){
	document.getElementById(objectId)[propertyName] = propertyValue;
}

function changeStyle(objectId,propertyName,propertyValue){
	document.getElementById(objectId).style[propertyName] = propertyValue;
}

function clearValue(id) {
	var e;
	var v;
	
	if (e = $(id)) {
		v = e.value;
		e.value = '';
		if (e = $('c_'+id)) {
			e.value = v;
		}
	}
}

function toggleElement(idname,action) {

	var c = 0;

	while (e = $(idname + '_' + c)) {
		if (action == 'show') {
			Element.show(e);
		} else {
			Element.hide(e);
		}
		c++;
	}
}

var pagemaxheight = 0;

function showPage(page) {
	
	var e; var t; var c;

	if (pagemaxheight == 0) {
	
		var height;
	
		for (c = 1; c <= 6; c++) {
			if (t = $('pagec_' + c)) {
				height = t.getHeight();
				if (height > pagemaxheight) {
					pagemaxheight = height;
				}
			}
		}
		
		for (c = 1; c <= 6; c++) {
			if (t = $('pagec_' + c)) {
				t.setStyle({'height' : pagemaxheight + 'px'});
			}
		}
	}
	
	if (e = $('page_' + page)) {
		for (c = 1; c <= 6; c++) {
			if (t = $('pagetab_' + c)) {
				if (page == c) {
					t.removeClassName('pager_unset');
					t.addClassName('pager_set');			
				} else {
					$('page_' + c).hide();
					t.removeClassName('pager_set');
					t.addClassName('pager_unset');
				}
			}
		}
		e.show();
	}
}

