var help_win='';
function open_help ( help_panel, x, y ) {
	help_win=window.open(help_panel,'login_help','height='+y+',width='+x+',left=0,top=0');
}

function close_help () {
	if ( help_win != '' ) { help_win.close(); }
}

function open_panel ( panel, x, y, sb, rs ) {
	panel_win=window.open(panel, 'panel','height='+y+',width='+x+',left=0,top=0,scrollbars='+sb+',resizable='+rs);
}

function jump ( page ) {
	var w = window.open( page, 'cb' );
}
 
function open_popup (url, x, y, x0, y0, sb, rs ) {
	//window.name = target;

	panel_win=window.open(url, 'popup','width='+x+',height='+y+',left='+x0+',top='+y0+',scrollbars='+sb+',resizable='+rs);
}

function close_popup ( url ) {
     window.opener.location.replace( url );  
	 window.close();
}

function char_count ( src, dest, max_num, msg ) {  
	// alert ( src );
	// alert ( document.getElementById( src ) );
	var chr_num = document.getElementById( src ).value.length; 
	var d = document.getElementById( dest ); 
	d.innerHTML = chr_num;
	if ( chr_num == max_num + 1 ) { alert ( msg ); }
	if ( chr_num > max_num ) { d.style.color = '#cc0000'; }
	else { d.style.color = '#0000cc'; }
}

function toggle_display ( id ) {  
	// alert ( src );
	// alert ( document.getElementById( src ) );
	var arr_options = ['once','weekly','fortnightly','monthly'];
	
	for ( var i = 0; i < arr_options.length; i++ ) {
		var src = arr_options[i];
		var d = document.getElementById( src ); 
		//alert(d.name);
		if ( src == id) d.style.display = 'block';
		else d.style.display = 'none';
	}
}

function area_hilight ( id ) {
	var a = document.getElementById( id ); 
	a.style.border = '2px solid red';
}

function area_reset ( id ) {
	//alert ( id );
	var a = document.getElementById( id ); 
	if ( id == 'main' ) a.style.border = '0 solid black';
	else if ( id == 'content' ) a.style.border = '1px solid dotted';
	else a.style.border = '1px solid black';
}

function change_bgcolor ( o ) {
	// o.style.background-color = '#cde';
	//alert (o.style.color );
}

function display_event ( id, offset ) {  
	// alert ( offset );
	var d = document.getElementById( id );
	 
	d.style.right = offset + 'px';
	d.style.cursor = 'pointer';
}

function hide_event ( id ) {  
	// alert ( id );
	var d = document.getElementById( id ); 
	d.style.right = '3000px';
	d.style.cursor = 'default';
}

function display_news ( id, offset ) {  
	// alert ( offset );
	var d = document.getElementById( id, offset );
	 
	d.style.right = offset + 'px';
	d.style.cursor = 'pointer';
}

function hide_news ( id ) {  
	// alert ( id );
	var d = document.getElementById( id ); 
	d.style.right = '3000px';
	d.style.cursor = 'default';
}

// used in iMap page - Twin Coast Cycleway
function imap_popup ( id, offset_x, offset_y ) {  
	// alert ( id );
	var icon = document.getElementById( 'icon_' + id );
	var pu = document.getElementById( 'pu_' + id );
	// alert ( icon.style.left )
	//d.style.right = offset + 'px';
	icon.style.cursor = 'pointer';
	pu.style.left =  offset_x + 'px';
	pu.style.top =  offset_y + 'px';
}

function imap_popdown ( id ) {  
	// alert ( id );
	var icon = document.getElementById( 'icon_' + id );
	var pu = document.getElementById( 'pu_' + id );
	 
	//d.style.right = offset + 'px';
	icon.style.cursor = 'arrow';
	pu.style.left = '3000px';
	pu.style.top =  '0px';
}

// used in Listing_form.cfm
function update_price ( id ) {  
	var f = document.getElementById( id ); 
	var i = f.AdvTypeID.options.selectedIndex;
	var v = f.AdvTypeID.options[i].value;
	f.OngoingCost.value = v.split(':')[1].split('.')[0];
}

function expand_directory ( id, group ) {  
	// alert ( offset );
	var g = document.getElementById( 'g' + id );
	var h = document.getElementById( 'h' + id );
	var i = document.getElementById( 'i' + id );
	 
	if ( g.style.height == 'auto' ) {
		g.style.height = '0px';
		h.title = 'click to open ' + group + ' listings';
		i.src = 'graphics/arrow_closed.gif';
	} else {
		g.style.height = 'auto';
		h.title = 'click to close ' + group + ' listings';
		i.src = 'graphics/arrow_open.gif';
	}
}

function img_swap ( id, num ) {
	var i = document.getElementById( id );
	var arr1 = i.src.split('.');
	var name = arr1[arr1.length-2];
	var arr2 = name.split('_');
	arr2[arr2.length-1] = num;
	var new_name = arr2[0];
	for ( i=1; i<arr2.length; i++ ) new_name += '_' + arr2[i];
	arr1[arr1.length-2]= new_name;
	var new_src = arr1[0];
	for ( i=1; i<arr1.length; i++ ) new_src += '.' + arr1[i];
	document.getElementById( id ).src = new_src;
}

function test ( id ) { 
	alert ('hello');
}

