// $Revision: 1.6 $

/************************************************************************/
/* phpAdsNew 2                                                          */
/* ===========                                                          */
/*                                                                      */
/* Copyright (c) 2000-2003 by the phpAdsNew developers                  */
/* http://sourceforge.net/projects/phpadsnew                            */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

// Settings
var helpDefault = '';

var helpSpeed = 600;
var helpHeight = 150;
var helpWidth = 612;
var helpOnScreen = false;

function initHelp() {
	$('#helpLayer').width(helpWidth);
	$('#helpLayer').height(helpHeight);
	
	$('#helpLayer').css('top', $(window).height() + $(document).scrollTop() + 1);
	$('#helpLayer').css('left', ($(window).width() / 2) - (helpWidth / 2) );
	
	$(window).scroll(function() {
		positionHelp();
	});
	
	$(window).resize(function() {
		positionHelp();
	});
}

function positionHelp() {
	if (helpOnScreen) {
		$('#helpLayer').css('top', $(window).height() + $(document).scrollTop() - helpHeight);
		$('#helpLayer').css('left', ($(window).width() / 2) - (helpWidth / 2) );
	}
}

/*********************************************************/
/* Set the help text                                     */
/*********************************************************/

function setHelp(item) {
	//var helpContents = findObj("helpContents");
	if (item != null && helpArray[item] != null) {
		bla = unescape(helpArray[item]);
		var re = new RegExp ('<p>', 'gi') ;
		var newbla = bla.replace(re, '<br>') ;
		$("#helpContents").html(newbla+'<br>');
		//helpContents.innerHTML = newbla+'<br>'; //unescape(helpArray[item]);
		
	} else {
		//helpContents.innerHTML = helpDefault;
		$("#helpContents").html(helpDefault);
	}
}



/*********************************************************/
/* Toggle the help popup                                 */
/*********************************************************/

function toggleHelp() {
	if (helpOnScreen == false) {
		showHelp();
	} else {
		hideHelp();
	}
}



/*********************************************************/
/* Display the help popup                                */
/*********************************************************/

function showHelp() {
	$("#helpLayer").show();
	
	$("#helpLayer").animate({
		top: $(window).height() + $(document).scrollTop() - helpHeight
	}, helpSpeed, function() {
		helpOnScreen = true;		
	});
	//helpDefault = $('#helpContents').html() + '<br>';
}

/*********************************************************/
/* Hide the help popup                                   */
/*********************************************************/

function hideHelp() {
	$("#helpLayer").animate({
		top: $(window).height() + $(document).scrollTop() + 1
	}, helpSpeed, function() {
		$("#helpLayer").hide();
		helpOnScreen = false;
	});
}
