//This file contains a load of scripts which used to just live in the <head> of each template.
//They are unsorted and uncommented...
//

function toggle(t,d){
	tt=document.getElementById(t);
	if(d==1){
		tt.style.display='none';
	} else {
		if(tt.style.display=='none'){
			tt.style.display='inline';
		}else{
			tt.style.display='none';
		}
	}
};

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=325,height=545,left = 440,top = 237');");
}


function openTree(l, p, link, sub_links, current_id, load_my_children) {

	if (document.getElementById('menu_preloaded_children_' + p).innerHTML == '') {
		if ((document.getElementById('menu_children_' + p).innerHTML != '') && (document.getElementById('menu_children_' + p).style.display == "inline")) {
			document.getElementById('menu_children_' + p).style.display = "none";

		} else {
			if (document.getElementById('menu_children_' + p).style.display == "none") {
				document.getElementById('menu_children_' + p).style.display = "inline";
			} else {
				document.getElementById('menu_children_' + p).style.display = "inline";
				pstr = '/inc/menusets/menusettree_rpc.php?l=' + l + '&p=' + p + '&link=' + link + '&sub_links=' + sub_links + '&current_id=' + current_id + '&load_my_children=' + load_my_children;
				makePOSTRequest(pstr, "post=true");
			}
		}
	} else {

		if (document.getElementById('menu_preloaded_children_' + p).style.display == "inline") {
			document.getElementById('menu_preloaded_children_' + p).style.display = "none";
		} else {
			document.getElementById('menu_preloaded_children_' + p).style.display = "inline";
		}

	}

}


	function loadFavRetailers() {
		
		favRetailersLoading();

		pstr = '/inc/modules/my_favourites/rpc.php?action=load';
		makePOSTRequest(pstr, "post=true");

	}

	function toggleFavRetailer(cid) {
		pstr = '/inc/modules/my_favourites/rpc.php?action=toggle&cid=' + cid;
		makePOSTRequest(pstr, "post=true");
	}

	function favRetailersLoading() {
		document.getElementById('my_favourites_list').innerHTML = '<table style="height: 130px; width: 100%;"><tr><td align="center">Please Wait, Loading Your Favourites<br><img src="/images/loading_bar.gif" alt="Loading..."></td></tr></table>';
	}

	function clear_textbox(id) {
		if (document.getElementById('bg_' + id + '_fade').value == 0) {
			document.getElementById(id).style.backgroundImage = 'url(/images/bg_' + id + '_fade.gif)';
			document.getElementById('bg_' + id + '_fade').value = 1;
		} else {
			if (document.getElementById(id).value == "" && document.getElementById('bg_' + id + '_fade').value == 1){
				document.getElementById(id).style.backgroundImage = 'url(/images/bg_' + id + '_fade_in.gif)';
				document.getElementById('bg_' + id + '_fade').value = 0;
			}
		}
	}
