$(document).ready(function(){	
	feedback_form();
	horizontal_slide_effect();
	portfolio_slide_effect();
	pngfix();
});


this.feedback_form = function(){

	var obj = $('#feedback');
	var openText = "Send us your feedback";
	var closeText = "Close feedback form";
	var top = obj.css('top');
	var speed = 500;
	
	$('<span class="open">'+ openText +'</span>').appendTo(obj).toggle(
		function(){
			$(this).removeClass('open').addClass('close').text(closeText);
			obj.animate(
				{ 'top':'0px' },	
				speed
			)
		},
		function(){
			$(this).removeClass('close').addClass('open').text(openText);
			obj.animate(
				{ 'top':top },	
				speed
			)
		}
	)
	
//	var obj = $('#feedback');
//	var openText = "Send us your feedback";
//	var closeText = "Close feedback form";
//	var left = obj.css('left');
//	var speed = 500;
	
//	$('<span class="open">'+ openText +'</span>').appendTo(obj).toggle(
//		function(){
//			$(this).removeClass('open').addClass('close').text(closeText);
//			obj.animate(
//				{ 'left':'0px' },	
//				speed
//			)
//		},
//		function(){
//			$(this).removeClass('close').addClass('open').text(openText);
//			obj.animate(
//				{ 'left':left },	
//				speed
//			)
//		}
//	)

};



this.horizontal_slide_effect = function(){

	var obj = $('#horizontal_slide');
	var width = '-' + obj.css('width');
	var speed = 500;
	
	$('#horizontal_slide').mouseout(function() {
		$(this).stop().animate({left: width}, speed);
		setTimeout('1000');
	});
	
	$('#h_slidein').mouseover(function() {
		$('#horizontal_slide').stop().animate({left: 0}, speed);
	});
	
	$('#navbar').mouseover(function() {
		$('#horizontal_slide').stop().animate({left: 0}, speed);
	});
	
//	$('#horizontal_slide').hover(function() { // Hover effect
//		$(this).find("div").stop().animate({left: 0}, speed);
//		//$(this).addClass('pretty-hover');
//	}, function () {
//		$(this).find("div").stop().animate({left: -480}, speed);
//	}).each(function () { // Make whole thing a 'link'
//		$(this).css({cursor: "pointer"}).click(function () {
//			document.location.href = $(this).find("a").attr("href");
//		});
//	});
};

this.portfolio_slide_effect = function(){
	//get all link with class panel   
	$('a.panel').click(function () {   

		//reset and highlight the clicked link   
		$('a.panel').removeClass('selected');   
		$(this).addClass('selected');   
	  
		//grab the current item, to be used in resize function   
		current = $(this);   

		//scroll it to the destination   
		$('#info').scrollTo($(this).attr('href'), 800);
		
		//cancel the link default behavior   
		return false;   
	});   

	//resize all the items according to the new browser size   
	//$(window).resize(function () {   

		//call the resizePanel function   
		//resizePanel();   
	//});  
};

function resizePanel() {   
	//get the browser width and height   
	width = $(window).width();   
	height = $(window).height();   

	//get the mask width: width * total of items   
	mask_width = width * $('.item').length;   

	//set the dimension    
	$('#info, .item').css({width: width, height: height});   
	$('#mask').css({width: mask_width, height: height});
	
	//if the item is displayed incorrectly, set it to the corrent pos   
	$('#info').scrollTo($('a.selected').attr('href'), 0); 
};

/* png fix */
this.pngfix=function(){var ie55=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 5.5")!=-1);var ie6=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 6.0")!=-1);if(jQuery.browser.msie&&(ie55||ie6)){$("*").each(function(){var bgIMG=$(this).css('background-image');if(bgIMG.indexOf(".png")!=-1){var iebg=bgIMG.split('url("')[1].split('")')[0];$(this).css('background-image','none');$(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+iebg+"',sizingMethod='crop')"}})}};
