
function popup(url,width,height){
	window.setTimeout("window.open('"+ url +"','_blank','width="+ width +",height="+ height +"');");
}

function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

function getMouseY(e) {
	tempY = event.clientY + document.body.scrollTop;
	
	if (tempY < 0){tempY = 0;}  
	return tempY;
}

function menu_ac(elm){
		$(elm).show();
}

function menu_kapa(elm){
	$(elm).hide();
}

function resimDegis(resim,nsn,href)
{
	var rsm=document.getElementById(nsn);
	rsm.src= resim ;
	if(href != null)
		rsm.parentNode.setAttribute("href",href);
}


var popUpWin=0;

function popUpWindow(URLStr, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+'');
}

function numbersonly(myfield, e, dec)
{
	var key;
	var keychar;
	
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
		 (key==9) || (key==13) || (key==27) )
		return true;
	
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
		return true;
	
	// decimal point jump
	else if (dec && (keychar == "."))
		{
		myfield.form.elements[dec].focus();
		return false;
		}
	else
		return false;
}

function textOnly(myfield, e)
{
	var key;
	var keychar;
	
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
		 (key==9) || (key==13) || (key==27) )
		return true;
	
	// characters
	else if ( /[a-z|A-Z|0-9]/.test(keychar) == true )
		return true;
	
	else
		return false;
}

function rmzKontrol(obj,tur)
{
	cotoci.sg('rumuz.asp?kont='+ obj.value +'&tur='+ tur +'&sid='+Math.random(),frs=function(){
		var veri=eval(frs.arguments[0].responseText);
		if(tur=='rumuz'){
			cotoci.ge('rumuzSonuc').innerHTML=veri.durum;
			
		}else{
			cotoci.ge('mailSonuc').innerHTML=veri.durum;
		}
		
		obj.onclick=function(){cotoci.ge('hataSonuc').innerHTML=veri.hata;}
		
	} )
}

function uyeForm()
{
	var frm=document.uyefrm;
	hata='';
	if(frm.rumuz.value=='')
		hata += '- Rumuz yazınız\n';
	
	if(frm.sifre.value=='')
		hata += '- Şifre yazınız\n';
		
	if(frm.sifre.value != frm.sifre2.value)
		hata += '- Şifre alanları farklı\n';
	
	if(frm.isim.value=='')
		hata += '- Görünen adınızı azınız\n';
		
	if(frm.mail.value=='')
		hata += '- Mail yazınız\n';
	
	if(frm.ulke.value=='')
		hata += '- Ülke seçiniz\n';
	
	if(frm.sehir.value=='')
		hata += '- Şehir seçiniz\n';
		
	if(frm.sehir.value=='')
		hata += '- Şehir seçiniz\n';
	
	if(frm.gun.value=='0' || frm.ay.value=='0' || frm.yil.value=='0')
		hata += '- Doğum tarihi yazınız\n';
	
	if(frm.guvenlik.value=='')
		hata += '- Güvenlik kodunu yazınız\n';
		
	
	if(hata != '')
	{
		msg  ='Forumda Hatalar Var\n';
		msg +='----------------------------\n';
		msg +=hata;
		msg +='----------------------------';
		alert(msg);
		return false;
	}
}

function sfrGonder()
{
	mail=document.sifr.mail.value;
	
	$.get('sifre.asp?islem=kyt&mail='+ mail +'&sid='+Math.random(), function(data) {
	  $('#sifLayer').html(data);
	});

}



function anketGonder()
{
	id=document.anketFrm.id.value;
	tcvp=document.anketFrm.cvp
	for(var i=0; i < tcvp.length; i++)
	{
		if(tcvp[i].checked==true)
		{
			cvp=tcvp[i].value;
			break;
		}
	}
	$.get('anket.asp?islem=kyt&id='+ id +'&cvp='+ cvp +'&sid='+Math.random(), function(data) {
	  $('#anketLayer').html(data);
	});
}


function mesajYaz()
{
	var mesaj=document.msg.mesaj.value;
	var alanID=document.msg.alanID.value;
	if( mesaj != ''){
		var msj=encodeURIComponent(mesaj)
		cotoci.sp('mesaj.asp?id='+ alanID +'&islem=gonder&method=ajax', 'mesaj='+ msj +'&alanID='+ alanID +'&sid='+Math.random(),frs=function(req){
			var veri=req.responseText;
			cotoci.ge('mesajlar').innerHTML=veri;
			document.msg.mesaj.value="";
			cotoci.ge('mesajlar').scrollTop=cotoci.ge('mesajlar').scrollHeight;
		} )
	}
}


var Url = {
 
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},
 
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}

if( document.implementation.hasFeature("XPath", "3.0") ){
	if( typeof XMLDocument == "undefined" ){ XMLDocument = Document; }
  XMLDocument.prototype.selectNodes = function(cXPathString, xNode){
    if( !xNode ) { xNode = this; } 
		var oNSResolver = this.createNSResolver(this.documentElement)
		var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
		var aResult = [];
		for( var i = 0; i < aItems.snapshotLength; i++){aResult[i] =  aItems.snapshotItem(i);	}
		return aResult;
	}
	XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode){
		if( !xNode ) { xNode = this; } 
		var xItems = this.selectNodes(cXPathString, xNode);
		if( xItems.length > 0 ){return xItems[0];	}
		else{return null;	}
	}
	Element.prototype.selectNodes = function(cXPathString){
		if(this.ownerDocument.selectNodes){	return this.ownerDocument.selectNodes(cXPathString, this);}
		else{throw "For XML Elements Only";}
	}
	Element.prototype.selectSingleNode = function(cXPathString){	
		if(this.ownerDocument.selectSingleNode){return this.ownerDocument.selectSingleNode(cXPathString, this);	}
		else{throw "For XML Elements Only";}
	}
}

var emlak={
	
	dosyaKontrol: function(elm){
		dosya=elm.value;
		uz=dosya.lastIndexOf(".")+1;
		uzanti=dosya.substr(uz);
		if(uzanti.toUpperCase() != 'JPG' && uzanti.toUpperCase() != 'JPEG' && uzanti.toUpperCase() != 'GIF' && uzanti.toUpperCase() != 'PNG'){
			alert('Seçtiğiniz dosya türü yanlış!\n\nLütfen JPG,GIF,PNG türünde dosya seçiniz');
			elm.value='';
		}
	},
	
	ilanSil: function(id) {
		if(confirm('Bu ilanın tüm bilgilerini kalıcı olarak silmek istediğinize emin misiniz?'))
		{
			window.location='ilanSil.asp?act=sil&ilanID='+ id
		}
	},
	
	projeSil: function(id) {
		if(confirm('Bu projenin tüm bilgilerini kalıcı olarak silmek istediğinize emin misiniz?'))
		{
			window.location='projeSil.asp?act=sil&projeID='+ id
		}
	},
	
	urunSil: function(id) {
		if(confirm('Bu ürünün tüm bilgilerini kalıcı olarak silmek istediğinize emin misiniz?'))
		{
			window.location='urunSil.asp?act=sil&urunID='+ id
		}
	},
	
	thumb: {
		over: function(elm) {
			elm.parentNode.style.zIndex='10';
			elm.childNodes[1].style.display='block';
		},
		
		out: function(elm) {
			elm.parentNode.style.zIndex='0';
			elm.childNodes[1].style.display='none';
		}
	}
}


function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}
