$(function() {
	var hover_on = 250;
	var hover_off = 150;
	var off = "_off.png";
	var on = "_on.gif";
	
	$('img.portfolio').hoverIntent(function() {
	//$('img.portfolio').hover(function() {
		$(this).fadeOut(hover_on);
		$(this).queue(function() {
			this.src = this.src.replace(off, on);
			$(this).fadeIn(hover_on);
			$(this).dequeue();
		});
	}, function() {
		$(this).fadeOut(hover_off);
		$(this).queue(function() {
			this.src = this.src.replace(on, off);
			$(this).fadeIn(hover_off);
			$(this).dequeue();
		});
	});
});

$(document).ready(function() {
	$('#portfolio_footer_menu li a:even').addClass('orange_text');
	$('#portfolio_footer_menu li a:odd').addClass('body_text');
});

$.preloadImages("images/portfolio/kazo_on.gif",
	"images/portfolio/studybyjanak_on.gif",
	"images/portfolio/nokia_on.gif",
	"images/portfolio/center_on.gif",
	"images/portfolio/proactiv_on.gif",

	"images/portfolio/th1.gif",
	"images/portfolio/th2.gif",
	"images/portfolio/th3.gif",
	"images/portfolio/as1.png",
	"images/portfolio/as2.png",
	"images/portfolio/br1.png",
	"images/portfolio/br2.png",
	"images/portfolio/br3.png",
	"images/portfolio/e1.png",
	"images/portfolio/e2.png",
	"images/portfolio/e3.png",
	"images/portfolio/dt1.png",
	"images/portfolio/dt2.png",
	"images/portfolio/sf1.png",
	"images/portfolio/sf2.png",
	"images/portfolio/sf3.png",
	"images/portfolio/sf4.png"
	);

var currentImage;
function showModal(id) 
{
	resetPortfolio();
	$('#portfolio_img').hide();
	$('#portfolio_text').hide();
	$('#portfolio_img').fadeIn(300);
	$('#portfolio_text').fadeIn(300);
	switch( id )
	{
		case 'jqmTH':
			$('#kazo_footer_link').css('font-style', 'italic');
			currentImage = 'images/portfolio/th1.gif';
			$('#th_text').show();
			$('#see_more').html('See more KAZO >>');
			break;
		case 'jqmAS':
			$('#studybyjanak_footer_link').css('font-style', 'italic');
			currentImage = 'images/portfolio/as1.png';
			$('#as_text').show();
			$('#see_more').html('See more Study By Janak >>');
			break;
		case 'jqmBR':
			$('#nokia_footer_link').css('font-style', 'italic');
			currentImage = 'images/portfolio/br1.png';
			$('#br_text').show();
			$('#see_more').html('See more Nokia >>');
			break;
		case 'jqmE':
			$('#proactiv_footer_link').css('font-style', 'italic');
			currentImage = 'images/portfolio/e1.png';
			$('#e_text').show();
			$('#see_more').html('See more Proactiv >>');
			break;
		case 'jqmDT':
			$('#heromoters_footer_link').css('font-style', 'italic');
			currentImage = 'images/portfolio/dt1.png';
			$('#dt_text').show();
			$('#see_more').html('See more Hero Motors >>');
			break;
		case 'jqmSF':
			$('#savio_footer_link').css('font-style', 'italic');
			currentImage = 'images/portfolio/sf1.png';
			$('#sf_text').show();
			$('#see_more').html('See more Proactiv >>');
			break;
	}
	$('#ad_img').attr('src', currentImage);	
	$('#dialog').fadeIn(400);
}

function resetPortfolio()
{
	$('#th_text').hide();
	$('#as_text').hide();
	$('#sf_text').hide();
	$('#br_text').hide();
	$('#dt_text').hide();
	$('#e_text').hide();
	
	$('#kazo_footer_link').css('font-style', 'normal');
	$('#nokia_footer_link').css('font-style', 'normal');
	$('#studybyjanak_footer_link').css('font-style', 'normal');
	$('#proactiv_link').css('font-style', 'normal');
	$('#heromotors_footer_link').css('font-style', 'normal');
	$('#savio_foundation_footer_link').css('font-style', 'normal');
}

var onJqShow = function(hash)
{
	showModal(hash.t.id);
}

var onJqHide = function(hash)
{
	resetPortfolio();
    $('#dialog').fadeOut(400);//.hide();
	hash.o.fadeOut(400);//remove();
}


$().ready(function() {
	$('#dialog').jqm({modal: false, onShow: onJqShow, onHide: onJqHide});
});

function swapImage()
{	
	$('#ad_img').fadeOut(200);
	$('#ad_img').queue(
		function() {
			switch (currentImage)
			{
				case 'images/portfolio/th1.gif':
					currentImage = 'images/portfolio/th2.gif';
					break;
				case 'images/portfolio/th2.gif':
					currentImage = 'images/portfolio/th3.gif';
					break;
				case 'images/portfolio/th3.gif':
					currentImage = 'images/portfolio/th1.gif';
					break;
				case 'images/portfolio/as1.png':
					currentImage = 'images/portfolio/as1.png';

				case 'images/portfolio/sf1.png':
					currentImage = 'images/portfolio/sf1.png';
					break;

				case 'images/portfolio/br1.png':
					currentImage = 'images/portfolio/br1.png';
					break;

				case 'images/portfolio/dt1.png':
					currentImage = 'images/portfolio/dt2.png';
					break;
				case 'images/portfolio/dt2.png':
					currentImage = 'images/portfolio/dt1.png';
					break;
				case 'images/portfolio/e1.png':
					currentImage = 'images/portfolio/e1.png';
					break;

			}
			$('#ad_img').attr('src', currentImage);
			$('#ad_img').fadeIn(200);
			$('#ad_img').dequeue();
		}
	);
}




