// JavaScript Document for Caglayangayrimenkul.com.tr
/*
	Copyright All Right Reserved "NetAjans Bright Ideas"
	Includes are : 
		#General Scripts
		#Some jquery codes
*/

$(document).ready(function() {

	var WindowProfiles =
	{
		
	};
	$('a[id=search-go]').click(function(){
		$(this).parents().find('form').submit();
	});
	/*
	* Check popup links
	*/
	try {
		$("a[rel=popup]").popupwindow(WindowProfiles);
	} catch (e) {}

	//$(document).pngFix();
	$("a[rel=quick-view], *[target=quick-view]").fancybox({});

	//Cufon.replace('#header-buttons a', { hover: true, textTransform: 'uppercase', hoverables: { li: true, a: true, fontFamily: 'Corpid', fontWeight:700 } });
	//Cufon.replace('h1', { hover: true, hoverables: { li: true, a: true, fontFamily: 'Agenda' } });
	//, li.side-big-menu a.cufon

	var spt = $('span.koru-beni');
	var at = / nerden /;
	var dot = / nokta /g;
	var addr = $(spt).text().replace(at,"@").replace(dot,".");
	$(spt).after('<a href="mailto:'+addr+'" title="">'+ addr +'</a>')
	$(spt).remove();

	$("#language-bar a[id=en]").hover(function(){
		$("#language-bar a[id=tr]").animate({ 
			width: "0"
		} );
		$("#language-bar a[id=en]").animate({ 
			width: "40px"
		} );
	});
	$("#language-bar a[id=tr]").hover(function(){
		$("#language-bar a[id=en]").animate({ 
			width: "0"
		} );
		$("#language-bar a[id=tr]").animate({ 
			width: "40px"
		} );
	});

	$('.tip').tipsy({gravity: 'w',fade: true,html: true});
	// Jump to ID
	$('a[class*=jump]').click(function() {
		var is = $(this).attr('rel');
		$('html, body').animate({
			scrollTop: $('#'+is).offset().top
		}, 1000);
	});
	// Follower
	var el = $('*[rel=follow-scroll]');
	if(el.html()) {
		var elpos_original = el.offset().top;
		$(window).scroll(function(){
			var elpos = el.offset().top;
			var windowpos = $(window).scrollTop();
			var finaldestination = windowpos;
			if(windowpos<elpos_original) {
				finaldestination = elpos_original;
				el.stop().css({'top':10});
			} else {
				el.stop().animate({'top':finaldestination-elpos_original+10},500);
			}
		});
	}
});
(function($) {
	$.fn.ProductsPage = function() {
		$('a[class=expand],a[class=expand-down]',$(this)).each(function() {
			var _this = $(this);
			$(_this).parent().next('ul').find('a[class=collapse]').click(function() {
				$(this).parent('ul').slideUp();
				$(_this).removeClass('expand-down').addClass('expand');
			});
			$(_this).click(function() {
				if($(_this).attr('class') == 'expand') {
					$(_this).removeClass('expand').addClass('expand-down');
					$(_this).parent().next('ul').slideDown();
					$(_this).parent().next('ul').find('a[class=collapse]').click(function() {
						$(this).parent('ul').slideUp();
						$(_this).removeClass('expand-down').addClass('expand');
					});
				} else {
					$(_this).removeClass('expand-down').addClass('expand');
					$(_this).parent().next('ul').slideUp();
				}
			});
		});
	};
	$.fn.bookmark = function (title, url) {
		if (window.sidebar) { // Mozilla Firefox
			window.sidebar.addPanel(title, url, "");
		}
		else if (window.external) { // IE
			window.external.AddFavorite(url, title);
		}
		else if (window.opera && window.print) {
			window.external.AddFavorite(url, title);
		}
		else {
			alert('not supported');
		}
	}
	$.fn.ExternalLinks = function () {
		$("a[rel=external], a[target=_blank]").each(function() {
			if($(this).attr('rel') != 'noexternal') {
				$(this).addClass('externals');
				$(this).attr('target','_blank');
			}
		});
	}
})(jQuery);
