var catalogueWindowHeight = 0;
	var currentCatalogue = '';
	var startTime = 0;
	var endTime = 0;
	var waitTime = 1000;
	var minHeight = 600;

	Number.prototype.isInt = function () {
		return !(this % 1);
	}

	function catalogueSelect(id, name, url) {
		catalogueWindowHeight = 0;
		var start = new Date();
		startTime = start.getTime();
		currentCatalogue = id;
		checkFrameHeight(id);
		hideCatalogueWindow();
		updateCatalogueWindow.delay(0.5, url);
	}

	function checkFrameHeight(id) {
		$('resizehelperframe').src = '/catalogue/checkframeheight/'+id;
	}

	function adjustFrameHeight(height) {
		catalogueWindowHeight = height + 60;
	}

	function setFrameHeight(height) {
		new Ajax.Request('/catalogue/setframeheight/'+currentCatalogue+'/'+height, {
				method: 'get',
	  			onComplete: function(transport) {
					//adjustFrameHeight(height);
	  			}
		});
	}

	function updateCatalogueWindow(url) {
		$('cataloguewindow').src = 'http://'+url;
	}

	function hideCatalogueWindow() {
		
		$('cataloguewindow').morph('height:0px;', {duration:0.5});
		$('calatoguewindowloading').appear({duration:0.5, delay:0.5});
	}

	function showCatalogueWindow() {
		var end = new Date();
		endTime = end.getTime();
		var del = 0.25;
		if ((endTime - startTime) < waitTime) {
			del = del + (waitTime - (endTime - startTime))/1000;
		}
		if (catalogueWindowHeight < minHeight) {
			catalogueWindowHeight = minHeight;
		}
		$('calatoguewindowloading').fade({duration:0.25});
		$('cataloguewindow').morph('height:'+catalogueWindowHeight+'px;',{duration:0.5, delay:del});
	}

