var k=0;
var c=0;
var activeLine=0;
var visibleElem=0;
var activeTab=1;
var vEVal=[0,0,0,0];
var tabs=["portfolio"];
var Links=[[],[],[]];
var visiblePhoto=1;

function linksFilling(){
	var alt="";
	for(var i=0;i<Links.length;i++){for(var z=1;z<=$("div# img").size();z++){alt=$("div# img."+z.toString()).attr("alt");Links[i].push(alt);}}
}
function arrayIndexOf(array, value) {
	for(var j = 0;j < array.length;j++) {if(array[j] == value) {return j;}}
	return null;
}
function address(){
	var a = window.document.location.href;
	var q = a.toString();
	var s = q.substr(q.indexOf("#")+1,100);
	if(q.indexOf("#")!==-1){
		var b=q.split("_");
		visibleElem=arrayIndexOf(Links[activeLine], b[1]);
		k=-700*visibleElem;
		$("div#"+tabs[activeLine]).css({marginLeft:k+"px"});
	}
}
function initArrows(){
	$("div.previous a").hide(0);
	$("div.next a").hide(0);
	$("div.product").mousemove(function(e){
		if(e.pageX<=parseInt($("body").width())/2){
			if(!($.browser.msie&&parseFloat($.browser.version)<7.0)){$("div.previous a").fadeIn(350);$("div.next a").fadeOut(350)}
			else{$("div.previous a").show(0);$("div.next a").hide(350)}
		}else{
			if(!($.browser.msie&&parseFloat($.browser.version)<7.0)){$("div.next a").fadeIn(350);$("div.previous a").fadeOut(350)}
			else{$("div.next a").show(0);$("div.previous a").hide(0)}
		}
	});
	$("div.product").hover(function(){},function(){
		if(!($.browser.msie&&parseFloat($.browser.version)<7.0)){$("div.previous a").fadeOut(300);$("div.next a").fadeOut(300);}
		else{$("div.previous a").hide(300);$("div.next a").hide(300);}
	});
}
function updateSelects(){
	if($("ul.selects li a").hasClass("active")){$("ul.selects li a").removeClass("active")}
	$("li#s_"+visibleElem.toString()+" a").addClass("active");
	var b=window.document.location.href.split("#");
	window.document.location.href=b[0]+"#"+tabs[activeLine]+"_"+Links[activeLine][visibleElem];
}
function initSelects(){
	$("ul.selects li").hide(0);
	for(var i=0;i<=($("div#"+tabs[activeLine]+" img").size()-1);i++){$("li#s_"+i.toString()).show(0);}
	updateSelects();
}
function initSelect(){
	var id="";
	for(var i=0;i<=($("div#"+tabs[activeLine]+" img").size()-1);i++){
		$("ul.selects li#s_"+i.toString()).click(function(){
			id=$(this).attr("id");
			id=parseInt(id.substr(id.indexOf("_")+1,10));
			if(id>=visibleElem){
				k=k-700*(id-visibleElem);$("div#"+tabs[activeLine]).animate({marginLeft:k},'1000');
			}else{
				k=k+700*(visibleElem-id);$("div#"+tabs[activeLine]).animate({marginLeft:k},'1000');
			}
			visibleElem = id;
			updateSelects();
		})
	}
}
function arrowRight(){
	if(visibleElem==($("div#"+tabs[activeLine]+" img").size()-1)){
		k=0;$("div#"+tabs[activeLine]).animate({marginLeft:k},'2000');visibleElem=0;
	}else{
		visibleElem=visibleElem+1;k=-700*visibleElem;$("div#"+tabs[activeLine]).animate({marginLeft:k},'1000');
	}
	updateSelects();
}
function arrowLeft(){
	if(visibleElem==0){
		k=-700*($("div#"+tabs[activeLine]+" img").size()-1);$("div#"+tabs[activeLine]).animate({marginLeft:k},'2000');visibleElem=$("div#"+tabs[activeLine]+" img").size()-1;
	}else{
		visibleElem=visibleElem-1;k=-700*visibleElem;$("div#"+tabs[activeLine]).animate({marginLeft:k},'1000');
	}
	updateSelects();
}
function initImage(){
	$("div.next a").click(function(){arrowRight();});
	$("div.previous a").click(function(){arrowLeft();});
}
function keyPress(){
	$(document).keydown(function(event){
		if(event.keyCode==37){event.preventDefault();arrowLeft();}
		if(event.keyCode==39){event.preventDefault();arrowRight();}
	})
}
function start(){$("div.images-container").removeClass("hide");}