var sAdres = "anasayfa";
var iLeft = 0;
var iToplamResim;
var iCount = 1;
var iMiddleHeight;

function setTotalImage (iT){
	iToplamResim = iT;
}

function linkGonder (sLink){
	if(sLink == "iletisim" && sAdres == "anasayfa"){
		 $("#anasayfaOrta").fadeIn('normal',function(){
			$(this).animate({'top': '-'+iMiddleHeight+'px'},'normal');
		});
		sAdres="iletisim";
	}else if (sLink == "anasayfa" && sAdres == "iletisim"){
		 $("#anasayfaOrta").fadeIn('normal',function(){
			$(this).animate({'top': '0px'},'normal');
		});
		sAdres = "anasayfa";
	}
} 

function showIt (sTipID){
	$("#"+sTipID).css('visibility','visible');	
}

function hideIt (sTipID){
	$("#"+sTipID).css('visibility','hidden');	
}

function next (){
	if (iCount + 1 == iToplamResim){
		showIt('blogTip');
	}else{
		hideIt('blogTip');
	}
	
	if (iCount == iToplamResim){
		iLeft = 0;
		iCount = 1;
	}else{
		iLeft += $("#ortaBolge").width();		
		iCount++;
	}

	 $("#portfolyoOrta").fadeIn('slow',function(){
		$(this).animate({'left': '-'+iLeft+'px'},'faster');					
	});

	document.getElementById('y'+iCount).src= '../Imajlar/yuvarlakdolu.jpg';
	if (iCount == 1){
		document.getElementById('y'+iToplamResim).src= '../Imajlar/yuvarlakbos.jpg';
	}else{
		document.getElementById('y'+(iCount-1)).src= '../Imajlar/yuvarlakbos.jpg';
	}
}

function customNext (iKod){
	var iPos;
	if (iKod != iCount){
		if (iKod > iCount){
			iLeft += ($("#ortaBolge").width() * (iKod - iCount));
			$("#portfolyoOrta").fadeIn('normal',function(){
				$(this).animate({'left': '-'+iLeft+'px'},'normal');				
			});	
		}else if (iKod < iCount){
			iLeft = (iLeft) - ($("#ortaBolge").width() * (iCount - iKod));
			iPos = $("#ortaBolge").width() * (iCount - iKod);
			$("#portfolyoOrta").fadeIn('normal',function(){
				$(this).animate({'left': "+="+iPos+'px'},'normal');								
			});
		}
		document.getElementById('y'+iKod).src= '../Imajlar/yuvarlakdolu.jpg';
		document.getElementById('y'+iCount).src= '../Imajlar/yuvarlakbos.jpg';
		iCount = iKod;	
	}
	if (iCount == iToplamResim){
		showIt('blogTip');
	}else{
		hideIt('blogTip');
	}
}

function initAnasayfa (){
	var iWindowHeight = $(window).height();
	var iCalculate;
	iMiddleHeight = $("#ortaBolge").height();	
	if (iMiddleHeight < iWindowHeight){
		iCalculate = (iWindowHeight / 2) - (iMiddleHeight / 2);
		$("#WrapperAnasayfa").css('height',iMiddleHeight+'px');
		$("#WrapperOrta").css('height',iMiddleHeight+'px');
		$(".blockAnasayfa").css('height',iMiddleHeight+'px');
		$("#ortaBolge").css('margin-top',iCalculate+'px');
		$(".blockAnasayfa").css('visibility','visible');		
	}
}

function initPortfolyo (){	
	var iWindowHeight = $(window).height();
	var iMiddleWidth = $(window).width()-(($(window).width() * 2) / 100);
	var iMiddleHeight = $("#ortaBolge").height();
	var iCalculate;
	$("#WrapperPortfolyo").css('width',iMiddleWidth+'px');
	$("#WrapperPortfolyoOrta").css('width',iMiddleWidth+'px');
	$("#portfolyoOrta").css('width',(iMiddleWidth*iToplamResim)+'px');
	$(".blockPortfolyo").css('width',iMiddleWidth+'px');
	$("#ileriButon").css('left',(iMiddleWidth - 70)+'px');
	if (iMiddleHeight < iWindowHeight){
		iCalculate = (iWindowHeight / 2) - (iMiddleHeight / 2);
		$("#ortaBolge").css('margin-top',iCalculate+'px');
		$("#ileriButon").css('top',(iWindowHeight / 2) - (59 / 2)+'px');
	}	
	$("#ileriButon").css('visibility','visible');
}

function resetPortfolyo (){
	var iWindowHeight = $(window).height();
	$("#portfolyoOrta").css('left','0px');	
	$("#ileriButon").css('top',(iWindowHeight / 2) - (59 / 2)+'px');
	if (iCount > 1){
		document.getElementById('y'+iCount).src= '../Imajlar/yuvarlakbos.jpg';
		document.getElementById('y1').src= '../Imajlar/yuvarlakdolu.jpg';
	}else if (iCount == 1){
		document.getElementById('y'+iToplamResim).src= '../Imajlar/yuvarlakbos.jpg';
		document.getElementById('y1').src= '../Imajlar/yuvarlakdolu.jpg';
	}
	iCount = 1;
	iLeft = 0;
}

function changeIt (sID,sO,sPath){
	document.getElementById(sID).src= sPath + sO + '.jpg';
}

function changecss(myclass,element,value) {
	var CSSRules
	if (document.all) {
		CSSRules = 'rules'
	}
	else if (document.getElementById) {
		CSSRules = 'cssRules'
	}
	for (var i = 0; i < document.styleSheets[0][CSSRules].length; i++) {
		if (document.styleSheets[0][CSSRules][i].selectorText == myclass) {
			document.styleSheets[0][CSSRules][i].style[element] = value
		}
	}	
}


function tatilPencere (){
	var maskHeight = $(window).height();
	var maskWidth = $(window).width();
	
	//Set heigth and width to mask to fill up the whole screen
	$('#mask').css({'width':maskWidth+'px','height':maskHeight+'px'});
	
	//transition effect		
	$('#mask').fadeIn(1000);	
	$('#mask').fadeTo("slow",0.8);	

	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();
		  
	//Set the popup window to center
	$("#dialog").css('top',  winH/2-$("#dialog").height()/2);
	$("#dialog").css('left', winW/2-$("#dialog").width()/2);

	//transition effect
	$("#dialog").fadeIn(2000); 
}


