/**
 * Page				**** CUSTOM ****
 */
function usr_Page()
{
	/**
	 * Class objects
	 */
	this.obj_lib_ajax = new lib_Ajax();




	/**
	 * 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)
	{
		var act = "window.location.href = '"+path+"'";
		setTimeout(act, 250);
	}




	/**
	 * Set language path
	 *
	 * @param string language
	 */
	this.setLanguagePath = function(language)
	{
		var parameters = 'act=' + 'setLanguagePath'
					   + '&language=' + language
					   + '&path=' + 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;
			}
		}
	}




	/**
	 * Search catalog
	 */
	this.searchCatalog = function()
	{
		var parameters = 'act=' + 'search'
					   + obj_lib_formprocessor.getParameters('form_search');

		obj_usr_page.obj_lib_ajax.postAjax('/catalog.php', parameters, this.callbackAjax_searchCatalog);
	}

	this.callbackAjax_searchCatalog = function()
	{
		obj_usr_page.obj_lib_ajax.callbackAjax('div_searchcatalog', 3, 1);
		if(document.getElementById('hidden_search_newPath'))
		{
			var newPath = document.getElementById('hidden_search_newPath').value;
			if(newPath != '')
			{
				window.location.href = newPath;
			}
		}
	}




	/**
	 * Clear search form
	 */
	this.clearSearchform = function()
	{
		if(document.getElementById('form_search'))
		{
			document.getElementById('zoeken').value = '';
			document.getElementById('category').selectedIndex = 0;
			document.getElementById('merk').selectedIndex = 0;
			document.getElementById('serie').selectedIndex = 0;
			//document.getElementById('doel').selectedIndex = 0;
			document.getElementById('diameter').selectedIndex = 0;
			document.getElementById('breedte').selectedIndex = 0;
			document.getElementById('new').selectedIndex = 0;
		}
	}




	/**
	 * Submit form on pressing Enter key
	 */
	this.submitOnEnter = function(e)
	{
		var key=e.keyCode || e.which;
		if(key==13) //(13 ==  enter)
		{
			obj_usr_page.searchCatalog();
		}
	}




	/**
	 * Reload search form
	 */
	this.reloadSearchform = function()
	{
		var parameters = 'act=' + 'reloadSearchform'
					   + obj_lib_formprocessor.getParameters('form_search');

		obj_usr_page.obj_lib_ajax.postAjax('/catalog.php', parameters, this.callbackAjax_reloadSearchform);
	}

	this.callbackAjax_reloadSearchform = function()
	{
		obj_usr_page.obj_lib_ajax.callbackAjax('div_searchform', 3, 1);
		if(document.getElementById('form_search'))
		{
			Cufon.replace('h1, h2, h3, h4, h5, h6');
		}
	}
}

