var ss = 0;
var ti = 4000;
var oldid = '';
var oldmid = '';
var mindex = new Array(); 
var mindex_sec = new Array(); 
var mindex_id = new Array(); 
var mindex_tx = new Array(); 
var curindex = 0;
var maxc = 0;


function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}


function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}


function goster(imageid, imagefile,sec,mid) {

	var speed = Math.round(600 / 100);
	var timer = 0;

	epic = new Image();
	var pic = document.getElementById(imageid);	


	for (i=1;i<=maxc;i++) {
		if (mindex_id[i] == mid ) { 
		 curindex = i;    break; }
	}


	epic.onload = function(){


				
		changeOpac(0, imageid);

		var height = epic.height;
		var width = epic.width;

		pic.onload = function(){
			pic.height = epic.height;
			pic.width = epic.width;
			var dw = width - 550;
			var dh = height - 453;
			var orn = 0;

			if ( dw > 0 || dh > 0 ) 
				{
					if (dw > dh) {
						orn = Math.round((550 / width ) * height);
						pic.width	= 550 ;
						pic.height	= orn ;			
					}
					else {
						orn = Math.round((453 / height ) * width) ;
						pic.width	= orn ;
						pic.height	= 453 ;
					    }
			}
				for(i = 0; i <= 100; i++) {
					setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
					timer++;
				}
		} ;
		// pic.className = "cizgi"
		pic.src = epic.src;

		if (oldid > '' ) {
			document.getElementById('u_' + oldid).style.display = 'none';
			document.getElementById(oldid).className = "photoTourPrimaryNav";
		}
		document.getElementById('u_' + sec).style.display = 'block';
		document.getElementById(sec).className = "photoTourPrimaryNavOn";
		oldid = sec;

		if (oldmid > '' ) {
			document.getElementById(oldmid).className = "photoTourSecondaryNav";
		}
		document.getElementById(mid).className = "photoTourSecondaryNavOn";
		oldmid = mid;

	}

	epic.src = imagefile;
	if ( mindex_tx[curindex] > '' ) {
	document.getElementById('baslik').value = mindex_tx[curindex];
	}
}




function showdiv(id) {
 ss = 0;
	if (oldid > '' ) {
		document.getElementById('u_' + oldid).style.display = 'none';
		document.getElementById(oldid).className = "photoTourPrimaryNav";
	}
	document.getElementById(id).className = "photoTourPrimaryNavOn";
	document.getElementById('u_' + id).style.display = 'block';
	document.getElementById(id).className = "photoTourPrimaryNavOn";

	oldid = id;
}



function nshow(sbl,sec,sid) {
   ss = 0;
   goster('blendimage',sbl,sec,sid);
}

function sshow() {
   ss = 1;
   setTimeout("navi(2)",ti);
}

function navi(tp) {
      if ( tp == 2 ) {
	      curindex++;
	      if (curindex > maxc ) { 
			curindex = 1 ;  
		}
	}
      else
	{
	     curindex--;
	      if (curindex < 1 ) { 
		curindex = maxc ;  
		}
	}

      var sbl =  mindex[curindex];
      var sec =  mindex_sec[curindex];
      var sid =  mindex_id[curindex];
      goster('blendimage',sbl,sec,sid);
      if (ss == 1 ) { setTimeout("navi(2)",ti); }
}







function anashow() {
   curindex = 1;
   ss = 1;
   setTimeout("ananav(2)",ti);
}

function ananav(tp) {
      curindex++;
      if (curindex > maxc ) { curindex = 1 ;  }
      var sbl =  mindex[curindex];
      ngoster('blendimage',sbl);
      if (ss == 1 ) { setTimeout("ananav(2)",ti); }
}

function ngoster(imageid, imagefile) {

	var speed = Math.round(600 / 100);
	var timer = 0;

	epic = new Image();
	var pic = document.getElementById(imageid);	

	changeOpac(0, imageid);
	pic.src = imagefile;

	for(i = 0; i <= 100; i++) {
				setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
				timer++;
			}

}