jQuery(document).ready(function(){
	$("dd").hide();
	$("dd:first").slideToggle("slow");
	$("dt:first").toggleClass("down", "slow");
	$(".portfolio").hide();
	//$(".fader").hide();	
	$("#loading").hide();
	$("dd>img").fadeTo("fast", 0.33)
		$("dt").click(function(){
		$(this).next().slideToggle("fast");
		$(this).toggleClass("down", "fast");
	});
	$("dd>img").hover(function(){
		 $(this).fadeTo("fast", 1);
	},function(){
		$(this).fadeTo("fast", 0.33);
	});
	$("dd>img").click(function(){
		var  number = $(this).attr('title');
		$.ajax
		({
			method: 'get',
			url: 'portfolio.php',
			data: 'portfolio=' + number,
			beforeSend: function(){
				$('#loading').show("fast");
			},
			complete: function(){
				$('#loading').hide("fast");
			},
			success: function(html){
			   $('.portfolio').html(html);
			   $(".portfolio").css("top", getPageScroll()+70);
			   $(".portfolio").css("width", getPageWidth());
			   $(".portfolio").toggle("slide");
			   //$(".fader").css("height", getPageHeight());
			   //$(".fader").css("width", getPageWidth());
			   //$(".fader").fadeIn("normal");
			   $("#close").click(function(){
				$(".portfolio").toggle("slide");
				//$(".fader").fadeOut("normal");
				});
			}
		});
	});
	
});

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} 
	else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} 
	else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return yScroll;
}

function getPageWidth(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	
	return pageWidth;
}

function getPageHeight(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return pageHeight;
}



