// JavaScript Document

function ajx(sPage,action,id,types,veri)
{	
	//sPage='http://www.yorsan.com.tr/'+sPage;
	//alert('Page : '+sPage+' / action: '+action+' / id: '+id+' / type: '+types+' / veri: '+veri);
	var method='POST';
	var myRandom=parseInt(Math.random()*99999999);
	load_on();
	$.ajax({
	url: sPage,
	type: method,
	dataType: 'html',
	data: "action="+action+"&rand="+myRandom+"&"+veri,
	timeOut:10000,
	error: function(request,error){
		load_off();
		if (error == 'timeout'){
			alert(' Hata : Zaman Asimi');
		}else if (error=='notmodified'){
			alert('Sayfa Bulunamadi');
		}else{
			alert('Bir Hata Olustu Lütfen Yöneticiyi Uyariniz');
		}
		
	},
	success: function(html){
		if (types=='hide')
		{
			$("#"+id).hide("slow");
			$("#"+id).html(html);
			$("#"+id).show("slow");
		}
		else if (types=='fade')
		{
			$("#"+id).fadeOut("slow",function(){
			$("#"+id).html(html);
			});
			$("#"+id).fadeIn("slow");
		}
		else if (types=='toggle')
		{
			$("#"+id).slideToggle("slow",function(){
			$("#"+id).html(html);
			});
		}
		else if (types=='fadeto')
		{
			$("#"+id).fadeTo("slow",0.3);    
			$("#"+id).html(html);
		}
		else if (types=='down')
		{
			$("#"+id).slideDown("slow",function(){
			$("#"+id).html(html);
			});
		}
		else if (types=='up')
		{
			$("#"+id).slideUp("slow",function(){
			$("#"+id).html(html);
			});
		}
		else if (types=='css')
		{
			$("#"+id).css();
		}
		load_off();
	}
	});
}

function load_on(){
	$('#loading').show();
}

function load_off(){
	$('#loading').hide();
}
function open_project(ad,alan,bg){
	ajx('index.php','proje_detay','content','fade','ad='+ad+'&alan='+alan);
	if (bg!=0)
		$('#menu').css("background-image","url(css/img/"+ad+"_bg.png)");
}
function open_projects(ad,bg,id){
	ajx('index.php',ad,'content','fade','page=projects');
	if (id!=''){
		$('a.aktif').attr('class','normal');
		$('#'+id).attr('class','aktif');
	}
	if (bg!='')
		$('#menu').css("background-image","url(css/img/top_"+ad+"_bg.png)");
}
function open_about(ad,alan){
	//alert(ad+'   '+alan);
	ajx('index.php','about_detay','content','fade','ad='+ad+'&alan='+alan);
	//$('#menu').css("background-image","url(css/img/"+ad+"_bg.png)");
}
function open_abouts(ad,bg,id){
	ajx('index.php',ad,'content','fade','page=about');
	if (id!=''){
		$('a.aktif').attr('class','normal');
		$('#'+id).attr('class','aktif');
	}
	if (bg!=1)
		$('#menu').css("background-image","url(css/img/top_"+ad+"_bg.png)");
}
function haber_detay(ad){
	//window.open('http://www.rencons.com/demo/?action=haber_ac&proje='+ad);
	ajx('index.php',ad,'haber_icerik','fade','page=news');	
}
function haber_ac(ad){
	ajx('index.php',ad,'bottom_right','fade','page=news');	
}
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
function foo_ac(icerik,type){
	$('#foo').fadeIn('slow');
	
	var div=document.getElementById('foo').style;
	var width=div.width;
	var height=div.height;
	if (type=='img'){
		$('#foo').html('<img src="'+icerik+'" style="width:'+width+';height:'+height+';"/>');	
	}
}
function foo_close(){
	$('#foo').html('');
	$('#foo').fadeOut('slow');
}
function buyut(id){
	$('#'+id).css('width','60px','height','60px');
	//$('#'+id).css('height','60px');
	/*
	$('#'+id).animate({
		width:"60px",
		height:"60px"
	},100);*/
}
function kucult(id){
	$('#'+id).css('width','52px','height','52px');
	//$('#'+id).css('width','52px');
}

function gizle_goster(id){
	//alert(id);
	$('#'+id+'_alt').toggle('slow');
}

function scrolltimerkill()
{
	clearTimeout(scrolltimer);
}

function scrollup(divid)
{
	mdiv=$("."+divid);
	mdiv.scrollTo('-=121px','+=0');
	scrolltimer=setTimeout('scrollup("'+divid+'")',500);
}
function scrolldown(divid)
{
	mdiv=$("."+divid);
	mdiv.scrollTo('+=121px','+=0');
	scrolltimer=setTimeout('scrolldown("'+divid+'")',500);
}


