//home img 898x586

var servicesState = false;
var currentMainBtn = -1;

function main() {
	fixBugs();
	initNav();
}

function initNav() {
	$("#services-btn").mouseover(function(){
		$('#sub-links').fadeIn();
		if(servicesState == false) {
			$(document).bind('mousemove', checkServicesPos);
			servicesState = true;
			$(this).css("color", "#49b9ba");
		}
	});
	
	$("#portfolio-btn").mouseover(function(){ servicesOut(); })
	$("#blog-btn").mouseover(function(){ servicesOut(); })
}

function checkServicesPos(e) {
	var a = ($(window).width() - 960) / 2;
	if(e.pageX < (a + 567) || e.pageX > (a + 850) || e.pageY < 45 || e.pageY > 150) {
		servicesOut();
	}
}

function servicesOut() {
	if(servicesState == true) {
		$(document).unbind('mousemove', checkServicesPos);
		$('#sub-links').fadeOut();
		
		if(currentMainBtn == 2) {
			$("#services-btn").css("color", "#49b9ba");			
		}
		else{
			$("#services-btn").css("color", "black");
		}	
		
		servicesState = false;
	}
}

function fixBugs() {
	if($.browser.msie) {
		$('#sub-links').css("left", "596px");
	}
}

function initMainNav(i) {
	currentMainBtn = i;
	var currentBtn = $($("#main-navigation").children()[i]);
	$(currentBtn).addClass('main-navigation-li-over');
	$('a', currentBtn).css("color", "#49b9ba");
}

function initSubNav(i) {
	if(i != -1) { 	
		var currentBtn = $($("#sub-links-list").children()[i]);
		$('a', currentBtn).css("color", "#49b9ba");
	}
}

var links = [
				'http://styleperfectevents.com/portfolio/jennifer-daniel/',
				'http://styleperfectevents.com/portfolio/southern-garden-party/',
				'http://styleperfectevents.com/portfolio/kristen-mario/',
				'http://styleperfectevents.com/portfolio/valecia-john/',
				'http://styleperfectevents.com/portfolio/kristen-mario/',
				'http://styleperfectevents.com/portfolio/urban-city-chic/',
				'http://styleperfectevents.com/portfolio/anna-jim/',
				'http://styleperfectevents.com/portfolio/anna-jim/'
			];

var child = 7;
var id = 0;

function initGallery() {
		
	setInterval(setImage, 3500);
	
	$('#scroller').click(function(){
		window.open(links[id-1],"_self");		
		return false;
	});
}

function setImage() {
	
	
	$($('#scroller').children()[id]).animate({left:-925}, 500, function(){
		$(this).css('left', '960px');
	});
	
	if(id == 7) {
		id = 0;
	} else {
		id++;
	}
	
	$($('#scroller').children()[id]).animate({left:0}, 500);
}
