function domore() {
    $('#col_right').hide();
    $('#left_close').show();
    $('.less').text('Detaylı');
    //$('#az_slider_container').width('278px');
    $('#az_slider_container').animate({'left' : '340px', 'width' : '278px'}, 'slow');
    $('.less').unbind('click').bind('click', function() {
       doless(); 
    });
}

function doless() {
	$('#left_close').hide();
    $('#az_slider_container').animate({'left' : '-=340px', 'width' : '618px'}, 'slow', function() {
        $('.less').text('Detaysız');
        $('#col_right').show();
    });
    
    $('.less').unbind('click').bind('click', function() {
       domore(); 
    });
}

function dostuff() {
	// more / less
    $('.less').bind('click', function() {
        domore(); 
    });
	
	//open facebox and display large image
	$('#enlarge').bind('click', function() {
		var image = $(this).attr('href');
		jQuery.facebox('<img src="'+image+'"/>');
		return false;
	});
	
	//click on thumbnail and load middle size image
	$('div.thumb > a, div.thumb2 > a').bind('click', function() {
		var image = $(this).attr('href');
		var enlarge = $(this).attr('rel');
		$('#image').attr('src', image);
		$('#enlarge').attr('href', enlarge);
		return false;
	});
	
	//tabs
	$('#tab_1').bind('click', function () {
		$('#tab_1_content').toggle();
		$('#tab_2_content').toggle();
		$(this).removeClass('tab_off').addClass('tab_on');
		$('#tab_2').removeClass('tab_on').addClass('tab_off');
	});
	
	$('#tab_2').bind('click', function() {
		$('#tab_1_content').toggle();
		$('#tab_2_content').toggle();
		$(this).removeClass('tab_off').addClass('tab_on');
		$('#tab_1').removeClass('tab_on').addClass('tab_off');
	});
    
    $('.close_popup').bind('click', function() {
       $('#az_slider_container').hide('slide',{ direction: 'right' });
       $('#az_slider_fxWrapper').hide('slow');
    });
    
}
$(function() {
    $('.popup_link').bind('click', function() {
		var xScroll, yScroll;
		if (self.pageYOffset) {
		  yScroll = self.pageYOffset;
		  xScroll = self.pageXOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
		  yScroll = document.documentElement.scrollTop;
		  xScroll = document.documentElement.scrollLeft;
		} else if (document.body) {// all other Explorers
		  yScroll = document.body.scrollTop;
		  xScroll = document.body.scrollLeft;	
		}
		$("#az_slider_fxWrapper").css('height','718px');
		$("#az_slider_fxWrapper").css('top',(yScroll-10)+'px');
		$("#az_slider_fxWrapper").css('display','block');

		$('#az_slider_container').css({width: "618px"});
		$("#az_slider_container").load($(this).attr('href'), '', function() {
            $(this).show('slide', {direction: 'right'});
            //$(this).show();
            dostuff();
	    });

		return false;
	});
	var width =
		document.documentElement && document.documentElement.clientWidth ||
		document.body && document.body.clientWidth ||
		document.body && document.body.parentNode && document.body.parentNode.clientWidth ||
		0;
    var height =
		document.documentElement && document.documentElement.clientHeight ||
		document.body && document.body.clientHeight ||
  		document.body && document.body.parentNode && document.body.parentNode.clientHeight ||
  		0;

	var left = window.XMLHttpRequest == null ? document.documentElement.scrollLeft : 0;
	var top = window.XMLHttpRequest == null ? document.documentElement.scrollTop : 0;
//	alert(document.getElementById("fxWrapper").offsetWidth);
//	alert(width + ' w ' + width +' & h ' + height + ' & l ' + left + '& t ' + top);
//	alert(Math.max((left + (width - $("#az_slider_fxWrapper").offsetWidth) / 2), 0));
	$("#az_slider_fxWrapper").css('left',Math.max((left + (width - document.getElementById("az_slider_fxWrapper").offsetWidth) / 2), 0) + 'px');
//	alert(height);
//	alert($("#az_slider_fxWrapper").css('left'));										

});