/*--------------Holdlink()---------------*/
function holdlink(id, sub_id1, sub_id2){
	if(id=='home'){
	document.getElementById('inner_header').style.display='none';
	document.getElementById('home_header').style.display='';
	document.getElementById(id).style.display='none';
	} else
	document.getElementById(id).className='current';
}
/*--------------Holdlink()---------------*/

/*--------------------------popup() ----------------------------*/
function popup(path)
{

	var NewWin3;
	NewWin3=window.open(SITE_URL+"page/"+path+"/",'NewWin1','height=600,width=620,top=10,left=150,location=no,status=no,toolbar=no,menubar=no,scrollbars=yes');
	NewWin3.focus();
}
/*--------------------------consultation() ----------------------------*/

/*------------include function---------------------*/
function include_file(id, url) {
	
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
  if (req) {
    // Synchronous request, wait till we have it all
	req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } 
}
/*------------include function---------------------*/

/*Misc*/
function hometext(id){
	if(document.getElementById(id).style.display==''){
		document.getElementById(id).style.display='none';
	}else {
		document.getElementById(id).style.display='';
	}	
}
/*Misc*/

function processPayment() { 

	document.getElementById('submit_Payment').disabled="yes";
	//document.getElementById('edit_information').disabled="yes";
	var pagesize = getPPageSize();
	document.getElementById('shadowLayer').style.top=0;
	document.getElementById('shadowLayer').style.left=0;
	document.getElementById('shadowLayer').style.width=pagesize[0]+"px";
	document.getElementById('shadowLayer').style.height=pagesize[1]+"px";
	document.getElementById('shadowLayer').style.background="#000000";
	document.getElementById('shadowLayer').style.display="";
	
	document.getElementById('processingBox').style.top=0;
	document.getElementById('processingBox').style.left=0;
	document.getElementById('processingBox').style.border='4px solid #c9c9c9';
	document.getElementById('processingBox').style.background='#FFFFFF';
	document.getElementById('processingBox').style.top = ((pagesize[1])/2)+'px';;	
	document.getElementById('processingBox').style.left = ((pagesize[0]-200)/2)+'px';
	document.getElementById('processingBox').style.display="";
}

/********************** Update Class Of li for showing Navigation at left *************************/
function getPPageSize(){
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth) {	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	var total_width = windowWidth; 

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (1) {
			curleft+=obj.offsetLeft;
			if (!obj.offsetParent) {
				break;
			}
			obj=obj.offsetParent;
		}
	} else if (obj.x) {
		curleft+=obj.x;
	}
	return curleft;
}
//var total_width;
function updatePosition (obj) { //alert(total_width);
	var total_width = document.getElementById('total_width').value;
	var posX = findPosX(obj);
	if((total_width-posX) <= 298) 
		obj.className = 'update';
}
/****************************************************************************************************/

function changelabel(obj,labelobj){
	var val='';
	var w = obj.selectedIndex;
	var selected_text = obj.options[w].text;
	if(trim(selected_text)==""){
		selected_text='&nbsp;';
	}
	val=selected_text;
	
	document.getElementById(labelobj).innerHTML=val;
	
}

	/*--------------ShowHide Content Div()---------------*/
var ids=new Array('a1','a2');
var oldboxid;
function switchid(id){	
	/*hideallids();
	showdiv(id);*/
	if(id=='a1' && id!=oldboxid) {
		//alert('comes')
		hideallids();
		showdiv(id);
		$('#scrollup1').hide();
		$('#scrollup').show();
		//headline_rotate('scrollup');
		
	} else if(id=='a2' && id!=oldboxid) {
		//alert('comes1')
		hideallids();
		showdiv(id);
		$('#scrollup').hide();
		$('#scrollup1').show();
		//headline_rotate1('scrollup1');
	}
	oldboxid = id;
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}
	
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
	
function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
			
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
/*--------------ShowHide Content Div()---------------*/
	
/*$.fn.scrollText = function(){
	currentItem = this.children(":first"); 	
	height = currentItem.height();
	
	duration = (height + 8000);
	currentItem.animate({
							marginTop:-height
						},duration, "linear", function(){
							currentItem.appendTo(currentItem.parent()).css("marginTop",0);
							currentItem.parent().scrollText();
					}//end fucntion
	)//animate
	
}

$(function(){	
	var innerheight = $("#inner").height();
	if(innerheight > 160){
		$("#inner").scrollText();
		
		$("#inner").mouseenter(function(){
			$(this).children().stop();
		})
		
		$("#inner").mouseleave(function(){
			$(this).scrollText();
		})
	}
		//scrollSpecialText()	
})//end function
*/
function validateRent()
{
	var	minRent	=	0;
	var	maxRent	=	0;
	
	var minRent	=	parseInt(document.getElementById("selminrent").value);
	var maxRent	=	parseInt(document.getElementById("selmaxrent").value);
	/*alert("min="+minRent)
	alert("max="+maxRent);*/
	if(minRent<=maxRent)
	{
		return true;
	}
	else
	{
		alert("Min rent should be less than max rent!")
		return false;
	}
}

function popList(flag)
{
	if(flag=='1'){
		$('#defaultPopup').slideDown('fast', function() {
			// Animation complete.
		 });
	} else {
		$('#defaultPopup').slideUp('fast', function() {
			// Animation complete.
		 });
	}
	
}

function defaultSearchPopUp(flag){
	if(flag){
		$('#defaultPopup').slideDown('fast', function() {
			// Animation complete.
		 });
	} else {
		$('#defaultPopup').slideUp('fast', function() {
			// Animation complete.
		 });
	}

}

function showMoveToTop(){
	$(window).scroll(function(){
			var h = $(window).scrollTop();
			if(h>400){
				var wh = $(window).height();
				$("#topButton").animate({opacity:"show",top:'+='+(wh-30)},800);
				$("#topButton").show();
			}
			else{
				$("#topButton").css("top",-5);
				$("#topButton").hide();
			}
		});
		
		$('#topButton').click(function(){
			$( 'html, body' ).animate( { scrollTop: 0 }, 1500 );
		});
		
}
function loadLightBox(eid){
	$('.'+eid+' a').lightBox();
}

