var HomeBlogCategories_Arr = ["#HomeBlogCol_Marketing", "#HomeBlogCol_Design", "#HomeBlogCol_Technology"];
var HomeBlogCat_LinkArr = ["#HomeMarketingLink", "#HomeDesignLink", "#HomeTechLink"];
var currHomeBlogCategory = 0;
var currHomeBlog_Count = 0;
var times = 0;

$(document).ready(function() {
	var AirBus = $('#AirBus');
	AirBus.bind('click', function(){
		AirBus.animate({left:1300, top:230}, {duration:4000});
	});
	
	$(document).everyTime(8000, function (){
		if(currHomeBlog_Count < 2){
			currHomeBlog_Count = currHomeBlog_Count + 1;
		}
		else{
			currHomeBlog_Count = 0;
		}
		changeHomeBlogCategory(HomeBlogCategories_Arr[currHomeBlog_Count]);
	}, 0);
	
	$("#HomeBlogCol_Marketing").mouseover(function(event) {
		$(document).stopTime();
	});
	$("#HomeBlogCol_Marketing").mouseout(function(event) {
		$(document).everyTime(8000, function(i){
			if(currHomeBlog_Count < 2){
				currHomeBlog_Count = currHomeBlog_Count + 1;
			}
			else{
				currHomeBlog_Count = 0;
			}
			changeHomeBlogCategory(HomeBlogCategories_Arr[currHomeBlog_Count]);								 
		});
	});

	$("#HomeBlogCol_Design").mouseover(function(event) {
		$(document).stopTime();
	});
	$("#HomeBlogCol_Design").mouseout(function(event) {
		$(document).everyTime(8000, function(i){
			if(currHomeBlog_Count < 2){
				currHomeBlog_Count = currHomeBlog_Count + 1;
			}
			else{
				currHomeBlog_Count = 0;
			}
			changeHomeBlogCategory(HomeBlogCategories_Arr[currHomeBlog_Count]);
		});
	});

	$("#HomeBlogCol_Technology").mouseover(function(event) {
		$(document).stopTime();
	});
	$("#HomeBlogCol_Technology").mouseout(function(event) {
		$(document).everyTime(8000, function(i){
			if(currHomeBlog_Count < 2){
				currHomeBlog_Count = currHomeBlog_Count + 1;
			}
			else{
				currHomeBlog_Count = 0;
			}
			changeHomeBlogCategory(HomeBlogCategories_Arr[currHomeBlog_Count]);
		});
	});
	
	changeContent(1);
	
});


function changeHomeBlogCategory(ID1){
	$(HomeBlogCat_LinkArr[currHomeBlogCategory]).removeClass("Selected");
	$(HomeBlogCategories_Arr[currHomeBlogCategory]).fadeOut("normal", function(){$(ID1).fadeIn("normal");});
	for(var i=0; i < HomeBlogCategories_Arr.length; i++){
		if(ID1 == HomeBlogCategories_Arr[i]){
			currHomeBlogCategory = i;
			currHomeBlog_Count = i;
			$(HomeBlogCat_LinkArr[currHomeBlogCategory]).addClass("Selected");
		}
	}
}

function changeHomeBlogCategory_OnClick(ID1){
	//_globalTimer.stop();
	$(HomeBlogCat_LinkArr[currHomeBlogCategory]).removeClass("Selected");
	if(HomeBlogCategories_Arr[currHomeBlogCategory] != ID1){
		$(HomeBlogCategories_Arr[currHomeBlogCategory]).fadeOut("normal", function(){$(ID1).fadeIn("normal");});
		for(var i=0; i < HomeBlogCategories_Arr.length; i++){
			if(ID1 == HomeBlogCategories_Arr[i]){
				currHomeBlogCategory = i;
				currHomeBlog_Count = i;
				$(HomeBlogCat_LinkArr[currHomeBlogCategory]).addClass("Selected");
			}
		}
	}
	/*$('#DebuggOutput_Content').html($('#DebuggOutput_Content').html() + '<br />' + 'Current Blog Cat: ' + currHomeBlogCategory);*/
	//_globalTimer.reset(10000);
}


function HomePort_Next(ID1){
	if(currentImageIndex < (OurWorkIMG.length - 1)){
		currHomePortIMGMask_XPos = currHomePortIMGMask_XPos + -238;
		$(ID1).animate({left:currHomePortIMGMask_XPos});
		
		currentImageIndex++;
		/*if(currentImageIndex == 3){
			disableRightArrow();
		}*/
		changeContent(currentImageIndex);
		if(currentImageIndex !== 0){
			$('#HomePortLeftArrow').removeClass('Limit');
		}
		if(currentImageIndex == (OurWorkIMG.length - 1)){
			$('#HomePortRightArrow').addClass('Limit');
		}
	}
}

function HomePort_Prev(ID1){
	if(currentImageIndex > 0){
		currHomePortIMGMask_XPos = currHomePortIMGMask_XPos + 238;
		$(ID1).animate({left:currHomePortIMGMask_XPos});
		
		currentImageIndex--;
		/*if(currentImageIndex < 3){
			enableRightArrow();
		}
		if(currentImageIndex == 0){
			disableLeftArrow();
		}*/
		changeContent(currentImageIndex);
		if(currentImageIndex == 0){
			$('#HomePortLeftArrow').addClass('Limit');
		}
		if(currentImageIndex !== (OurWorkIMG.length - 1)){
			$('#HomePortRightArrow').removeClass('Limit');
		}
	}else{
			
	}
}

function changeContent(currentImageIndex){
	if(currentImageIndex < OurWorkIMG.length){
		if(currentImageIndex >= 0){
			$('#HomePortTitle').html('<a href="/Portfolio/Project/'+ OurWorkProjectID[currentImageIndex] +'">' + OurWorkTitle[currentImageIndex] + '</a>');
			$('#Description').html(OurWorkBrief[currentImageIndex] + OurWorkText[currentImageIndex]);
			$('#HomePortCenterBorder').unbind('click');
			$('#HomePortCenterBorder').click(function() {
				location.href = '/Portfolio/Project/' + OurWorkProjectID[currentImageIndex];								
			});
		}
	}
}


function disableArrow(id){
	//PNGswap(id, true);
}
function enableArrow(id){
	//PNGswap(id, false);
}
function disableRightArrow(){
	disableArrow("HomePortArrowRight");
}
function enableRightArrow(){
	enableArrow("HomePortArrowRight");
}
function disableLeftArrow(){
	disableArrow("HomePortArrowLeft");
}
function enableLeftArrow(){
	enableArrow("HomePortArrowLeft");
}