/* Ajax */
function ajaxRequest(div_id, url) { 
	div = document.getElementById(div_id)
	advAJAX.get({
		url: url,
		onSuccess : function(obj) { div.innerHTML = obj.responseText; },
		onError : function(obj) { div.innerHTML = "Sorry, try again later";	}
	});	
}

function ajaxPostRequest(div_id, form_id) { 
	div  = document.getElementById(div_id);
	form = document.getElementById(form_id);
	advAJAX.submit(form, {
		onSuccess : function(obj) { div.innerHTML = obj.responseText; },
	    onError : function(obj) { div.innerHTML = "Sorry, try again later"; }
    });
}
/* Ajax */

/* GOOGLE MAP*/
    function initialize() {	
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById('gmap'));
		map.setCenter(new GLatLng(50.82843,-0.20401), 15);
        map.clearOverlays();
		map.addControl(new GSmallMapControl());
		var marker = new GMarker(map.getCenter());
		map.addOverlay(marker);		
  }
}//map.openInfoWindow(map.getCenter(), document.createTextNode("Hello, world"));
/* GOOGLE MAP*/	


function displayPopup(url, width, height) {
	var Win = window.open(url,"displayPopup",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=yes,menubar=no');
}


function cleanField(id,fieldValue) { 
	var obj = document.getElementById(id);
	if (obj.value==fieldValue) obj.value='';
}

function restoreField(id,value) {
	var obj = document.getElementById(id);
	if (obj.value=='') obj.value=value;
}

function searchFocus() {
	var fld = document.getElementById('querytext');
	if (fld.value=='Full text search') {
		fld.value='';
	}
}


function ShowHide(id) {
	if (document.getElementById(id).style.display=='none' || document.getElementById(id).style.display=='') {
		document.getElementById(id).style.display='block';
	}
	else {
		document.getElementById(id).style.display='none';
	}
	// return(false);
}
function ShowHideAll(ids) {
	for(x=0; x < ids.length; x++) {
		ShowHide(ids[x]);
	}
}

function external(state,id) {
	obj = document.getElementById(id);
	if (state=='over') {
		obj.style.top = '-2px';
		obj.style.left = '2px';
	}
	if (state=='out') {
		obj.style.top = '0px';
		obj.style.left = '0px';
	}
}

function confirmation(link,msg) {
	conf = confirm(msg);
	if (conf == true) {
		location.href = link;
	}
}

function confirmationForm(id,msg) {
	conf = confirm(msg);
	if (conf == true) {
		$(id).submit();
	}
}




function adm_showExternal(id,showhide) {
	if (id.value=='1') {
		$_(showhide).style.display='block';
	}
	else {
		$_(showhide).style.display='none';
	}
}

function adm_showEditorOptions(id,showhide) {
	if (id.value=='editor') {
		$(showhide).style.display='block';
	}
	else {
		$(showhide).style.display='none';
	}
}

function colorRow(id,class_n) {
	$(id).className = class_n;
}

function onKeyPressSubmit(e,frmId) {
	var key = window.event ? e.keyCode : e.which;
	if (key==13) {
		$(frmId).submit();
	}
}

function clearFld(id) {
	if ($(id)) {
		$(id).value = '';
	}
}

function searchFocus(id) {
	var fld = $(id);
	if (fld.value=='search...') {
		fld.value='';
	}
}


function news_edittab() {
	$_('news_preview').style.display = 'none';
	$_('news_edit').style.display = 'block';

	$_('news_previewbutton').className = 'newsbuttonenabled';
	$_('news_editbutton').className = 'newsbuttondisabled';
}
function news_previewtab() {
	$_('news_preview').style.display = 'block';
	$_('news_edit').style.display = 'none';

	$_('news_previewbutton').className = 'newsbuttondisabled';
	$_('news_editbutton').className = 'newsbuttonenabled';
	$_('news_preview').innerHTML = "<span class='header'>" + $('news_title').value + "</span><br/>\n<i>" + formatDate(new Date(getDateFromFormat($('news_date').value,'yyyy-MM-dd HH:mm:ss')),'EE, d MMM yyyy') + "</i><br/><br/>" + tinyMCE.activeEditor.getContent();
}


function content_edittab() {
	$_('content_preview').style.display = 'none';
	$_('content_edit').style.display = 'block';

	$_('content_previewbutton').className = 'buttonenabled';
	$_('content_editbutton').className = 'buttondisabled';
}
function content_previewtab() {
	$_('content_preview').style.display = 'block';
	$_('content_edit').style.display = 'none';

	$_('content_previewbutton').className = 'buttondisabled';
	$_('content_editbutton').className = 'buttonenabled';
	$_('content_preview').innerHTML = tinyMCE.activeEditor.getContent();
}


function showHideTr(tr_id, img_id, first_status) {
		tr  = document.getElementById(tr_id);				
		img = document.getElementById(img_id);				
		if ((tr.style.display == '' && first_status == '1') || tr.style.display == 'none') {
			if (navigator.appName == 'Microsoft Internet Explorer') {
				tr.style.display = 'block';				
			} else {
				tr.style.display = 'table-row';
			}				
			img.src = 'images/arrow_awards_opened.gif';
		} else {
			tr.style.display = 'none';	
			img.src = 'images/arrow_awards_closed.gif';			
		}		
}

