var eleArr = new Array('pSale-pSaleImg','pSold-pSoldImg','acqu-acquImg','requ-requImg');
var targetId = '';
var indexChild = 0;
if(navigator.appName == 'Netscape'){
  indexChild = 1;
}
function showHide(ele, imgEle, pType, start){
	var eleSty = $(ele).style.display;
	targetId   = ele;
	
	if(eleSty == 'none'){
	  new Effect.BlindDown(ele);	 
	  $(imgEle).src = 'images/green_arrow_bottom.gif';
	  $(ele).parentNode.childNodes[indexChild].className = 'tab_bg2';
	  if (ele=='requ')
	  {
		  $('msg_div').innerHTML = "";
		  $('alert_div').className = 'alert_hide';
		  $('name').value="";
		  $('cmpName').value="";
		  $('eMail').value="";
		  $('tele').value="";
		  $('fax').value="";
		  $('cmt').value="";

	  }
      closeOthers(ele);
      if(pType != ''){
	    showDetails(pType, start);
	  }
	}
	else{
      Effect.BlindUp(ele);
  	  $(imgEle).src = 'images/green_arrow_right.gif';
	  $(ele).parentNode.childNodes[indexChild].className = 'tab_bg1';
	}
}

function closeOthers(eleM){
	for (var i = 0; i < eleArr.length ; i++)
	{
		if((eleArr[i].split('-'))[0] != eleM){
             if($((eleArr[i].split('-'))[0]).style.display != 'none'){
                Effect.BlindUp((eleArr[i].split('-'))[0]);
                $((eleArr[i].split('-'))[0]).parentNode.childNodes[indexChild].className = 'tab_bg1';
				$((eleArr[i].split('-'))[1]).src = 'images/green_arrow_right.gif';
			 } 
		}
	}
}

function showDetails(pType,start) {
	showLoader(1);
	/*var x;
	x="";
	
	if ($('multyfamily').checked==true)
	{
		x+="multyfamily,";
		//alert(x);
	}
	if ($('office').checked==true)
	{
		x+="office,";
		//alert(x);
	}
	if ($('industrial').checked==true)
	{
		x+="industrial,";
		//alert(x);
	}
	if ($('retail').checked==true)
	{
		x+="retail,";
		//alert(x);
	}
	if ($('shopCenter').checked==true)
	{
		x+="shopCenter,";
		//alert(x);
	}
	if ($('land').checked==true)
	{
		x+="land,";
		//alert(x);
	}
	if ($('agricultural').checked==true)
	{
		x+="agricultural,";
		//alert(x);
	}
	if ($('hotelMotel').checked==true)
	{
		x+="hotelMotel,";
		//alert(x);
	}
	if ($('seniorHouse').checked==true)
	{
		x+="seniorHouse,";
		//alert(x);
	}
	if ($('healthCare').checked==true)
	{
		x+="healthCare,";
		//alert(x);
	}
	if ($('sportEnt').checked==true)
	{
		x+="sportEnt,";
		//alert(x);
	}
	if ($('specialPur').checked==true)
	{
		x+="specialPur,";
		//alert(x);
	}
	if ($('resiIncome').checked==true)
	{
		x+="resiIncome,";
		//alert(x);
	}*/
	var url = "propertylistAjax.php";
	var myAjax = new Ajax.Request(url,
		 {
		  method: 'post', 
		  parameters: {propType:pType,start:start},
		  onComplete: ajaxresponseShow
		 }
	   );
}

function acquShow(mode,start)//For Acquisition
{
	showLoader(1);
	var url = "propertylistAjax.php";
	var myAjax = new Ajax.Request(url,
		 {
		  method: 'post', 
		  parameters: {mode:"acqulist",start:start},
		  onComplete: ajaxresponseShow
		 }
	   );
}
function ajaxresponseShow(originalRequest) {
 //alert("jayanta");
 $(targetId).innerHTML = originalRequest.responseText;
showLoader(0);
}

function displayAlert(msg)
{
	if(msg) $('msg_div').innerHTML = msg;
	$('alert_div').className = 'alert_show';
}

function validation()
{
	var url = "contactCheck.php";

	if (alltrim($('name').value) == "")
	{
		displayAlert("Name can't be blank.");
		$('name').select();
		$('name').focus();
		return false;
	}
	if (alltrim($('cmpName').value) == "")
	{
		displayAlert("Company Name can't blank.");
		$('cmpName').select();
		$('cmpName').focus();
		return false;
	}
	if (alltrim($('eMail').value) == "")
	{
		displayAlert("Email Address can't be blank.");
		$('eMail').select();
		$('eMail').focus();
		return false;
	}
	if(!checkEmail($('eMail').value))
	{
		displayAlert("Invalid Email Address.");
		$('eMail').select();
		$('eMail').focus();
		return false;
	}
	if (alltrim($('tele').value) == "")
	{
		displayAlert("Telephone can't be blank.");
		$('tele').select();
		$('tele').focus();
		return false;
	}
	if(!isDigitajax($('tele').value))
	{
		$('tele').select();
		$('tele').focus();
		return false;
	}
	if (alltrim($('fax').value) != "")
	{
		if(!isDigitajax($('fax').value))
		{
			$('fax').select();
			$('fax').focus();
			return false;
		}
		
	}
	if (alltrim($('cmt').value) == "")
	{
		displayAlert("Comment can't be blank.");
		return false;
	}
	
	var pars ='name='+$F('name')+'&cmpName='+$F('cmpName')+'&eMail='+$F('eMail')+'&tele='+$F('tele')+'&fax='+$F('fax')+'&cmt='+$F('cmt')+"&mode=login";
	var myAjax = new Ajax.Request(url,
		 {
		  method: 'post', 
		  parameters: pars,
		  onComplete: ajax_contactShow
		 }
	   );
	//return true;
}

function ajax_contactShow(originalRequest)
{
    
	response  = originalRequest.responseText;
	//alert(response);
	//alert(response.indexOf('yes'));
	
	if(response.indexOf('yes') != -1) {
		displayAlert("Message sent Sucessfully");
		//alert ("sucess");
		//window.location ="brokerage.php";
		//$('requ').className = 'alert_hide';
		  /*$('msg_div').innerHTML = "";
		  $('alert_div').className = 'alert_hide';*/
		  $('name').value="";
		  $('cmpName').value="";
		  $('eMail').value="";
		  $('tele').value="";
		  $('fax').value="";
		  $('cmt').value="";
	}
    else {
		//$('msg_div').innerHTML = response;
		displayAlert(response);
		//showLoader(0);
		//return false;
	}
}
// javascript function for for showing property description

function showProperty(propId)
{
	var screenHeight = screen.height;
	var screenWidth = screen.width - 20;
	$('propDesc'+propId).style.top = '0px';
	$('propDesc'+propId).style.left = '0px';
	//$('propDesc'+propId).style.width = screenWidth+'px';
	//$('propDesc'+propId).style.height = screenHeight+'px';
	Effect.Grow('propDesc'+propId);
	self.scrollTo(0,00);
}

	var imgArr = new Array();
function showImage(propId)
{
	var screenHeight = screen.height - 400;
	var screenWidth = screen.width - 400;
	$('propImage').style.top = (screenHeight / 6) + 'px';
	$('propImage').style.left = (screenWidth / 3) + 'px';
	$('propImage').style.width = screenWidth+'px';
	$('propImage').style.height = screenHeight+'px';

	imgArr = $F('imgList'+propId).split(",");
	showGal(imgArr);
	Effect.Grow('propImage');
	self.scrollTo(0,00);
}
var ImgIndex = 0;
function showGal(){
	var screenHeight = screen.height - 470;
	var screenWidth = screen.width - 470;
  //var newImg = new Image(200,150);
   var newImg = new Image();
   newImg.src = 'upload/propertyImage/' + imgArr[ImgIndex];
   //$('showImg').src = newImg.src;
   var height = Number(newImg.height);
   var width = Number(newImg.width);
   //alert ('The image size is '+width+'*'+height);
  //alert ($('showImg').style.width);
  if (height >= '400')
  {
	  $('showImg').height = screenHeight+'px';
  }
  if (width >= '400')
  {
	  $('showImg').height = screenHeight+'px';
  }
  /*$('showImg').style.width = screenWidth+'px';
   $('showImg').style.height = screenHeight+'px';*/
  $('showImg').src = newImg.src;
   Effect.Grow('showImg');
   ImgIndex++;
   if(ImgIndex == imgArr.length){
	  ImgIndex = 0;
   }
   var t = setTimeout('showGal();',3000);
}
	

// Ajax ISDIGIT
function isDigitajax(para) {
	var validchars = "0123456789";
	var parsed = true;
	for (var i=0; i < para.length; i++) {
		var letter = para.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) != -1)
			continue;
		if (isDigitajax.arguments.length==2){
			if (isDigitajax.arguments[1] == 0){
				displayAlert(letter + " is not a digit. Please enter a digit.");
			}
		}else{
			displayAlert(letter + " is not a digit. Please enter a digit.");
		}
		parsed = false;
		break;
	}
	return parsed;
}
/*-------END-----*/



var eleArr1 = new Array('pRent-pRentImg');
var targetId1 = '';
var indexChild1 = 0;
if(navigator.appName == 'Netscape'){
  indexChild1 = 1;
}
function showHide1(ele1, imgEle1, pType1, start1){
	var eleSty1 = $(ele1).style.display;
	targetId   = ele1;
	//alert(targetId1);
	if(eleSty1 == 'none'){
	  new Effect.BlindDown(ele1);	 
	  $(imgEle1).src = 'images/green_arrow_bottom.gif';
	  $(ele1).parentNode.childNodes[indexChild1].className = 'tab_bg2';
      closeOthers1(ele1);
      if(pType1 != ''){
	    showDetails1(pType1, start1);
	  }
	}
	else{
      Effect.BlindUp(ele1);
  	  $(imgEle1).src = 'images/green_arrow_right.gif';
	  $(ele1).parentNode.childNodes[indexChild1].className = 'tab_bg1';
	}
}

function closeOthers1(eleM1){
	for (var i = 0; i < eleArr1.length ; i++)
	{
		if((eleArr1[i].split('-'))[0] != eleM1){
             if($((eleArr1[i].split('-'))[0]).style.display != 'none'){
                Effect.BlindUp((eleArr1[i].split('-'))[0]);
                $((eleArr1[i].split('-'))[0]).parentNode.childNodes[indexChild1].className = 'tab_bg1';
				$((eleArr1[i].split('-'))[1]).src = 'images/green_arrow_right.gif';
			 } 
		}
	}
}

function showDetails1(pType1,start1) {
	//showLoader(1);
	var url = "propertylistAjax.php";
	var myAjax = new Ajax.Request(url,
		 {
		  method: 'post', 
		  parameters: {propType:pType1,start:start1},
		  onComplete: ajax_responseShow2
		 }
	   );
}
function ajax_responseShow2(originalRequest) {
 
 $(targetId).innerHTML = originalRequest.responseText;
 //showLoader(0);
}

function dispNewsList(pType,start) {
	//showLoader(1);
	var url = "newsDescAjax.php";
	var myAjax = new Ajax.Request(url,
		 {
		  method: 'post', 
		  parameters: {propType:pType,start:start},
		  onComplete: ajax_responseShow
		 }
	   );
}
function ajax_responseShow(originalRequest) {
 $('showNewsList').innerHTML = originalRequest.responseText;
 //showLoader(0);
}
function rentShow(mode,start)//For Rent
{
	showLoader(1);
	var url = "propertylistAjax.php";
	var myAjax = new Ajax.Request(url,
		 {
		  method: 'post', 
		  parameters: {mode:"rentlist",start:start},
		  onComplete: ajaxresponseShow
		 }
	   );
}
function rentShowpro(mode,start)//For Rent
{
	showLoader(1);
	var rad = document.getElementsByName("rentClas");
		
		for (i = 0; i < rad.length; i++)
		{
			if(rad[i].checked == true){
			var x = rad[i].value;
			}
		}
	var url = "propertylistAjax.php";
	var myAjax = new Ajax.Request(url,
		 {
		  method: 'post', 
		  parameters: {exvar:x,mode:"rentlist",start:start},
		  onComplete: ajaxresponseShow
		 }
	   );
}
/*function imgGal(rentId){
	showLoader(1);
	var url = "propertylistAjax.php";
	var myAjax = new Ajax.Request(url,
		 {
		  method: 'post', 
		  parameters: {mode:"rentlist",rentId:rentId},
		  onComplete: ajaxresponseShow
		 }
	   );
}*/



var setT = '';
function showGallery(picId, pageId){
	window.moveTo(0,0);
	
    window.resizeTo(screen.width, screen.height);
	 //$('headerPic').style.display = 'none';

	self.scrollTo(0,00);
	var screenHeight = screen.height;
	var screenWidth = screen.width - 20;
	$('dispGalleryDiv').style.top = '0px';
	$('dispGalleryDiv').style.left = '0px';
	$('dispGalleryDiv').style.width = screenWidth+'px';
	$('dispGalleryDiv').style.height = screenHeight+'px';
	Effect.Grow('dispGalleryDiv');
    $('selPicId').value  = picId;
	$('selPageId').value = pageId;
	showPicture();
}

function showPicture(){
   $('loading').style.display = 'block';
   var sPicId = $('selPicId').value;
   var myAjax = new Ajax.Request(
	//rootPath + 'showGallery.php',
   'showGallery.php',
	{
		method: 'get',
		parameters:{selPicid:sPicId, selPageId:$('selPageId').value, page:$('page').value},
		onComplete:showPic
	});
    
}

function showPic(originalRequest){
	var res = originalRequest.responseText;
	var resArray = res.split("|");
	var prevPicId = resArray[0];
	var curPicPath = resArray[1];
	var nextPicId = resArray[2];
	var selPicId = resArray[3];
	$('prevPicId').value = prevPicId;
	$('nextPicId').value = nextPicId;
	if($F('move') == 1){
     $('selPicId').value  = nextPicId;
	}
	else{
      $('selPicId').value  = prevPicId;
	}
	
	var w = 240;
	var h = 55;
	var pic = new Image(parseInt(w),parseInt(h)); 
	pic.height = h;
    pic.width  = w;
    pic.src = curPicPath;
	//$('loadedImage').style.height = h;
    //$('loadedImage').style.width  = w;

    $('loadedImage').src = pic.src;
	$('loading').style.display = 'none';
	if($('gallPause').value == 0){
	 setT = setTimeout("showPicture();",$('delaySec').value * 1000);
	}
	
}

function showPrev(){
   clearTimeout(setT);
   $('selPicId').value = $('prevPicId').value;
   showPicture();
}
function showNext(){
   clearTimeout(setT);
   $('selPicId').value = $('nextPicId').value;
   showPicture();
}

function changeDelay(mode){
   var delay = parseInt($('delaySec').value);
   if(mode == 1){
     delay +=  1;
   }
   else{
     if(delay != 1){
       delay -= 1;
	 }
   }
   $('delaySec').value = delay;
   $('delayText').innerHTML = $('delaySec').value;
}

function pauseGallery(){
    if($('gallPause').value == 1){
       $('gallPause').value = 0;
       showPicture();
    }
	else{
       $('gallPause').value = 1; 
	   clearTimeout(setT);
	}
    
}

function stopGal(){
	clearTimeout(setT);
    $('selPageId').value = '';
    $('selPicId').value = '';
    $('prevPicId').value = '';
	$('nextPicId').value = '';
	$('gallPause').value = '0';
	$('move').value = '1';
    $('delaySec').value = '3';
   //$('headerPic').style.display = '';
	Effect.Shrink('dispGalleryDiv');
	//alert($('menuLink').value);
	//window.location.href=rootPath + $('menuLink').value + ".html";
}


function move(moveVal){
  clearTimeout(setT);
  $('move').value = moveVal;
  showPicture();
}
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    //if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
   // } else {
      //  opacity(id, 100, 0, millisec);
    //}
}

function shiftOpacityLink(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
   // if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    //} else {
      //  opacity(id, 100, 0, millisec);
   //}
} 

function shiftOpacityLinkInv(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
   // if(document.getElementById(id).style.opacity == 0) {
        //opacity(id, 0, 100, millisec);
    //} else {
        opacity(id, 100, 0, millisec);
   //}
} 

/*function checkval()
{
	var x;
	x="";
	
	if ($('multyfamily').checked==true)
	{
		x+="multyfamily";
		alert(x);
	}
	if ($('office').checked==true)
	{
		x+=",office";
		alert(x);
	}
	if ($('office').checked==true)
	{
		x+=",office";
		alert(x);
	}
	if ($('office').checked==true)
	{
		x+=",office";
		alert(x);
	}
	if ($('office').checked==true)
	{
		x+=",office";
		alert(x);
	}
	if ($('office').checked==true)
	{
		x+=",office";
		alert(x);
	}
	if ($('office').checked==true)
	{
		x+=",office";
		alert(x);
	}
	if ($('office').checked==true)
	{
		x+=",office";
		alert(x);
	}
}*/
function showDetailspro(pType,start) {
	showLoader(1);
	var x;
	x="";
	
	if ($('multyfamily').checked==true)
	{
		x+="multyfamily,";
		//alert(x);
	}
	if ($('office').checked==true)
	{
		x+="office,";
		//alert(x);
	}
	if ($('industrial').checked==true)
	{
		x+="industrial,";
		//alert(x);
	}
	if ($('retail').checked==true)
	{
		x+="retail,";
		//alert(x);
	}
	if ($('shopCenter').checked==true)
	{
		x+="shopCenter,";
		//alert(x);
	}
	if ($('land').checked==true)
	{
		x+="land,";
		//alert(x);
	}
	if ($('agricultural').checked==true)
	{
		x+="agricultural,";
		//alert(x);
	}
	if ($('hotelMotel').checked==true)
	{
		x+="hotelMotel,";
		//alert(x);
	}
	if ($('seniorHouse').checked==true)
	{
		x+="seniorHouse,";
		//alert(x);
	}
	if ($('healthCare').checked==true)
	{
		x+="healthCare,";
		//alert(x);
	}
	if ($('sportEnt').checked==true)
	{
		x+="sportEnt,";
		//alert(x);
	}
	if ($('specialPur').checked==true)
	{
		x+="specialPur,";
		//alert(x);
	}
	/*if ($('resiIncome').checked==true)
	{
		x+="resiIncome,";
		//alert(x);
	}*/
	var url = "propertylistAjax.php";
	var myAjax = new Ajax.Request(url,
		 {
		  method: 'post', 
		  parameters: {exvar:x,propType:pType,start:start},
		  onComplete: ajaxresponseShow
		 }
	   );
}
function showDetailspro1(pType,start)
{
	showLoader(1);
	var rad = document.getElementsByName("propClas");
		
		for (i = 0; i < rad.length; i++)
		{
			if(rad[i].checked == true){
			var x = rad[i].value;
			}
		}
	var url = "propertylistAjax.php";
	var myAjax = new Ajax.Request(url,
		 {
		  method: 'post', 
		  parameters: {exvar:x,propType:pType,start:start},
		  onComplete: ajaxresponseShow
		 }
	   );
}
