function showOverlay(){
	$('wrapper').style.position = 'relative';
	$('overlay').style.width = $('wrapper').getWidth() + 'px';
	$('overlay').style.height = $('wrapper').getHeight() + 'px';
	$('overlay').setOpacity(0.8);
	$('overlay').style.display = 'block';
	$('overlay').onclick = new Function('hideOverlay()');
}

function hideOverlay(){
	$('wrapper').style.position = 'static';
	$('overlay').style.display = 'none';
}

function showHowToUsePopup(page){
	if(!(page) || (page!=1 && page!=2 && page!=3 && page!=4 && page!=5 && page!=6 && page!=7 && page!=8)){
		page = 1;
	}
	var change = new Ajax.Request(
		'/remote.php', {
		method: 'get', 
		parameters: 'module=front&action=get_howto_page&page_id=' + page, 
		onSuccess: function(requestResponse){
			if(requestResponse.responseText!='error' && requestResponse.responseText!='empty'){
				showOverlay();
				$('popup_container').innerHTML = requestResponse.responseText;
				$('popup_container').style.backgroundColor = '#ffffff';
				$('popup_container').style.position = 'absolute';
				$('popup_container').style.top = '10px';
				$('popup_container').style.zIndex = 30000;
				$('popup_container').style.left = (($('wrapper').getWidth() - 780)/2) + 'px';
				$('popup_container').style.display = 'block';
				switch(page){
					case 1:
					case 2:
					case 3:
					case 4:
					case 5:
					case 6:
					case 7:
						$('popup_container').onclick = new Function("showHowToUsePopup(" + (page+1) + ");");
						$('overlay').onclick = new Function("showHowToUsePopup(" + (page+1) + ");");
						$('overlay').title = 'Spiediet, lai ietu uz nākamo lappusi';
						$('popup_container').title = 'Spiediet, lai ietu uz nākamo lappusi';
						$('howto_page_1').title = 'Spiediet, lai ietu uz nākamo lappusi';
						break;
					default:
						$('popup_container').onclick = new Function("hideHowToUsePopup();");
						$('overlay').onclick = new Function("hideHowToUsePopup();");
						$('overlay').title = 'Nospiežat, lai aizvērtu';
						$('popup_container').title = 'Nospiežat, lai aizvērtu';
						$('howto_page_1').title = 'Nospiežat, lai aizvērtu';
						break;
				}
				
			}
		}
	});	
}

function hideHowToUsePopup(){
	$('popup_container').innerHTML = '';
	$('popup_container').style.display = 'none';
	hideOverlay();
}

function hideProductPricePopup(){
	$('popup_container').innerHTML = '';
	$('popup_container').style.display = 'none';
	hideOverlay();
}