//For Pageing 
var currentP = 1;
var dispPNo = 9;
function showPage(icount,totalpages)//Show given number page
{
	//document.getElementById('Div').style.visibility="hidden";
	for(i=1;i<=totalpages;i++)
	{	
		if(i==icount)
		{
			document.getElementById('Div'+i).style.visibility="visible";
			document.getElementById('Div'+i).style.position="relative";
			document.getElementById('Div'+i).style.top="";
			if (document.getElementById('sp' +i)=='[object]' || document.getElementById('sp' +i)=='[object HTMLSpanElement]')
				document.getElementById('sp' +i).style.color="#FF0000";
			if (document.getElementById('spi' +i)=='[object]' || document.getElementById('spi' +i)=='[object HTMLSpanElement]')
				document.getElementById('spi' +i).style.color="#FF0000";
			currentP = i;
		}
		else
		{
			document.getElementById('Div'+i).style.visibility="hidden";
			document.getElementById('Div'+i).style.position="absolute";
			document.getElementById('Div'+i).style.top="0";
			document.getElementById('Div'+i).style.height=document.getElementById('Div'+icount).style.height;
			if (document.getElementById('sp' +i)=='[object]' || document.getElementById('sp' +i)=='[object HTMLSpanElement]')
				document.getElementById('sp' +i).style.color="#000000";
			if (document.getElementById('spi' +i)=='[object]' || document.getElementById('spi' +i)=='[object HTMLSpanElement]')
				document.getElementById('spi' +i).style.color="#000000";
		}
	}
}

function nextPages(totalpages) {//next button click
	if ((currentP)!=totalpages) {
		showPage(currentP+1,totalpages);
		var html='';
		if (currentP!=1)	html=html+'<a href="javascript:prevPages('+totalpages+');">Prev</a> ';
		var limit = (dispPNo+currentP);
		var start = currentP;
		if((dispPNo+currentP)>=totalpages) { start = (currentP-dispPNo)+(totalpages-currentP); limit = totalpages;}
		for (i=start;i<=limit ;i++)
		{
			html=html+'<a id="A1" href="javascript:void(0);" onclick="showPage('+i+','+totalpages+')" ><span id="sp'+i+'">'+i+'</span></a> ';
		}
		if ((currentP+dispPNo)<totalpages)	html=html+'<a href="javascript:nextPages('+totalpages+');">Next</a>';
		
		document.getElementById('pageno').innerHTML = html;
		document.getElementById('sp'+currentP).style.color="#FF0000";
	}
}

function prevPages(totalpages) {//previous button click
	if ((currentP-1)!=0) {
		showPage(currentP-1,totalpages);
		var html='';
		if ((currentP-dispPNo)>1)	html=html+'<a href="javascript:prevPages('+totalpages+');">Prev</a> ';
		var limit=currentP; 
		var start = currentP-dispPNo;
		if((currentP-dispPNo)<=1) {	limit = dispPNo+1; start = 1; }
		for (i=start;i<=limit ;i++)
		{
			html=html+'<a id="A1" href="javascript:void(0);" onclick="showPage('+i+','+totalpages+')" ><span id="sp'+i+'">'+i+'</span></a> ';
		}
		if ((currentP)<totalpages)	html=html+'<a href="javascript:nextPages('+totalpages+');">Next</a>';
		
		document.getElementById('pageno').innerHTML = html;
		document.getElementById('sp'+currentP).style.color="#FF0000";
	}
}
//

function narrowResult()//Narrow Result click
{
	var checkboxs = document.getElementsByTagName('input');
	var property = "";
    for(var i = 0, CB_obj; CB_obj = checkboxs[i]; i++) 
    {
	    if(CB_obj.type.toLowerCase() == 'checkbox')
	    { 
	    	if (CB_obj.checked)
	    	{
	    		property = property +", "+ CB_obj.value;
	    	}
	    }
    }
    property=property.substring(2,property.length);
    if(property!="")
    {
	    document.cookie = escape("property") + "=" + escape(property) + "; path=/";
	    //window.parent.location.href="../CorpInner/ctm_displaypage.asp?page=AptSeaRe&PageGroup=CORPINNER";
	    window.parent.location.href="../lyonapartment/ApartmentSearchResult.asp";
	    //window.location.href="ctm_AptSearchResult.asp?page=APTSEARE&PageGroup=CORPINNER&flag=-1";
    }
}
//