window.onerror=function(desc,page,line,chr){
/* alert('JavaScript error occurred! \n'
  +'\nError description: \t'+desc
  +'\nPage address:      \t'+page
  +'\nLine number:       \t'+line
 );*/
}

var urrxx = "http://filmfabrikasi.com/";

$(function(){
 $('a').focus(function(){this.blur();});
 SI.Files.stylizeAll();
 slider.init();

 $('input.text-default').each(function(){
  $(this).attr('default',$(this).val());
 }).focus(function(){
  if($(this).val()==$(this).attr('default'))
   $(this).val('');
 }).blur(function(){
  if($(this).val()=='')
   $(this).val($(this).attr('default'));
 });

 $('input.text,textarea.text').focus(function(){
  $(this).addClass('textfocus');
 }).blur(function(){
  $(this).removeClass('textfocus');
 });

 var popopenobj=0,popopenaobj=null;
 $('a.popup').click(function(){
  var pid=$(this).attr('rel').split('|')[0],_os=parseInt($(this).attr('rel').split('|')[1]);
  var pobj=$('#'+pid);
  if(!pobj.length)
   return false;
  if(typeof popopenobj=='object' && popopenobj.attr('id')!=pid){
   popopenobj.hide(50);
   $(popopenaobj).parent().removeClass(popopenobj.attr('id').split('-')[1]+'-open');
   popopenobj=null;
  }
  return false;
 });
 $('p.images img').click(function(){
  var newbg=$(this).attr('src').split('bg/bg')[1].split('-thumb')[0];
  $(document.body).css('backgroundImage','url('+_siteRoot+'images/bg/bg'+newbg+'.jpg)');
 
  $(this).parent().find('img').removeClass('on');
  $(this).addClass('on');
  return false;
 });
 $(window).load(function(){
//  $.each(css_ims,function(){(new Image()).src=_siteRoot+'css/images/'+this;});
//  $.each(css_cims,function(){
//   var css_im=this;
//   $.each(['blue','purple','pink','red','grey','green','yellow','orange'],function(){
 //   (new Image()).src=_siteRoot+'css/'+this+'/'+css_im;
 //  });
 // });
 }); 
 $('div.sc-large div.img:has(div.tml)').each(function(){
  $('div.tml',this).hide();
  $(this).append('<a href="#" class="tml_open">&nbsp;</a>').find('a').css({
   left:parseInt($(this).offset().left)+864,top:parseInt($(this).offset().top)+1
  }).click(function(){
   $(this).siblings('div.tml').slideToggle();
   return false;
  }).focus(function(){this.blur();}); 
 });
});
var slider={
 num:-1,
 cur:0,
 cr:[],
 al:null,
 at:10*1000,
 ar:true,
 init:function(){
  if(!slider.data || !slider.data.length)
   return false;

  var d=slider.data;
  slider.num=d.length;
  var pos=Math.floor(Math.random()*1);//slider.num);
  for(var i=0;i<slider.num;i++){
   $('#'+d[i].id).css({left:((i-pos)*1000)});
   $('#slide-nav').append('<a id="slide-link-'+i+'" href="#" onclick="slider.slide('+i+');return false;" onfocus="this.blur();">'+(i+1)+'</a>');
  }

  $('img,div#slide-controls',$('div#slide-holder')).fadeIn();
  slider.text(d[pos]);
  slider.on(pos);
  slider.cur=pos;
  window.setTimeout('slider.auto();',slider.at);
 },
 auto:function(){
  if(!slider.ar)
   return false;

  var next=slider.cur+1;
  if(next>=slider.num) next=0;
  slider.slide(next);
 },
 slide:function(pos){
  if(pos<0 || pos>=slider.num || pos==slider.cur)
   return;

  window.clearTimeout(slider.al);
  slider.al=window.setTimeout('slider.auto();',slider.at);

  var d=slider.data;
  for(var i=0;i<slider.num;i++)
   $('#'+d[i].id).stop().animate({left:((i-pos)*1000)},1000,'swing');
  
  slider.on(pos);
  slider.text(d[pos]);
  slider.cur=pos;
 },
 on:function(pos){
  $('#slide-nav a').removeClass('on');
  $('#slide-nav a#slide-link-'+pos).addClass('on');
 },
 text:function(di){
  slider.cr['a']=di.client;
  slider.cr['b']=di.desc;
  slider.ticker('#slide-client span',di.client,0,'a');
  slider.ticker('#slide-desc',di.desc,0,'b');
 },
 ticker:function(el,text,pos,unique){
  if(slider.cr[unique]!=text)
   return false;

  ctext=text.substring(0,pos)+(pos%2?'-':'_');
  $(el).html(ctext);

  if(pos==text.length)
   $(el).html(text);
  else
   window.setTimeout('slider.ticker("'+el+'","'+text+'",'+(pos+1)+',"'+unique+'");',30);
 }
};
// STYLING FILE INPUTS 1.0 | Shaun Inman <http://www.shauninman.com/> | 2007-09-07
if(!window.SI){var SI={};};
SI.Files={
 htmlClass:'SI-FILES-STYLIZED',
 fileClass:'file',
 wrapClass:'cabinet',
 
 fini:false,
 able:false,
 init:function(){
  this.fini=true;
 },
 stylize:function(elem){
  if(!this.fini){this.init();};
  if(!this.able){return;};
  
  elem.parentNode.file=elem;
  elem.parentNode.onmousemove=function(e){
   if(typeof e=='undefined') e=window.event;
   if(typeof e.pageY=='undefined' &&  typeof e.clientX=='number' && document.documentElement){
    e.pageX=e.clientX+document.documentElement.scrollLeft;
    e.pageY=e.clientY+document.documentElement.scrollTop;
   };
   var ox=oy=0;
   var elem=this;
   if(elem.offsetParent){
    ox=elem.offsetLeft;
    oy=elem.offsetTop;
    while(elem=elem.offsetParent){
     ox+=elem.offsetLeft;
     oy+=elem.offsetTop;
    };
   };
  };
 },
 stylizeAll:function(){
  if(!this.fini){this.init();};
  if(!this.able){return;};
 }
};

function sor(yer,str)
{
	
if (str.length==0)
  { 
  document.getElementById(yer).innerHTML="";
  document.getElementById(yer).style.display='none';
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
function standart()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	document.getElementById(yer).innerHTML=xmlhttp.responseText;
	document.getElementById(yer).style.display='block';
    }
  }
function oturum()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
  {
	if (xmlhttp.responseText == "hata") {
		alert('Kullanıcı adı ya da şifre hatalı');
	}else{	
	document.getElementById(yer).innerHTML=xmlhttp.responseText;
	document.getElementById(yer).style.display='block';
	
	}
  }
}
switch (yer) {
	case "eklHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str,true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "txtHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Oyuncu",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "sesHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Ses",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "kameraHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Kamera",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "isikHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Işık",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "kurguHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Kurgu",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "renkHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Renk Düzenleme",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "yyonetHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Yardımcı Yönetmen",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "sntHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Sanat Yönetmeni",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "muzikHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Müzik",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "rejiHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Reji Asistanı",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "yntHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Yönetmen",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "senHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Senaryo",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "grnHint":
		xmlhttp.open("GET",urrxx+"gethint.php?q="+str+"&i=Görüntü Yönetmeni",true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "logicerik":
		xmlhttp.open("GET",urrxx+"gethint.php?u="+str,true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=oturum;
	break;
	case "filmyrm":
		xmlhttp.open("GET",urrxx+"gethint.php?f="+str,true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "puanek":
		xmlhttp.open("GET",urrxx+"gethint.php?pu="+str,true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "uyarici":
		xmlhttp.open("GET",urrxx+"gethint.php?uy="+str,true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "oyuncuekl":
		xmlhttp.open("GET",urrxx+"gethint.php?c_is="+str,true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	case "yorums":
		var params = "uye="+str;
		xmlhttp.open("POST",urrxx+"gethint.php",true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=iso-8859-9");
		xmlhttp.setRequestHeader("Content-length", params.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(params);
		xmlhttp.onreadystatechange=standart;
	break;	
	default:
		xmlhttp.open("GET",urrxx+"gethint.php?oe="+str,true);
		xmlhttp.send();
		xmlhttp.onreadystatechange=standart;
	break;
	
}

}

function exchange(id){
var ie=document.all&&!window.opera? document.all : 0
var frmObj=ie? ie[id] : document.getElementById(id)
var toObj=ie? ie[id+'b'] : document.getElementById(id+'b')
// toObj.style.width=frmObj.offsetWidth+7+'px'
toObj.style.width='290px';
toObj.style.height='20px';
frmObj.style.display='none';
toObj.style.display='inline';
toObj.value=frmObj.innerHTML
}

function enterAl(isim,id) {
	if (event.keyCode == 13) {
	sor('uyarici',document.getElementById(isim + 'b').value + '\&ay\=' + isim  + '\&id\=' + id);
	document.getElementById(isim + 'b').style.display='none';
	document.getElementById(isim).innerHTML=document.getElementById(isim + 'b').value;
	document.getElementById(isim).style.display='inline';
	}
}

function showIt(item,i,j,max){
	   var id;
	   actualItem = item;
	   
	   // Show the selected boxes
	   for (var x=1;x<=i;x++){
	      id = item + "_" + x;
	      document.getElementById(id).src = urrxx + "imaj/b.gif";
	   }
	   
	   // Display the not selected ones
	   for (var x=i+1;x<=max;x++){
	      id = item + "_" + x;
	      if (x<=j) document.getElementById(id).src = urrxx + "imaj/y.gif";
	      else document.getElementById(id).src = urrxx + "imaj/w.gif";
	   }
	}

	function showOriginal(i,max){
	   for (var x=1;x<=max;x++){
	      id = actualItem + "_" + x;
	      if (x<=i) document.getElementById(id).src = urrxx + "imaj/y.gif";
	      else document.getElementById(id).src = urrxx + "imaj/w.gif";
	   }
	}
	
	function yorumgonder () {
		if (document.forms[0].yorum.value == "") {
			alert ('Yaptığına şantaj denir. Böyle aşka montaj denir.')
		} else {
		sor('yorums',document.forms[0].uye.value + '\&yorum\=' + document.forms[0].yorum.value + '\&film\=' + document.forms[0].film.value);
		}
	}
	
	function oturumsor() {
		if (document.getElementById("kadii")) { 
			alert ('Üye olun ya da üye girişi yapın.');
			document.getElementById("kadii").style.background="red";
			document.getElementById("ksifree").style.background="red";
			} else {
		window.location = urrxx + "form.php";
	}
	}
	
	function film_sil_sor()
	{
	 var sil_sor = confirm("Film silinecek. Onaylıyor musunuz?");
	 if (sil_sor == true)
	 {
	   document.sil_s.submit();
	 }
	 else
	 {
	  return false;
	  }
	}
