/**
 * Page
 */
function usr_Page()
{
	/**
	 * Class objects
	 */
	this.obj_lib_ajax = new lib_Ajax();




	/**
	 * Search single phrase
	 */
	this.searchSinglePhrase = function()
	{
		var parameters = 'act=' + 'searchSinglePhrase'
					   + '&keyword=' + escape(document.getElementById('s').value);

		obj_usr_page.obj_lib_ajax.postAjax('/vakantiehuizen.php', parameters, obj_usr_page.callbackAjax_searchSinglePhrase);
	}

	this.callbackAjax_searchSinglePhrase = function()
	{
		obj_usr_page.obj_lib_ajax.callbackAjax('div_hidden', 3, 1);

		if(document.getElementById('hidden_newpath'))
		{
			window.location.href = document.getElementById('hidden_newpath').value;
		}
	}




	/**
	 * Submit form on pressing Enter key
	 */
	this.submitOnEnter = function(e, act)
	{
		var key=e.keyCode || e.which;
		if(key==13) //(13 ==  enter)
		{
			if(act == 'searchSinglePhrase')	{obj_usr_page.searchSinglePhrase();}
		}
	}




	/**
	 * Clear login textbox if it still contains the default text, and put back default text if still empty after losing focus
	 *
	 * @param string id
	 */
	this.setLoginTextbox = function(id)
	{
			 if(id == 'top_customer')	{var text = 'mijn emailadres';}
		else if(id == 'top_password')	{var text = 'mijn wachtwoord';}

			 if(document.getElementById(id).value == text)	{document.getElementById(id).value = '';}
		else if(document.getElementById(id).value == '')	{document.getElementById(id).value = text;}
	}




	/**
	 * Go to catalog page
	 *
	 * @param string path
	 */
	this.gotoCatalog = function(path)
	{
		window.location.href = path;
	}




	/**
	 * Set language path
	 *
	 * @param string language
	 */
	this.setLanguagePath = function(language)
	{
		var parameters = 'act=' + 'setLanguagePath'
					   + '&language=' + language
					   + '&path=' + escape(window.location.href);

		obj_usr_page.obj_lib_ajax.postAjax('/setlanguage.php', parameters, this.callbackAjax_setLanguagePath);
	}

	this.callbackAjax_setLanguagePath = function()
	{
		obj_usr_page.obj_lib_ajax.callbackAjax('div_language', 3, 1);
		if(document.getElementById('hidden_newpath'))
		{
			var newPath = document.getElementById('hidden_newpath').value;

			if(newPath != '')
			{
				window.location.href = newPath;
				//setTimeout('window.location.href = ' + newPath, 1000);
			}
			else
			{
				window.location.href = window.location.href;
				//setTimeout('window.location.href = window.location.href', 4000);
			}
		}
	}




	/**
	 * Hide provinces
	 */
	this.hideProvinces = function()
	{
		if(document.getElementById('tableRegions'))
		{
			var $ = jQuery.noConflict();

			if(document.getElementById('hidden_provinces_visible').value == 1)
			{
				document.getElementById('hidden_provinces_visible').value = 0;
				document.getElementById('span_provinces').innerHTML = '(+)';
				$('#tableRegions').slideUp('fast', function(){});
			}
			else
			{
				document.getElementById('hidden_provinces_visible').value = 1;
				document.getElementById('span_provinces').innerHTML = '(-)';
				$('#tableRegions').slideDown('fast', function(){});
			}
		}
	}




	/**
	 * Perform on done loading page
	 *
	 * @param string element
	 */
	this.onLoaded = function(element)
	{
		if(element == '' || document.getElementById(element))
		{
			//cufon_replace();
			Cufon.replace('h3', {hover: true});
		}
	}
}

