$(document).ready(function(){
	
	// sezon tanimi select objesinden aliniyor
	$('#JSezon').change(function() {
		var sezon = $.jqURL.get('sezon');
		var url = $.jqURL.url();
		
		 if(url.indexOf('sezon=') == -1 && (sezon != undefined && sezon != '') && url.indexOf('?') > 0  )
		 {
			window.location.href = url +'&sezon=' + $(this).val(); 
		 }
		 else
		 {
			var CurrSezonVal = $.jqURL.get('sezon');
			url = url.replace(CurrSezonVal, $(this).val());
			window.location.href = url;
			//window.location.href = $.jqURL.strip() +'?sezon=' + $(this).val();
		 }
			
	});
	
	// sezon tanimi select objesine esitleniyor
	$("#JSezon [value=\""+$.jqURL.get('sezon')+"\"]").attr("selected","selected");

	// site icindeki linklere sezon querystring'i eklenmemesi istenen objeler disarida tutuluyor
	$("a:not(.NJSezon)").each(function(){
			//alert(this.hostname);
		if (this.hostname == location.hostname){
			 var url = this.href;
			 var sezon = $.jqURL.get('sezon');
			 if(url.indexOf('sezon=') == -1 && (sezon != undefined && sezon != '')){
				if (url.indexOf('?')>0){
					$(this).attr('href', url + '&sezon='+ sezon);
				}
				else
				{
					$(this).attr('href', url + '?sezon='+ sezon);
				}
			}
		 }
		})
	
	// site icindeki linklere sezon querystring'i ekleniyor
	$("a,div,tr,td,table").each(function() {
		var onclick_temp1 = new String(this.onclick);
		if(onclick_temp1.match("window.location.href") /* && onclick_temp1.match("tbl.org.tr") */) {
			var sezon = $.jqURL.get('sezon');
			var onclick_temp = onclick_temp1.replace(/"/g, "'");
			var url = onclick_temp.match(/'(.*?)'/)[1];
			//alert(url);
			 if(url.indexOf('sezon=') == -1 && (sezon != undefined && sezon != '')){
					if (url.indexOf('?')>0){
						this.onclick = function() {
							window.location.href = url +'&sezon=' + sezon;
						}
					}
					else
					{
						this.onclick = function() {
							window.location.href = url +'?sezon=' + sezon;
						}
					}
				}
			}
	});
	
	
	// sistem tarafindan otomatik olarak eklenen tbf haberlerinin imaj path'leri duzenleniyor
	$('img').each(function(){
		temp_src = $(this).attr('src');
			if(temp_src.indexOf('http://www') >0 ){
				new_src = temp_src.substring(19);
				$(this).attr('src',new_src)
			}

		
	})


	$('img').error(function(){
		
		if(parseInt($(this).attr('width')) > 80)
			$(this).remove();
		else
		{
			$(this).attr('height', $(this).attr('width'));
			$(this).attr('src', 'http://www.tbl.org.tr/genel/imaj/spacer.gif');
		}
	});

});




