_PAGING.results=new Object();
var _RESULT = _PAGING.results;
_RESULT.headerInactive="listInactive";
_RESULT.headerOver="listOver";
_RESULT.headerActive="listActive";
_RESULT.evenTr="listingEvenTr";
_RESULT.oddTr="listingOddTr";
_RESULT.listingTr="listing"
_RESULT.headerTrIndex=0;
_RESULT.disabledHeader="noitem";
_RESULT.descIMG="/img/s_desc.gif";
_RESULT.ascIMG="/img/s_asc.gif";
_RESULT.deafultEvent=_PAGING.orderBy;
_PAGING.deleteMyAdvertise=function()
{
	if(_RESULT.selectedCompare<1)
	{

		alert("Lütfen silmek isteğiniz ilanları seçiniz.","Hata");
		return false;
	}
	checks=document.getElementsByName('advertise_compare_id[]');
	j=0;
	if(confirm("Seçtiğiniz ilanları silmek istediğinizden eminmisiniz"))
	{
		str=""

		for(i=0;i<checks.length;i++)
		{
			if(checks[i].checked)
			{
				str+="advertise_delete_id["+j+"]="+checks[i].value+"&";
				j++;
			}
		}
		_AJAX.sendLoad("/real_estate/delete_my_advertise.php",str);
	}

	//_AJAX.sendLoad("delete_my_advertise.php",)
}
_PAGING.compareAdd=function(){

	if(_RESULT.selectedCompare<2)
	{

		alert("Karşılaştırma yapabilmek için en az 2 ilan seçmeniz gerekmektedir.<br>Lütfen karşılaştırma için ilan seçiniz.",'',"Uyarı!",2);
		return false;
	}
	if(_RESULT.selectedCompare>5)
	{

		alert("Lütfen en fazla 5 ilan seçiniz.",'',"Uyarı!",2);
		return false;
	}
	_PAGING.formOBJ.target="newWindow";
	_PAGING.formOBJ.action="/real_estate/advertise_compare.php";
	_PAGING.formOBJ.method="POST"
	_PAGING.formOBJ.submit();
	_PAGING.formOBJ.target="";
	_PAGING.formOBJ.action="";
	_PAGING.formOBJ.method="GET"
}
_RESULT.selectedCompare=0;
_RESULT.countCompare=function(chck)
{
	if(chck)
	_RESULT.selectedCompare=_RESULT.selectedCompare+1
	else
	_RESULT.selectedCompare=_RESULT.selectedCompare-1

}
_RESULT.event=new Array();
//_RESULT.event[0]=_PAGING.compareAdd;
_RESULT.bottomEvent=new Array();
_RESULT.bottomEvent[0]=_PAGING.compareAdd;
_RESULT.bottomEvent[1]=_RESULT.deleteMyAdvertise	
_RESULT.setProperties=function(prop,value){
	this[prop]=value;
}
_RESULT.orderBy=function (index,direction){

	
	this.formOBJ['sf'].value=0;
	this.formOBJ[this.orderDirection].value=direction;
	this.formOBJ.submit();
}
_RESULT.styleResult=function(active){
	if(document.getElementById(this.listingTr)){
		var elem=document.getElementById(this.listingTr).getElementsByTagName('tr');
		var tdHeader=elem[this.headerTrIndex].getElementsByTagName('td');
		if(_PAGING.formOBJ[_PAGING.orderByFName])
			var obValue=_PAGING.formOBJ[_PAGING.orderByFName].value;
		var active=obValue;
		var subControl=document.getElementById('bottomControl');
		if(subControl)
		{
			subControl=subControl.getElementsByTagName('td');
			for(i=0;i<subControl.length;i++)
			{
				
				if(subControl[i].id!='disabledItem')
				{
					subControl[i].onmouseover=function()
					{
						this.style.cursor="pointer"
					}
					subControl[i].className=this.headerInactive
					subControl[i].index=i
					subControl[i].onmousemove=function highLight(){this.className=_RESULT.headerOver};
					subControl[i].onmouseout=function highLight(){this.className=_RESULT.headerInactive};
					subControl[i].onmousedown=function mouseDown()
					{
	
	
						if(_RESULT.bottomEvent[this.index])
						{
							_RESULT.bottomEvent[this.index]();
						}
					}
				}
			}
		}
		for(i=0;i<tdHeader.length;i++)
		{

			tdHeader[i].className=this.headerInactive
			tdHeader[i].index=i

			tdHeader[i].onmousedown=function mouseDown(){

				if(_RESULT.disabledHeader.indexOf(this.index+',')==-1)
				{
					if(_RESULT.event[this.index])
					{
						_RESULT.event[this.index]();
					}
					else
					{
						if((obValue!=null||obValue!=undefined)&&obValue==this.index&&_PAGING.formOBJ[_PAGING.orderDirection].value!="")
						{
							this.orderIndex=_PAGING.formOBJ[_PAGING.orderDirection].value
						}
						if(this.orderIndex==null) this.orderIndex=0
						this.orderIndex=(this.orderIndex+1)%3
						_RESULT.deafultEvent(this.index,this.orderIndex);
					}
				}


			}
			

			if(_RESULT.disabledHeader.indexOf(i+',')==-1)
			{
				tdHeader[i].onmouseover=function()
				{
					this.style.cursor="pointer"
				}
			}

			if(active!=""&&active!=null && active==i){
				if(_RESULT.disabledHeader.indexOf(i+',')==-1)
				{
					tdHeader[active].className=_RESULT.headerActive;
					if(_PAGING.formOBJ[_PAGING.orderDirection].value==1)
					tdHeader[active].innerHTML+='&nbsp;&nbsp;<img src="'+_RESULT.ascIMG+'">'
					else if(_PAGING.formOBJ[_PAGING.orderDirection].value==2)
					tdHeader[active].innerHTML+='&nbsp;&nbsp;<img src="'+_RESULT.descIMG+'">'
					else
					{
						tdHeader[active].className=_RESULT.headerInactive;
						tdHeader[active].onmousemove=function highLight(){this.className=_RESULT.headerOver};
						tdHeader[active].onmouseout=function highLight(){this.className=_RESULT.headerInactive};
					}

					active=null
					continue
				}
			}
			else
			{
				if(_RESULT.disabledHeader.indexOf(i+',')==-1)
				{
					tdHeader[i].onmousemove=function highLight(){this.className=_RESULT.headerOver};
					tdHeader[i].onmouseout=function highLight(){this.className=_RESULT.headerInactive};
				}
			}
		}


		//PARAMETRIC
		for(i=this.headerTrIndex+1;i<elem.length;i++)
		{
			
			prp=""
			if(elem[i].attributes.prop)
			{

				prp=elem[i].attributes.prop.value
				if(prp==","||prp=='0,')
				{
					prp=""
				}

			}

			if(elem[i].className!="")
			{
				if(prp!="")
					_RESULT.tdStyler(elem[i],prp)
				continue;
			}
			if(this.trStyler(i))
			{
				if(elem[i].id=='row')
					elem[i].className=this.evenTr
			}
			else {
				if(elem[i].id=='row')
					elem[i].className=this.oddTr
			}

			if(prp!="")
				_RESULT.tdStyler(elem[i],prp)
		}

	}
}

_RESULT.tdStyler=function(elem,st)
{

	for(var i=0;i<_RESULT.propertyLayOut.length;i++)
	{

		if(elem.id==_RESULT.propertyLayOut[i].trID)
		{
			if(st.indexOf(_RESULT.propertyLayOut[i].index+',')==-1)
			continue;
			if(_RESULT.propertyLayOut[i].tdIndex==null)
			{

				elem.className=elem.className+" "+_RESULT.propertyLayOut[i].class_name
			}
			else
			{

				elem.getElementsByTagName('td')[_RESULT.propertyLayOut[i].tdIndex].className=elem.getElementsByTagName('td')[_RESULT.propertyLayOut[i].tdIndex].className+" "+_RESULT.propertyLayOut[i].class_name
			}

		}
	}
	//if(style.indexOf(this.index+',')==-1)
}
_RESULT.propertyLayOut=new Array();
function setPropertyLayOut(prpId,prtClass,prpTrId,prpTdIndex)
{
	this.index=prpId;
	this.class_name=prtClass;
	this.trID=prpTrId
	this.tdIndex=prpTdIndex;
}
_RESULT.propertyLayOut.push(new setPropertyLayOut(1,'yellow','listingTitle',null))
_RESULT.propertyLayOut.push(new setPropertyLayOut(1,'yellow','listingRow',null))
_RESULT.propertyLayOut.push(new setPropertyLayOut(5,'bld','listingTitle',2))
_RESULT.propertyLayOut.push(new setPropertyLayOut(6,'red','listingTitle',2))

_RESULT.trStyler=function(index)
{

	if(index%6==5||(index)%6==1||(index)%6==0)
	return true;
}
_RESULT.listMode=function (){
	var elem=document.getElementById(this.listingTr).getElementsByTagName('img');
	for(i=0;i<elem.length;i++){
		
		if(elem[i].src.indexOf("ico_pointer.gif")!=-1 || elem[i].src.indexOf("ico_list.gif")!=-1 ||elem[i].src.indexOf("s_asc")!=-1||elem[i].src.indexOf("s_desc")!=-1)
			continue;
		elemNow= elem[i].parentNode.parentNode.parentNode.parentNode.parentNode;
		if(elemNow.style.display!="none")
		{
			
			elem[i].style.display="none";
		 	elemNow.style.display="none";

		}
		else
		{
			if(_BROWSER.name=="Netscape")
				elemNow.style.display="table";
			else
				elemNow.style.display="inline";
			elem[i].style.display="inline";
		}
	}
	this.writeModeInners();

}
_RESULT.detailMode=function (){
	if(document.getElementById(this.listingTr))
	{
		var elem=document.getElementById(this.listingTr).getElementsByTagName('img');
		for(i=0;i<elem.length;i++)
		{
			elemNow= elem[i].parentNode.parentNode.parentNode.parentNode.parentNode;
			if(_BROWSER.name=="Netscape")
				elemNow.style.display="table";
			else
				elemNow.style.display="inline";
			elem[i].style.display="inline";
		}
		this.writeModeInners();
		//tg.innerHTML="Liste"
	}
}
_RESULT.writeModeInners=function()
{
	if(document.getElementById(this.listingTr))
	{
		var picstate=false;
		var elem=document.getElementById(this.listingTr).getElementsByTagName('img')
		for(i=0;i<elem.length;i++)
		{
			if(elem[i].attributes.ptitle&&elem[i].attributes.ptitle!="")
			{
					elemNow=elem[i];
					
			}
		}
		 
		 
		if(elemNow.style.display=='none'||elemNow.style.display=="")
		{
			if(document.getElementById('listType2'))
			document.getElementById('listType2').innerHTML='<a href="javascript:_PAGING.setFormValue(\'ishw\',\'\');_RESULT.detailMode()" class="blue_link_u">Resim</a> | <b>Liste</b> | &nbsp;&nbsp;'

			document.getElementById('listType').innerHTML='<a href="javascript:_PAGING.setFormValue(\'ishw\',\'\');_RESULT.detailMode()" class="blue_link_u">Resim</a> | <b>Liste</b> | &nbsp;&nbsp;'

		}
		else
		{

			if(elemNow.src&&elemNow.src.indexOf("spacer.gif")!=-1||elemNow.src.indexOf("spacer.gif")!=-1)
			{
				
				showAdvertiseImg(this.listingTr,"thumb_6448")
			}
			if(document.getElementById('listType2'))
			{
				document.getElementById('listType2').innerHTML='<b>Resim</b> | <a href="javascript:_PAGING.setFormValue(\'ishw\',\'1\');_RESULT.listMode()" class="blue_link_u">Liste</a> | &nbsp;&nbsp;'

			}
			document.getElementById('listType').innerHTML='<b>Resim</b> | <a href="javascript:_PAGING.setFormValue(\'ishw\',\'1\');_RESULT.listMode()" class="blue_link_u">Liste</a> | &nbsp;&nbsp;'
		}
	}
}
_RESULT.bigImg=function(index)
{
	window.location.href=this.advertise_detail_url+"?ad_id="+index;
}
function checkAll(tg,val){
	elem=document.getElementById(tg).getElementsByTagName('input')
	for(i=1;i<elem.length;i++)
	{if(elem[i].type=="checkbox") elem[i].checked=val;}
}