$(document).ready(function() {
	//city select
	$('#city1').selectbox({className:selectclass}).bind('change', function(){ yer_getir(1); set_select('city2', $(this).val());yer_getir(2);});
	$('#local1').selectbox({className:selectclass}).bind('change', function(){});
	$('#city2').selectbox({className:selectclass}).bind('change', function(){ yer_getir(2);});
	$('#local2').selectbox({className:selectclass}).bind('change', function(){});
	$('#pricetype').selectbox({className:selectclass}).bind('change', function(){});
	$('#distance1').selectbox({className:selectclass,listboxMaxSize: 7}).bind('change', function(){});
	$('#distance2').selectbox({className:selectclass,listboxMaxSize: 7}).bind('change', function(){});
	$('#country').selectbox({className:selectclass,listboxMaxSize: 7}).bind('change', function(){});
	
	$('#return').selectbox().bind('change', function(){ 
		if($(this).val()=="2"){$('#returndiv').show();}
		if($(this).val()=="1"){$('#returndiv').hide();}
	});

	
	$(document).bind('click', function(e) {
	  var trgt = e.target;
	  var currentListElements = jQuery('#lang_button').parent().parent().find('*').andSelf();
	  if(jQuery.inArray(trgt, currentListElements)<0 ) {$('#lang_cont').slideUp(); }	  
	});

	//exchange
	$.getJSON(root+'php/infos.php?infos=exchange', {},
	function(jsonObj){
		$("#dollar").html(jsonObj[0]);
		$("#euro").html(jsonObj[2]);
	});	
	//weather
	$.getJSON(root+'php/infos.php?infos=weathers&weather=TUXX0015', {},
	function(jsonObj){
		$(".weimg").attr("src",root+"php/weather/icons/"+jsonObj[0].image+".png");
		$(".wecity").html(jsonObj[0].place);
		$(".wedegre").html(jsonObj[0].degree);
		$(".wedegree").html(jsonObj[1].high);
		$('.weimg').ifixpng();
		$('.weimg2').ifixpng();
	});
	
	
	
	
	$('#search1').css("visibility","visible");
	news_slider();
	slideShow();
	
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		$("#year1").prev().css("font-size","0.8em");
		$("#year2").prev().css("font-size","0.8em");

		//pngfix
		$('#esinti').ifixpng();
		$('#carpriceb').ifixpng();
		$('.ui-datepicker-trigger').ifixpng();
		$('.slide').next().find("img").ifixpng();
		
		$('.slide').ifixpng();
		$('a.hover').ifixpng();
		$('.millf').ifixpng();
	}
	
	$('.foomenu a:last-child').find('span:last-child').text('');
	
	$('.sdw_obj').each(function(){
		$(this).css("position","relative").clone().css({"position":"absolute","left":"1px","top":"1px","color":"#d9c902"
		}).prependTo($(this).parent().css("position",$(this).parent().css("position")=="absolute"?"absolute":"relative"));
	});

});

//News - developer: misima
news_current = 0;
news_heads	 = ".news_heads .div"
function news_slider() {
	$(news_heads).css({"display": "block"});
	$(news_heads).css({opacity: 0});
	$(news_heads+':first').css({opacity: 1});
	newssetint = setInterval('news_next()',8000);
}
function news_next() {
	news_old=news_current;news_current=news_current+1;news_current==$(news_heads).length?news_current=0:"";
	$(news_heads).eq(news_old).animate({opacity: 0.0}, 1000).removeClass('show');
	$(news_heads).eq(news_current).css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
}

//Slide - developer: misima
gallery_current = 1;
gallery_old=0;
gallery_items = '.slides';
gallery_links = '.snums a';

function slideShow() {
	$(gallery_items).fadeOut();
	$(gallery_items+':first').fadeIn();
	$(gallery_links+':first').addClass('active');
	gallerysetint = setInterval('gallery_next()',6000);
	
}
function gallery_next() {
	
	gallery_capt = $(gallery_items).eq(gallery_current).find('img').attr('rel');	
	$(gallery_links).eq(gallery_old).removeClass('active');
	$(gallery_links).eq(gallery_current).addClass('active');
	$(gallery_items).eq(gallery_old).fadeOut();
	$(gallery_items).eq(gallery_current).fadeIn();
	gallery_old=gallery_current;
	gallery_current=gallery_current+1;
	gallery_current==$(gallery_items).length?gallery_current=0:"";
}
function gallery_nexter(a){
	if(a>$(gallery_items).length){}else{
	  clearInterval(gallerysetint);
	  gallery_current = (a-1);
	  gallery_next();
	}
};


//modalbox
var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
function modalBox(content, width, height, close) {
	if(close){
		$(content).append($('#ntz_modal div:first'));
		$('#ntz_modal').remove();
		$('#ntz_overlay').fadeOut(function(){$(this).remove();});
		try{if(IE6){$('body').find('select.unhideThis').removeClass('unhideThis').visibility('visible');}}catch(err){};
		$('embed.unhideThis, object.unhideThis').removeClass('unhideThis').css('visibility', 'visible');
		return false;
	}
	try{if(IE6){$('body').find('select:visible').addClass('unhideThis').visibility('hidden');}}catch(err){};
	$('embed:visible, object:visible').addClass('unhideThis').css('visibility', 'hidden');
	$('body').append('<div id="ntz_overlay"></div>');
	$('#ntz_overlay').click(function(){modalBox(content, '', '', true)});
	$('#ntz_overlay').css({
		width		:	'100%',
		height		:	$(document).height(),
		position	:	'absolute',
		left		:	0,
		top		:	0,
		backgroundColor	:	'#000',
		zIndex		:	100,
		opacity		:	0
	}).fadeTo(200, 0.5);
	$('body').append('<div id="ntz_modal"></div>');
	$('#ntz_modal').css({
		//border		:	'1px solid #2d7abb',
		width		:	width ? width : 350,
		height		:	height ? height : 350,
		//backgroundColor	:	'#FFFFFF',
		position	:	'absolute',
		left		:	'50%',
		top		:	$(document).scrollTop(),
		zIndex		:	101,
		marginLeft	:	-(Math.ceil((width ? width : 800)/2))+130,
		marginTop	:	Math.ceil(($(window).height()-height)/2)+100
	}).append($(content+' div:first')).show("drop",{direction:'up'},500);//.draggable();
	//$('#ntz_modal a:eq(0), #ntz_modal input, #ntz_modal textarea').focus();
	try{
		callback.call();
	}catch(err){};	
	$(document).bind('scroll', function(){
		$('#ntz_modal').css({
			top:$(document).scrollTop()
		});
	});
};











$(document).ready(function(){
		
			var pf_loading = 0;
			imgh='#pf_imgh';
			navh='#pnav';
			
			$(navh+" a").live('click',function(){
				var my_id = $(this).attr("id");
				var my_link = $(this);
				var sel_id = my_id.replace("i","");
				var step = 180;
				var action_step = 0;
				if (pf_loading==0){
					pf_loading = 1;
					if ($('#pnav').width()>=190){
						var slides = $('#pnavh a').size();
						var lslides = -$('#pnavh').position().left/19;
						var rslides = slides-10+($('#pnavh').position().left/19);
						var sstep = 0;
						if (sel_id==(lslides+10)){ // next
							if (rslides<9){
								sstep = 19*rslides;}
							else{
								sstep = 19*9;}
							$('#pnavh').animate({left:'-='+sstep},300);
						}
						if (lslides>0 && sel_id==(lslides+1)){ // previous
							if (lslides<9){
								sstep = 19*lslides;}
							else{
								sstep = 19*9;}
							$('#pnavh').animate({left:'+='+sstep},300);			
						}
					}
					action_step = step*(sel_id-1);
					h_step = 19 * (sel_id-1);
					if (h_step+"px"!=$('#pf_hh').css("top")){
						$('#pf_hh').fadeOut(function(){
							$('#pf_hh').css("top","-"+h_step+"px");
							$('#pf_hh').fadeIn();
						});
					}
					
					$(navh+" a").filter(".sel").removeClass("sel");
					my_link.addClass("sel");
					$(imgh).fadeOut(function(){
						$(imgh).css("top",'-'+action_step+"px");
						$(imgh).fadeIn();
						pf_loading = 0;
						
							var slides = $(navh+'h a').size();
							var lslides = -$(navh+'h').position().left/19;
							var rslides = slides-10+($(navh+'h').position().left/19);
							$(navh+"h a").removeClass("plus");
							$(navh+"h a").removeClass("minus");
							if (rslides>0){
								var ps = lslides+10;
								$(navh+"h a#i"+ps).addClass("plus");	
							}
							if (lslides>0){
								var ms = lslides+1;
								$(navh+"h a#i"+ms).addClass("minus");	
							}
					});
					
				}
				
				return false;
			});	
		});
