// JavaScript Document
var arrinpbetween=new Array();
var systemwhat;
var systemsearch='basic';
var ximausa_login_name= Ext.util.Cookies.get("ximausa_login_name");
var ximausa_login_pass= Ext.util.Cookies.get("ximausa_login_pass");
if(Ext.isEmpty(ximausa_login_name)){
	ximausa_login_name='';
	ximausa_login_pass='';
}

var todaycount=new Date()
var christmas=new Date(2011, 0, 1) //Month is 0-11 in JavaScript
//if (todaycount.getMonth()==11 && todaycount.getDate()>25) //if Christmas has passed already
//christmas.setFullYear(christmas.getFullYear()+1) //calculate next year's Christmas
//Set 1 day in milliseconds
var one_day=1000*60*60*24
//Calculate difference btw the two dates, and convert to days
var COUNTDOWNSYSTEM=Math.ceil((christmas.getTime()-todaycount.getTime())/(one_day))-1;

var login_win=new Ext.Window({
	 width:435,
	 height:245,
	 resizable: false,
	 modal: true,
	 border:false,
	 closable:false,
	 plain: true,
	 listeners: {beforeshow: function(win){document.getElementById('login_error_msg').style.display='none'; win.center();}},
	 html:'<div style="background: url(../../../../../img/bkgd_login.jpg) repeat-x #95bed4; width:425px; height:255px; font-family:Arial,Helvetica,Tahoma,Verdana,sans-serif;">	<div style="color:#FFF;font-size:18px;font-weight:bold;padding:0 10px 5px; height:30px;text-align:left;"><div style="float:left; width:90%;">Log In</div><div align="right" style="float:right; width:10%; padding-top:3px;"><img src="../../../../../img/close.gif" style="cursor:pointer;" onClick="login_win.hide();"></div></div><div style="border: #237aa7 solid 1px; background:#fff;font-size:12px;line-height:14px;margin:0px 10px;padding:15px; color:#000; height:145px;"><form action="go.php" method="post" name="ximausa_login"><div style="padding-bottom:10px; font-size:11px; text-align:left;"><label style="float:left;font-weight:bold;padding:5px 0 0;width:120px;vertical-align:middle;">Email:</label><input value="'+ximausa_login_name+'" type="text" name="user" id="user" style="width:230px;font-size:11px;vertical-align:middle;"></div><div style="padding-bottom:10px; font-size:11px; text-align:left;"><label style="float:left;font-weight:bold;padding:5px 0 0;width:120px;">Password:</label><input type="password" name="pass" id="pass" value="'+ximausa_login_pass+'" style="width:230px;font-size:11px;vertical-align:middle;"></div><div id="login_error_msg" align="center" style="padding-bottom:0px; border:none; margin:0px; font-weight:bold; color:#F00; font-size:10px; display:none;"></div><div align="center" style="font-weight:bold;font-size:11px;"><input name="login_guardar" id="login_guardar" type="checkbox" value="true" checked style=" margin-bottom:0px; height: 12px;"> Remember Me</div><div align="center" style="padding-bottom:15px;border:none; margin:0px; font-weight:bold; color:#237aa7;font-size:11px;"><span style="color:#333;">Not registered?.</span> <a href="register.php">Register Now! </a><span style="color:#333;">||</span><a href="forgot_pass.php" target="_blank" onClick="window.open(this.href,this.target,\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no resizable=no,copyhistory=no,height=300,width=350,left=505,top=380\'); return false;">Forgot Password</a></div><div align="right"> <a href="javascript:void(0);" onClick="systemwhat=1;check_contract(\'check\');return false;" ><img  border=0 src="../../../../../img/blogin3.png" value="Multifamiliar - Comercial"></a></div></form></div></div>'
});

var countdowm_win=new Ext.Window({
	 width:430,
	 height:205,
	 resizable: false,
	 modal: true,
	 border:false,
	 closable:false,
	 plain: true,
	 listeners: {beforeshow: function(win){document.getElementById('login_error_msg').style.display='none'; win.center();}},
	 html:'<div style="background: url(../../../../../img/bkgd_login.jpg) repeat-x #95bed4; width:425px; height:200px; font-family:Arial,Helvetica,Tahoma,Verdana,sans-serif;">	<div style="color:#FFF;font-size:18px;font-weight:bold;padding:0 10px 5px; height:30px;text-align:left;"><div style="float:left; width:90%;">Information</div><div align="right" style="float:right; width:10%; padding-top:3px;"><img src="../../../../../img/close.gif" style="cursor:pointer;" onClick="hidecountdowm()"></div></div><div style="border: #237aa7 solid 1px; background:#fff;font-size:12px;line-height:14px;margin:0px 10px;padding:15px; color:#000; height:120px;"><div style="padding-bottom:10px; font-size:14px; font-weight:bold; text-align:CENTER;">Please be informed that this version will cease to work on <span style="color: #F00">January 1st 2011</span>. We recommend you to  use the <span style="color: #F00">New version.</span></div><div id="login_error_msg" align="center" style="padding-bottom:0px; border:none; margin:0px; font-weight:bold; color:#F00; font-size:10px; display:none;"></div><div align="center" style="font-weight:bold;font-size:11px;"></div><div align="center" style="color:#F00; font-weight:bold;font-size:22px; height:30px;padding-top:15px;"> DAYS: '+COUNTDOWNSYSTEM+' </div><div align="right" style="color:#F00; font-weight:bold;font-size:22px; height:20px;padding-top:5px;"> <input name="botok" type="button" value="Close" onClick="hidecountdowm()"/> </div></div></div>'
});

var login_win_allcounty=new Ext.Window({
	 width:550,
	 height:420,
	 resizable: false,
	 modal: true,
	 border:false,
	 closable:false,
	 plain: true,
	 listeners: {beforeshow: function(win){win.center();}},
	 autoLoad: {url: 'mysetting_tabs/myaccount_tabs/allcountyactive.php', scripts:true}
});

var login_win_commercial=new Ext.Window({
	 width:550,
	 height:450,
	 resizable: false,
	 modal: true,
	 border:false,
	 closable:false,
	 plain: true,
	 listeners: {beforeshow: function(win){win.center();}},
	 autoLoad: {url: 'mysetting_tabs/myaccount_tabs/commercialactiveask.php', scripts:true}
});

var contract_win=new Ext.Window({
	 width:650,
	 height:430,
	 resizable: false,
	 modal: true,
	 border:false,
	 closable:true,
	 closeAction: 'hide',
	 plain: true,
	 listeners: { 
	 	'beforehide': function (panel){
			loading_win.hide();
		}
	 },
	 html:'<div style="background: url(../../../../../img/bkgd_login.jpg) repeat-x #95bed4; width:638px; height:500px; font-family:Arial,Helvetica,Tahoma,Verdana,sans-serif;">	<div style="color:#FFF;font-size:18px;font-weight:bold;padding:0 10px 5px; height:30px;text-align:left;">    	<div style="float:left; width:90%;">Read Terms and Conditions</div></div><div style="border: #237aa7 solid 1px; background:#fff;font-size:12px;line-height:14px;margin:0px 10px;padding:15px; color:#000; height:260px;"><div style="padding-bottom:10px; font-size:11px; text-align: justify;"><label style="padding:0;width:230px;vertical-align:middle;">Because of recent upgrades to our system and the future nationwide coverage of our service, we decided to choose a more appropriate domain name for the system.  The new domain name <span style="color:#F00;">"REIFAX.com"</span> <span style="font-weight:bold;">(Real Estate Investment Property FAX)</span> better exemplifies the commitment we have to providing timely and factual information to help our users in making critical investment decisions.  The new name further shows our continued commitment to expanding services and the data delivery we are now providing to our clients.<br><br>Just as recent examples of some of these changes, our <span style="font-weight:bold; color:#F00;">Platinum Version</span> now includes the following:<br>1. New advanced search parameters to find prospects more quickly.<br>2. Probate listings &shy; no more going to the court and searching endless reams of documents.<br>3. FAR/BAR Contracts that auto-fill with the information from the public record.<br>4. E-signatures for these Contracts <span style="color:#F00;">(coming soon)</span>.<br>5. Sorting for <span style=" font-weight:bold;">"Cash Buyers"</span> to find these elusive buyers <span style="color:#F00;">(coming soon)</span>.<br>6. And many more tools to simplify finding prospective sellers and buyers.<br><br>This Domain Change Wont\' affect Your current price, plan, billing cycle or affiliated marketing program, all data will be updated only in the new domain <a href="index.php" target="_blank" >www.reifax.com</a><br><br>To be able to login you have to accept this<a href="http://www.reifax.com/TermsAndConditions.pdf" style="padding-left:10px;" target="_blank" >Read Terms and Conditions</a>. After accepting, please save the new page in your preferences.</label></div><br><div><a href="javascript:void(0);" onClick="check_contract(\'update\'); return false;" ><img  border=0 src="../../../../../img/accept.png" value="Accept"></a></div></div>'
});

var loading_win=new Ext.Window({
     width:170,
     autoHeight: true,
     resizable: false,
     modal: true,
     border:false,
     closable:false,
     plain: true,
     html:'<div style="background-color: #fff; color:#6593cf; font-weight:bold; font-family:Arial,Helvetica,Tahoma,Verdana,sans-serif;"><div style="float:left;"><img src="../../../../../img/loading.gif"/></div><div style="float:left; margin:0 auto; padding-top:10px">Please wait, loading!...</div></div>'
});

var lsImgCss={
'A-F':{'img':'verdel.png','explain':'Active Foreclosed'},
'A-F-S':{'img':'verdel_s.png','explain':'Active Foreclosed Sold'},
'A-P':{'img':'verdel.png','explain':'Active Pre-Foreclosed'},
'A-P-S':{'img':'verdel_s.png','explain':'Active Pre-Foreclosed Sold'},	
'A-N':{'img':'verdeb.png','explain':'Active'},
'A-N-S':{'img':'verdeb_s.png','explain':'Active Sold'},
'P-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'P-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'},
'P-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'P-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'P-N': {'img':'grisb.png','explain':'Non-Active'},
'P-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'CC-F': {'img':'cielol.png','explain':'By Owner Foreclosed'},
'CC-F-S': {'img':'cielol_s.png','explain':'By Owner Foreclosed Sold'},
'CC-P': {'img':'cielol.png','explain':'By Owner Pre-Foreclosed'},
'CC-P-S': {'img':'cielol_s.png','explain':'By Owner Pre-Foreclosed Sold'},
'CC-N': {'img':'cielo.png','explain':'By Owner'},
'CC-N-S': {'img':'cielo_s.png','explain':'By Owner Sold'},
'CS-P': {'img':'marronl.png','explain':'Closed Sale Pre-Foreclosed'},
'CS-P-S': {'img':'marronl_s.png','explain':'Closed Sale Pre-Foreclosed Sold'},
'CS-F': {'img':'marronl.png','explain':'Closed Sale Foreclosed'},
'CS-F-S': {'img':'marronl_s.png','explain':'Closed Sale Foreclosed Sold'},
'CS-N': {'img':'marronb.png','explain':'Closed Sale'},
'CS-N-S': {'img':'marronb_s.png','explain':'Closed Sale Sold'},
'PS-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'PS-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'PS-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'PS-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'},
'PS-N': {'img':'grisb.png','explain':'Non-Active'},
'PS-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'SP-': {'img':'grisdiamante.png','explain':'Unknow'},
'T-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'T-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'T-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'T-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'},
'T-N': {'img':'grisb.png','explain':'Non-Active'},
'T-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'R-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'R-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'R-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'R-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'},
'R-N': {'img':'grisb.png','explain':'Non-Active'},
'R-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'E-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'E-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'E-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'E-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'},
'E-N': {'img':'grisb.png','explain':'Non-Active'},
'E-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'C-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'C-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'C-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'C-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'},
'C-N': {'img':'grisb.png','explain':'Non-Active'},
'C-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'Q-N': {'img':'grisb.png','explain':'Non-Active'},
'Q-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'Q-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'Q-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'Q-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'Q-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'},
'W-N': {'img':'grisb.png','explain':'Non-Active'},
'W-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'W-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'W-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'},
'W-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'W-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'X-N': {'img':'grisb.png','explain':'Non-Active'},
'X-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'X-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'X-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'X-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'X-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'},
'SUBJECT': {'img':'verdetotal.png','explain':'Subject'},
'USER_CAR': {'img':'xxima.png','explain':'User'},
'B-N': {'img':'grisb.png','explain':'Non-Active'},
'B-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'B-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'B-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'B-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'B-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'},
'N-N': {'img':'grisb.png','explain':'Non-Active'},
'N-N-S': {'img':'grisb_s.png','explain':'Non-Active Sold'},
'N-P': {'img':'grisl.png','explain':'Non-Active Pre-Foreclosed'},
'N-P-S': {'img':'grisl_s.png','explain':'Non-Active Pre-Foreclosed Sold'},
'N-F': {'img':'grisl.png','explain':'Non-Active Foreclosed'},
'N-F-S': {'img':'grisl_s.png','explain':'Non-Active Foreclosed Sold'}};
var indImgCss='';

function getCasita(status,pendes,sold)
{
		if(pendes=='L') pendes='N';
		if(sold=='S') sold='-S'; else sold='';
			switch (status.toUpperCase())
			{
				case "A":
					indImgCss="A-"+pendes+sold;					
					break;
				case "P":
					indImgCss="P-"+pendes+sold;
					break;
				case "CC":				
					indImgCss="CC-"+pendes+sold;
					break;
				case "CS":				
					indImgCss="CS-"+pendes+sold;
					break;
				case "PS":
					indImgCss="PS-"+pendes+sold;
					break;
				case "SP":
					indImgCss="SP-"+pendes+sold;
					break;
				case "T":
					indImgCss="T-"+pendes+sold;
					break;
				case "R":
					indImgCss="R-"+pendes+sold;
					break;
				case "E":
					indImgCss="E-"+pendes+sold;
					break;
				case "C":
					indImgCss="C-"+pendes+sold;
					break;
				case "Q":
					indImgCss="Q-"+pendes+sold;
					break;
				case "R":
					indImgCss="R-"+pendes+sold;
					break;
				case "T":
					indImgCss="T-"+pendes+sold;
					break;
				case "W":
					indImgCss="W-"+pendes+sold;
					break;
				case "X":
					indImgCss="X-"+pendes+sold;
					break;
				case "B":
					indImgCss="B-"+pendes+sold;
					break;
				case "N":
					indImgCss="N-"+pendes+sold;
					break;
				case "SUBJECT":
					indImgCss="SUBJECT";break
			}

	
}

function formatCurrency(num,dec_if) 
{
	if(num || num==0 || num=='0')
	{
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		if(dec_if)
			return (((sign)?'':'-') + num + '.' + cents);
		else
			return (((sign)?'':'-') + num);
	}
}


function imagen_grid(status,pendes){
	if(status=='CS'){
		if(pendes!='N')
			return 'marronl.png';
		else
			return 'marronb.png';
	}else{
		if(pendes!='N')
			return 'cielol.png';
		else
			return 'cielo.png';
	}
}

function OnObliqueEnterHandler()
{
	if(mapOverview.IsBirdseyeAvailable()){
		mapOverview.SetBirdseyeScene(SpaceNeedle,VEOrientation.North,1);
	}else{
		mapOverview.SetMapStyle(VEMapStyle.Aerial);
	}
}
	 
function change_value_img(slider,val){
	document.getElementById('img_data').src=img_src[val];
}

function check_contract(action){
	loading_win.show();
	
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_contract.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			user: document.getElementById('user').value,
			pass: document.getElementById('pass').value,
			action: action
		},
		
		failure:function(response,options){
			loading_win.hide();
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			
			var results=response.responseText;
			
			if(results=='go'){
				contract_win.hide();
				ajax_submit();
			}else{ 
				if(results=='error'){
					document.getElementById('login_error_msg').innerHTML='Your email or password is incorrect!';
					document.getElementById('login_error_msg').style.display='';
					loading_win.hide();
				}else{
					contract_win.show();
				}
			}
			
			return false;
		}                                
	});
}

function hidecountdowm()
{
	countdowm_win.hide(); 
	if(systemwhat==0)
		location.href='pagmenu1.php';
}

function ajax_submit(){
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_validacion.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			user: document.getElementById('user').value,
			pass: document.getElementById('pass').value,
			check: document.getElementById('login_guardar').checked, 
			systemwhat: systemwhat
		},
		
		failure:function(response,options){
			loading_win.hide();
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			
			var results=response.responseText.split('^');
			//alert(results);
			if(results[0]==true || results[0]=='true')
			{
				if(results[3]=='freeze' || results[3]=='inactive')
					login_menu(results[1],results[2],true,false,results[7],results[8]);
				else
				{
					if(systemwhat==1)
					{
						if(results[5]==1)//ask for all county promotion
							login_win_allcounty.show(); 
						else if(results[6]==0)//ask for commercial version
							login_win_commercial.show(); 
						
						if(results[3]=='realtorweb' && results[4]==0){
							login_menu(results[1],results[2],false,true,results[7],results[8]);
						}else
							login_menu(results[1],results[2],false,false,results[7],results[8]);
							
						if(results[3]=='investorweb' && results[4]==0){
							login_menu(results[1],results[2],false,true,results[7],results[8]);
						}else
							login_menu(results[1],results[2],false,false,results[7],results[8]);	
							
						document.getElementById('login_error_msg').style.display='none';
					}
					else
					{
						if(results[5]==1)//ask for all county promotion
							login_win_allcounty.show(); 
						else if(results[6]==0)//ask for commercial version
							login_win_commercial.show(); 
						else countdowm_win.show(); 
						//else location.href='pagmenu1.php';
					}					
				}
			}
			else
			{
				if(results[1]=='logeado'){
					if(confirm("You did not log off or have another sesion opened. To continue and close the other sesion click 'OK'.")){
						session_release_with_data(document.getElementById('user').value,document.getElementById('pass').value);
					}
				}else{
					document.getElementById('login_error_msg').innerHTML=results[1];
					document.getElementById('login_error_msg').style.display='';
					//alert(results[1]);
				}
				loading_win.hide();
			}
			
			
			return false;
		}                                
	});
}

function ajax_submit_loged(userid){
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_validacion.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			userid: userid,
			systemwhat: systemwhat
		},
		
		failure:function(response,options){
			loading_win.hide();
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			
			var results=response.responseText.split('^');
           //alert(results);  
            			  
			if(results[0]==true || results[0]=='true')
			{    
				if(results[3]=='freeze' || results[3]=='inactive'){
					login_menu(results[1],results[2],true,false,results[7],results[8]);
				}else{
					if(systemwhat==1)
					{
						if(results[3]=='realtorweb' && results[4]==0)
							login_menu(results[1],results[2],false,true,results[7],results[8]);
						else
							login_menu(results[1],results[2],false,false,results[7],results[8]);
						if(document.getElementById('login_error_msg')) document.getElementById('login_error_msg').style.display='none';
						if(results[3]=='investorweb' && results[4]==0)
							login_menu(results[1],results[2],false,true,results[7],results[8]);
						else
							login_menu(results[1],results[2],false,false,results[7],results[8]);
										
					}
					else
						location.href='pagmenu1.php';
				}
				
			}
			else
			{
				if(results[1]=='logeado'){
					if(confirm("You did not log off or have another sesion opened. To continue and close the other sesion click 'OK'.")){
						session_release_with_data_id(userid);
					}
				}else{
					document.getElementById('login_error_msg').innerHTML=results[1];
					document.getElementById('login_error_msg').style.display='';
					//alert(results[1]);
				}
				loading_win.hide();
			}
			
			
			return false;
		}                                
	});
}

function login_menu(name,useridlog,tipo_login,publicidad,blocktab,tipo_user){
	user_loged=true;
	useridlogin=useridlog;
	user_name_menu=name;
	 
	
	var west = Ext.getCmp('west_panel');
	var east = Ext.getCmp('east_panel');
	var south = Ext.getCmp('south_panel');
	
	if(!publicidad){
		west.collapse();
		east.collapse();
		south.collapse();

		tabs.setWidth(system_width);
		//tabs.setHeight(580);
		//viewport.setHeight(650);
		document.getElementById('layout_center').style.width= system_width;
	}
			
	document.getElementById('top_m_reg').style.display='none';
	document.getElementById('top_m_login').style.display='none';
	document.getElementById('top_m_user_name').innerHTML=name+' ('+useridlog+')';
	document.getElementById('top_m_user').style.display='';
	var tab = tabs.getItem('myaccountTab');
	if(tab)
		document.getElementById('top_m_logout').style.display='';
	
	loading_win.hide();
	login_win.hide();
	
	restarTabs(tipo_login,blocktab,tipo_user);
	//location.href='http://www.reifax.com/properties_search.php?fromother=true';
}

function restarTabs(tipo_login,blocktab2,tipo_user){
	tabs.removeAll();
	
	tabs.add({
				title: ' My Settings ',
				id: 'settingTab',
				width: 660,
				autoLoad: {url: 'properties_settings.php', timeout: 10800, scripts:true}
			  });
	
	search_type='PR';
	search_by_type='LOCATION';
	search_state='FL';
	search_county='1';
	master_web=false;
	
	//alert(blocktab2);
			
	 if (blocktab2==1){
	tabs.add({
				title: ' By Owner ',
				width: 660,
				id: 'byownerTab',
				autoLoad: {url: 'byowner/properties_byowner.php', timeout: 10800, scripts: true, params: {tipo_login: tipo_login,userweb:user_web, search_type: search_type, search_by_type: search_type, state_search: search_state, county_search: search_county}}
			  });
			  
	 }
	
	tabs.add({
				title: ' Search ',
				width: 660,
				id: 'searchTab',
				autoLoad: {url: 'properties_searchBasAdv.php', timeout: 10800, scripts: true, params: {tipo_login: tipo_login,userweb:user_web, search_type: search_type, search_by_type: search_type, state_search: search_state, county_search: search_county, masterweb:master_web,tipouser:tipo_user}}
			  });	
	
	if(!tipo_login)
	     if (blocktab2!=1){tabs.setActiveTab(1);}else{ tabs.setActiveTab(2);}
      	else
		tabs.setActiveTab(0); 
	 
}

function logout_menu(){
	user_loged=false;
	
	document.getElementById('top_m_reg').style.display='';
	document.getElementById('top_m_login').style.display='';
	document.getElementById('top_m_user').style.display='none';
	document.getElementById('top_m_logout').style.display='none';
	
	var west = Ext.getCmp('west_panel');
	var east = Ext.getCmp('east_panel');
	var south = Ext.getCmp('south_panel');
	
	if(document.body.offsetWidth >= 1200){
		west.expand(false);
	}
	east.expand(false);
	south.expand(false);

	tabs.setWidth(660,2350);
	/*tabs.setHeight(1300);
	viewport.setHeight(1500);*/
}

function ajax_submit_advertising(){
	
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_validacion.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			user: document.getElementById('advertising_user').value,
			pass: document.getElementById('advertising_pass').value	
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			
			var results=response.responseText;
			//alert(results);
			eval(results);
			return false;
		}                                
	});
}

function session_release(){
	
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_releaseSess.php', 
		method: 'POST',
		timeout :600000,
		params: { 
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			
			var results=response.responseText;
			if(user_loged) 	location.href='properties_search.php';
			else logout_menu();
			return false;
		}                                
	});
}

function session_release_with_data_id(userid){
	
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_releaseSess.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			userid: userid
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			ajax_submit_loged(userid);
		}                                
	});
}

function session_release_with_data(user,pass){
	
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_releaseSess.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			user: user,
			pass: pass
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			ajax_submit();
		}                                
	});
}

function valid_session(){
	
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_validSess.php', 
		method: 'POST',
		timeout :600000,
		params: { 
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			var results=response.responseText;
			//alert(results);
			if(results=='invalid'){
				Ext.MessageBox.alert('Warning','This sesion was closed as another became active.');
				session_release();
			}
		}                                
	});
}

function orderByResult(order,dir){
	
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_order_by_result.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			order: order+' '+dir
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			pagingResult(0);	
		}                                
	});
}

function orderBymylisting(order,dir,page,total){
	var orden = order+' '+dir;
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_order_by_mylisting.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			order: order+' '+dir,
			userweb:user_webid
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
	      pagingmylisting(page,total,orden);	
		  
		}                                
	});
}

function orderBymylistingweb(order,dir,page,total){
	var orden = order+' '+dir;
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_order_by_mylisting.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			order: order+' '+dir,
			userweb:master_webid
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
	      pagingmylistingweb(page,total,orden);	
		  
		}                                
	});
}
function createOverview(county,pid,astatus,realtor,compType,tipouser){
	window.scrollTo(0,0);
	var msg,idc='overviewTab',titlec=' Overview ',menuidc='menu_overview';
	 	  
		//website user,owner,master
	if(realtor==false) { 
		if(astatus == 'A') { var icon_mylis=false; } else { var icon_mylis=true; } // icon mylisting
	    
	    if(tipouser=="Investor"){ var icon_inv=false;  var icon_mylis=true;}
	    if(tipouser=="Realtor" ||tipouser=="RealtorWo" ){var icon_inv=true;}
	    if(tipouser=="Administrator" || tipouser=="Salesman" || tipouser=="Programmer" ){var icon_inv=false;  var icon_mylis=false;}
	    //alert(tipouser);
	
	}else{ var icon_mylis=true; var icon_ocultar=true; var icon_inv=true; }
	 
	
	 
	var url='properties_overview.php?county='+county+'&pid='+pid+'&astatus='+astatus;
	var tbar = new Ext.Toolbar({
			id:menuidc,
			cls: 'no-border',
			width: 'auto',
			items: [' ',
					{
					 tooltip: 'Click to View Legend',
					 iconCls:'icon',
					 iconAlign: 'top',
					 width: 40,
					 icon: 'http://www.ximausa.com/img/toolbar/legend.png',
					 scale: 'medium',
					 handler: function(){
						var dataLegend = [
							['S','http://www.ximausa.com/img/houses/verdetotal.png','Subject'],
							['A-F','http://www.ximausa.com/img/houses/verdel.png','Active Forclosed'],
							['A-F-S','http://www.ximausa.com/img/houses/verdel_s.png','Active Forclosed Sold'],
							['A-P','http://www.ximausa.com/img/houses/verdel.png','Active Pre-Forclosed'],
							['A-P-S','http://www.ximausa.com/img/houses/verdel_s.png','Active Pre-Forclosed Sold'],
							['A-N','http://www.ximausa.com/img/houses/verdeb.png','Active'],
							['CC-F','http://www.ximausa.com/img/houses/cielol.png','By Owner Forclosed'],
							['CC-F-S','http://www.ximausa.com/img/houses/cielol_s.png','By Owner Forclosed Sold'],
							['CC-P','http://www.ximausa.com/img/houses/cielol.png','By Owner Pre-Forclosed'],
							['CC-P-S','http://www.ximausa.com/img/houses/cielol_s.png','By Owner Pre-Forclosed Sold'],
							['CC-N','http://www.ximausa.com/img/houses/cielo.png','By Owner'],
							['CS-F','http://www.ximausa.com/img/houses/marronl.png','Closed Sale Forclosed'],
							['CS-F-S','http://www.ximausa.com/img/houses/marronl_s.png','Closed Sale Forclosed Sold'],
							['CS-P','http://www.ximausa.com/img/houses/marronl.png','Closed Sale Pre-Forclosed'],
							['CS-P-S','http://www.ximausa.com/img/houses/marronl_s.png','Closed Sale Pre-Forclosed Sold'],
							['CS-N','http://www.ximausa.com/img/houses/marronb.png','Closed Sale'],
							['N-F','http://www.ximausa.com/img/houses/grisl.png','Non-Active Forclosed'],
							['N-F-S','http://www.ximausa.com/img/houses/grisl_s.png','Non-Active Forclosed Sold'],
							['N-P','http://www.ximausa.com/img/houses/grisl.png','Non-Active Pre-Forclosed'],
							['N-P-S','http://www.ximausa.com/img/houses/grisl_s.png','Non-Active Pre-Forclosed Sold'],
							['N-N','http://www.ximausa.com/img/houses/grisb.png','Non-Active']
						];
						 
						 var store = new Ext.data.ArrayStore({
							fields: [
								'status', 'url', 'description'
							]
						 });
						
						store.loadData(dataLegend);
						
						 var listView = new Ext.list.ListView({
							store: store,
							multiSelect: false,
							emptyText: 'No Legend to display',
							columnResize: false,
							columnSort: false,
							columns: [{
								header: 'Color',
								width: .15,
								dataIndex: 'url',
								tpl: '<img src="{url}">'
							},{
								header: 'Status',
								width: .2,
								dataIndex: 'status'
							},{
								header: 'Description',
								dataIndex: 'description'
							}]
						});
						
						var win = new Ext.Window({
							
							layout      : 'fit',
							width       : 370,
							height      : 300,
							modal	 	: true,
							plain       : true,
							items		: listView,
				
							buttons: [{
								text     : 'Close',
								handler  : function(){
									win.close();
								}
							}]
						});
						win.show();
					 }
				},{
					 tooltip: 'Click to Property Analisys',
					 //text: 'Property Analisys',
					 iconCls:'icon',
					 iconAlign: 'top',
					 width: 40,
					 icon: 'http://www.ximausa.com/img/ximaicon/ssale.png',
					 scale: 'medium',
					 hidden: icon_ocultar,
					 handler: function(){
						 if(document.getElementById('reportsTab')){
							 var tab = tabs.getItem('reportsTab');
							 tabs.remove(tab);
						 }
						 if(!user_loged){ login_win.show(); return false;}
						 else if(user_block || user_web){Ext.Msg.alert('Warning', 'You are either not logged in or are not allowed to view detailed information.'); return false;}

						var win = new Ext.Window({		
							layout      : 'fit',
							title: 'PAR Selections',
							width       : 180,
							height      : 360,
							modal	 	: true,
							plain       : true,
							bodyStyle: 'text-align:left; padding-left:5px;',
							items		: new Ext.form.CheckboxGroup({
								xtype: 'checkboxgroup',
								id: 'checkboxpar',
								fieldLabel: 'Tabs',
								itemCls: 'x-check-group-alt',
								columns: 1,
								items: [
									{boxLabel: 'Details', name: 'detail', checked: true},
									{boxLabel: 'Listing', name: 'listing', checked: true},
									{boxLabel: 'Rental', name: 'rental', checked: true},
									{boxLabel: 'Pictures', name: 'picture', checked: true},
									{boxLabel: 'Comparables', name: 'comparable', checked: true},
									{boxLabel: 'Comp. Active', name: 'compactive', checked: true},
									{boxLabel: 'Distress', name: 'compdistress', checked: true},
									{boxLabel: 'Comp. Rental', name: 'comprental', checked: true},
									{boxLabel: 'Mortgage', name: 'mortgage', checked: true},
									{boxLabel: 'Foreclosures', name: 'foreclosure', checked: true},
									{boxLabel: 'Map', name: 'map', checked: true},
									{boxLabel: 'XRay', name: 'xray', checked: true}
								]
							}),
						
							buttons: [{
								text     : 'Close',
								handler  : function(){
									win.close();
								}
							},{
								text     : 'Apply',
								handler  : function(){
									var acheck = Ext.getCmp('checkboxpar').getValue();
									var cde = cli = cre = cpi = cco = cca = ccd = ccr = cmo = cfo = cma = cxr = false;
									
									for(var j=0; j<acheck.length; j++){
										if(acheck[j].getName()=='detail') cde=true;
										if(acheck[j].getName()=='listing') cli=true;
										if(acheck[j].getName()=='rental') cre=true;
										if(acheck[j].getName()=='picture') cpi=true;
										if(acheck[j].getName()=='comparable'){ 
											cco=true;
											var parcelids_cco='';
											if(smComp){
												if(!AllCheckComp){
													var comparables = smComp.getSelections();
													if(comparables.length > 0){
														parcelids_cco='\''+comparables[0].get('pid')+'\'';
														for(i=1; i<comparables.length; i++){
															parcelids_cco+=',\''+comparables[i].get('pid')+'\'';
														}
													}
												}	
											}
										}
										if(acheck[j].getName()=='compactive'){ 
											cca=true;
											var parcelids_cca='';
											if(smActive){
												if(!AllCheckActive){
													var comparables = smActive.getSelections();
													if(comparables.length > 0){
														parcelids_cca='\''+comparables[0].get('pid')+'\'';
														for(i=1; i<comparables.length; i++){
															parcelids_cca+=',\''+comparables[i].get('pid')+'\'';
														}
													}
												}	
											}
										}
										if(acheck[j].getName()=='compdistress'){ 
											ccd=true;
											var parcelids_ccd='';
											if(smDistress){
												if(!AllCheckDistress){
													var comparables = smDistress.getSelections();
													if(comparables.length > 0){
														parcelids_ccd='\''+comparables[0].get('pid')+'\'';
														for(i=1; i<comparables.length; i++){
															parcelids_ccd+=',\''+comparables[i].get('pid')+'\'';
														}
													}
												}	
											}
										}
										if(acheck[j].getName()=='comprental'){ 
											ccr=true;
											var parcelids_ccr='';
											if(smRental){
												if(!AllCheckRental){
													var comparables = smRental.getSelections();
													if(comparables.length > 0){
														parcelids_ccr='\''+comparables[0].get('pid')+'\'';
														for(i=1; i<comparables.length; i++){
															parcelids_ccr+=',\''+comparables[i].get('pid')+'\'';
														}
													}
												}	
											}
										}
										if(acheck[j].getName()=='mortgage') cmo=true;
										if(acheck[j].getName()=='foreclosure') cfo=true;
										if(acheck[j].getName()=='map') cma=true;
										if(acheck[j].getName()=='xray') cxr=true;
									}
									win.close();
									
									tabs.add({
										title: ' Reports ',
										id: 'reportsTab',
										autoScroll: true,
										autoLoad: {url: 'reports_types/properties_par.php?db='+county+'&pid='+pid+'&detail='+cde+'&listing='+cli+'&rental='+cre+'&picture='+cpi+'&comparable='+cco+'&compactive='+cca+'&compdistress='+ccd+'&comprental='+ccr+'&mortgage='+cmo+'&foreclosure='+cfo+'&map='+cma+'&xray='+cxr, scripts: true, params:{parcelids_cco: parcelids_cco, parcelids_cca: parcelids_cca, parcelids_ccd: parcelids_ccd, parcelids_ccr: parcelids_ccr}, timeout: 10800},
										closable: true,
										tbar: new Ext.Toolbar({
											cls: 'no-border',
											width: 'auto',
											items: [' ',{
												 tooltip: 'Click to Print Property Analisys.',
												 iconCls:'icon',
												 iconAlign: 'top',
												 width: 40,
												 icon: 'http://www.ximausa.com/img/toolbar/printer.png',
												 scale: 'medium',
												 handler: function(){
													Ext.Ajax.request( 
													{  
														waitMsg: 'Printing...',
														url: 'imprimir/properties_par_print.php', 
														method: 'POST',
														timeout :600000,
														params: { 
															db: county,
															pid: pid,
															type: 'P',
															detail: cde,
															listing: cli,
															rental: cre,
															picture: cpi,
															comparable: cco,
															compactive: cca,
															compdistress: ccd,
															comprental: ccr,
															mortgage: cmo,
															foreclosure: cfo,
															map: cma,
															xray: cxr,
															parcelids_cco: parcelids_cco, 
															parcelids_cca: parcelids_cca, 
															parcelids_ccd: parcelids_ccd, 
															parcelids_ccr: parcelids_ccr
														},
														
														failure:function(response,options){
															loading_win.hide();
															Ext.MessageBox.alert('Warning','ERROR');
														},
														success:function(response,options){
															
															var results=response.responseText;
															if(Ext.isIE)
																window.open(results,null,'width='+screen.width+', height='+screen.height+', top=0, left=0, directories=no, location=no, menubar=yes, resizable=no, scrollbars=yes, status=no, toolbar=no, target=_newtab');
															 else
																window.open(results,'_newtab');
														}                                
													});
												 }
											},{
												 tooltip: 'Click to Save Property Analisys.',
												 iconCls:'icon',
												 iconAlign: 'top',
												 width: 40,
												 icon: 'http://www.ximausa.com/img/toolbar/save.png',
												 scale: 'medium',
												 handler: function(){
													 var simple = new Ext.FormPanel({
														url: 'imprimir/properties_par_print.php',
														frame:true,
														title: 'Saved Documents.',
														width: 400,
														waitMsgTarget : 'Saving Documents...',
														
														items: [{
																	xtype     : 'textfield',
																	name      : 'name_save',
																	fieldLabel: 'Name',
																	value     : '',
																	width: 200
																},{
																	xtype     : 'hidden',
																	name      : 'db',
																	value     : county
																},{
																	xtype     : 'hidden',
																	name      : 'pid',
																	value     : pid
																},{
																	xtype     : 'hidden',
																	name      : 'type',
																	value     : 'S'
																},{
																	xtype     : 'hidden',
																	name      : 'detail',
																	value     : cde
																},{
																	xtype     : 'hidden',
																	name      : 'listing',
																	value     : cli
																},{
																	xtype     : 'hidden',
																	name      : 'rental',
																	value     : cre
																},{
																	xtype     : 'hidden',
																	name      : 'picture',
																	value     : cpi
																},{
																	xtype     : 'hidden',
																	name      : 'comparable',
																	value     : cco
																},{
																	xtype     : 'hidden',
																	name      : 'compactive',
																	value     : cca
																},{
																	xtype     : 'hidden',
																	name      : 'compdistress',
																	value     : ccd
																},{
																	xtype     : 'hidden',
																	name      : 'comprental',
																	value     : ccr
																},{
																	xtype     : 'hidden',
																	name      : 'mortgage',
																	value     : cmo
																},{
																	xtype     : 'hidden',
																	name      : 'foreclosure',
																	value     : cfo
																},{
																	xtype     : 'hidden',
																	name      : 'map',
																	value     : cma
																},{
																	xtype     : 'hidden',
																	name      : 'xray',
																	value     : cxr
																},{
																	xtype     : 'hidden',
																	name      : 'parcelids_cco',
																	value     : parcelids_cco
																},{
																	xtype     : 'hidden',
																	name      : 'parcelids_cca',
																	value     : parcelids_cca
																},{
																	xtype     : 'hidden',
																	name      : 'parcelids_ccd',
																	value     : parcelids_ccd
																},{
																	xtype     : 'hidden',
																	name      : 'parcelids_ccr',
																	value     : parcelids_ccr
																}
															],
														
														buttons: [{
																text: 'Save',
																handler: function(){
																	loading_win.show();
																	simple.getForm().submit({
																		success: function(form, action) {
																			loading_win.hide();
																			win.close();
																			Ext.Msg.alert("Saved Documents", 'Your document has been save.');
																		},
																		failure: function(form, action) {
																			loading_win.hide();
																			Ext.Msg.alert("Failure", action.result.msg);
																		}
																	});
																}
															},{
																text: 'Cancel',
																handler  : function(){
																		simple.getForm().reset();
																		win.close();
																	}
															}]
														});
													 
													var win = new Ext.Window({
														layout      : 'fit',
														width       : 400,
														height      : 170,
														modal	 	: true,
														plain       : true,
														items		: simple,
														closeAction : 'hide',
														buttons: [{
															text     : 'Close',
															handler  : function(){
																win.close();
															}
														}]
													});
													win.show();
												 }
											},'->',{
												 tooltip: 'Click to Close Reports',
												 iconCls:'icon',
												 iconAlign: 'top',
												 width: 40,
												 icon: 'http://www.ximausa.com/img/cancel.png',
												 scale: 'medium',
												  
												 handler: function(){
													 var tab = tabs.getItem('reportsTab');
													 tabs.remove(tab);
												 }
											}]
										})
									}).show();
								}
							}]
						});
						win.show();
					 }
				},{
					 tooltip: 'Click to BPO Report',
					 //text: 'BPO Report',
					 iconCls:'icon',
					 iconAlign: 'top',
					 width: 40,
					 icon: 'http://www.ximausa.com/img/ximaicon/bpo.png',
					 scale: 'medium',
					 hidden: icon_ocultar,
					 handler: function(){
						 if(document.getElementById('reportsTab')){
							 var tab = tabs.getItem('reportsTab');
							 tabs.remove(tab);
						 }
						 if(!user_loged){ login_win.show(); return false;}
						 else if(user_block || user_web){Ext.Msg.alert('Warning', 'You are either not logged in or are not allowed to view detailed information.'); return false;}
						  
						var parcelids_cco='';
						if(smComp){
							if(!AllCheckComp){
								var comparables = smComp.getSelections();
								if(comparables.length > 0){
									parcelids_cco='\''+comparables[0].get('pid')+'\'';
									for(i=1; i<comparables.length; i++){
										parcelids_cco+=',\''+comparables[i].get('pid')+'\'';
									}
								}
							}	
						}
						
						var parcelids_cca='';
						if(smActive){
							if(!AllCheckActive){
								var comparables = smActive.getSelections();
								if(comparables.length > 0){
									parcelids_cca='\''+comparables[0].get('pid')+'\'';
									for(i=1; i<comparables.length; i++){
										parcelids_cca+=',\''+comparables[i].get('pid')+'\'';
									}
								}
							}	
						}
						 
						tabs.add({
							title: ' Reports ',
							id: 'reportsTab',
							autoScroll: true,
							autoLoad: {url: 'reports_types/properties_bpo.php?db='+county+'&pid='+pid, scripts: true, params:{parcelids_cco: parcelids_cco, parcelids_cca: parcelids_cca}, timeout: 10800},
							closable: true,
							tbar: new Ext.Toolbar({
								cls: 'no-border',
								width: 'auto',
								items: [' ',{
									 tooltip: 'Click to Print BPO Report.',
									 iconCls:'icon',
									 iconAlign: 'top',
									 width: 40,
									 icon: 'http://www.ximausa.com/img/toolbar/printer.png',
									 scale: 'medium',
									 handler: function(){
										Ext.Ajax.request( 
										{  
											waitMsg: 'Printing...',
											url: 'imprimir/properties_bpo_print.php', 
											method: 'POST',
											timeout :600000,
											params: { 
												db: county,
												pid: pid,
												type: 'P',
												parcelids_cco: parcelids_cco, 
												parcelids_cca: parcelids_cca
											},
											
											failure:function(response,options){
												loading_win.hide();
												Ext.MessageBox.alert('Warning','ERROR');
											},
											success:function(response,options){
												
												var results=response.responseText;
												if(Ext.isIE)
													window.open(results,null,'width='+screen.width+', height='+screen.height+', top=0, left=0, directories=no, location=no, menubar=yes, resizable=no, scrollbars=yes, status=no, toolbar=no, target=_newtab');
												 else
													window.open(results,'_newtab');
											}                                
										});
									 }
								},{
									 tooltip: 'Click to Save BPO Report.',
									 iconCls:'icon',
									 iconAlign: 'top',
									 width: 40,
									 icon: 'http://www.ximausa.com/img/toolbar/save.png',
									 scale: 'medium',
									 handler: function(){
										 var simple = new Ext.FormPanel({
											url: 'imprimir/properties_bpo_print.php',
											frame:true,
											title: 'Saved Documents.',
											width: 400,
											waitMsgTarget : 'Saving Documents...',
											
											items: [{
														xtype     : 'textfield',
														name      : 'name_save',
														fieldLabel: 'Name',
														value     : '',
														width: 200
													},{
														xtype     : 'hidden',
														name      : 'db',
														value     : county
													},{
														xtype     : 'hidden',
														name      : 'pid',
														value     : pid
													},{
														xtype     : 'hidden',
														name      : 'type',
														value     : 'S'
													},{
														xtype     : 'hidden',
														name      : 'parcelids_cco',
														value     : parcelids_cco
													},{
														xtype     : 'hidden',
														name      : 'parcelids_cca',
														value     : parcelids_cca
													}],
											
											buttons: [{
													text: 'Save',
													handler: function(){
														loading_win.show();
														simple.getForm().submit({
															success: function(form, action) {
																loading_win.hide();
																win.close();
																Ext.Msg.alert("Saved Documents", 'Your document has been save.');
															},
															failure: function(form, action) {
																loading_win.hide();
																Ext.Msg.alert("Failure", action.result.msg);
															}
														});
													}
												},{
													text: 'Cancel',
													handler  : function(){
															simple.getForm().reset();
															win.close();
														}
												}]
											});
										 
										var win = new Ext.Window({
											layout      : 'fit',
											width       : 400,
											height      : 170,
											modal	 	: true,
											plain       : true,
											items		: simple,
											closeAction : 'hide',
											buttons: [{
												text     : 'Close',
												handler  : function(){
													win.close();
												}
											}]
										});
										win.show();
									 }
								},'->',{
									 tooltip: 'Click to Close Reports',
									 iconCls:'icon',
									 iconAlign: 'top',
									 width: 40,
									 icon: 'http://www.ximausa.com/img/cancel.png',
									 scale: 'medium',
									  
									 handler: function(){
										 var tab = tabs.getItem('reportsTab');
										 tabs.remove(tab);
									 }
								}]
							})
						}).show();
					 }
				},{
					 tooltip: 'Click to XRay Report',
					 //text: 'XRay Report',
					 iconCls:'icon',
					 iconAlign: 'top',
					 width: 40,
					 icon: 'http://www.ximausa.com/img/ximaicon/exray.png',
					 scale: 'medium',
					 hidden: icon_ocultar,
					 handler: function(){
						 if(document.getElementById('reportsTab')){
							 var tab = tabs.getItem('reportsTab');
							 tabs.remove(tab);
						 }
						 if(!user_loged){ login_win.show(); return false;}
						 else if(user_block || user_web){Ext.Msg.alert('Warning', 'You are either not logged in or are not allowed to view detailed information.'); return false;}
						 
						tabs.add({
							title: ' Reports ',
							autoScroll: true,
							id: 'reportsTab',
							autoLoad: {url: 'reports_types/properties_xray.php?db='+county+'&pid='+pid, scripts: true, timeout: 10800},
							closable: true,
							tbar: new Ext.Toolbar({
								cls: 'no-border',
								width: 'auto',
								items: [' ',{
									 tooltip: 'Click to Print XRay Report.',
									 iconCls:'icon',
									 iconAlign: 'top',
									 width: 40,
									 icon: 'http://www.ximausa.com/img/toolbar/printer.png',
									 scale: 'medium',
									 handler: function(){
										Ext.Ajax.request( 
										{  
											waitMsg: 'Printing...',
											url: 'imprimir/properties_xray_print.php', 
											method: 'POST',
											timeout :600000,
											params: { 
												db: county,
												pid: pid,
												type: 'P'
											},
											
											failure:function(response,options){
												loading_win.hide();
												Ext.MessageBox.alert('Warning','ERROR');
											},
											success:function(response,options){
												
												var results=response.responseText;
												if(Ext.isIE)
													window.open(results,null,'width='+screen.width+', height='+screen.height+', top=0, left=0, directories=no, location=no, menubar=yes, resizable=no, scrollbars=yes, status=no, toolbar=no, target=_newtab');
												 else
													window.open(results,'_newtab');
											}                                
										});
									 }
								},{
									 tooltip: 'Click to Save XRay Report.',
									 iconCls:'icon',
									 iconAlign: 'top',
									 width: 40,
									 icon: 'http://www.ximausa.com/img/toolbar/save.png',
									 scale: 'medium',
									 handler: function(){
										 var simple = new Ext.FormPanel({
											url: 'imprimir/properties_xray_print.php',
											frame:true,
											title: 'Saved Documents.',
											width: 400,
											waitMsgTarget : 'Saving Documents...',
											
											items: [{
														xtype     : 'textfield',
														name      : 'name_save',
														fieldLabel: 'Name',
														value     : '',
														width: 200
													},{
														xtype     : 'hidden',
														name      : 'db',
														value     : county
													},{
														xtype     : 'hidden',
														name      : 'pid',
														value     : pid
													},{
														xtype     : 'hidden',
														name      : 'type',
														value     : 'S'
													}],
											
											buttons: [{
													text: 'Save',
													handler: function(){
														loading_win.show();
														simple.getForm().submit({
															success: function(form, action) {
																loading_win.hide();
																win.close();
																Ext.Msg.alert("Saved Documents", 'Your document has been save.');
															},
															failure: function(form, action) {
																loading_win.hide();
																Ext.Msg.alert("Failure", action.result.msg);
															}
														});
													}
												},{
													text: 'Cancel',
													handler  : function(){
															simple.getForm().reset();
															win.close();
														}
												}]
											});
										 
										var win = new Ext.Window({
											layout      : 'fit',
											width       : 400,
											height      : 170,
											modal	 	: true,
											plain       : true,
											items		: simple,
											closeAction : 'hide',
											buttons: [{
												text     : 'Close',
												handler  : function(){
													win.close();
												}
											}]
										});
										win.show();
									 }
								},'->',{
									 tooltip: 'Click to Close Reports',
									 iconCls:'icon',
									 iconAlign: 'top',
									 width: 40,
									 icon: 'http://www.ximausa.com/img/cancel.png',
									 scale: 'medium',
									  
									 handler: function(){
										 var tab = tabs.getItem('reportsTab');
										 tabs.remove(tab);
									 }
								}]
							})
						}).show();
					 } 
				},{
					 tooltip: 'Click to Discount Report',
					 iconCls:'icon',
					 iconAlign: 'top',
					 width: 40,
					 icon: 'http://www.ximausa.com/img/toolbar/rebate.jpg',
					 scale: 'medium',
					 hidden: icon_ocultar,
					 handler: function(){
						 if(document.getElementById('reportsTab')){
							 var tab = tabs.getItem('reportsTab');
							 tabs.remove(tab);
						 }
						 if(!user_loged){ login_win.show(); return false;}
						 else if(user_block || user_web){Ext.Msg.alert('Warning', 'You are either not logged in or are not allowed to view detailed information.'); return false;}
						 
						tabs.add({
							title: ' Reports ',
							autoScroll: true,
							id: 'reportsTab',
							autoLoad: {url: 'reports_types/properties_rebate.php?db='+county+'&pid='+pid, scripts: true, timeout: 10800},
							closable: true,
							tbar: new Ext.Toolbar({
								cls: 'no-border',
								width: 'auto',
								items: [' ',{
									 tooltip: 'Click to Print Discount Report.',
									 iconCls:'icon',
									 iconAlign: 'top',
									 width: 40,
									 icon: 'http://www.ximausa.com/img/toolbar/printer.png',
									 scale: 'medium',
									 handler: function(){
										Ext.Ajax.request( 
										{  
											waitMsg: 'Printing...',
											url: 'imprimir/properties_rebate_print.php', 
											method: 'POST',
											timeout :600000,
											params: { 
												db: county,
												pid: pid,
												type: 'P'
											},
											
											failure:function(response,options){
												loading_win.hide();
												Ext.MessageBox.alert('Warning','ERROR');
											},
											success:function(response,options){
												
												var results=response.responseText;
												if(Ext.isIE)
													window.open(results,null,'width='+screen.width+', height='+screen.height+', top=0, left=0, directories=no, location=no, menubar=yes, resizable=no, scrollbars=yes, status=no, toolbar=no, target=_newtab');
												 else
													window.open(results,'_newtab');
											}                                
										});
									 }
								},{
									 tooltip: 'Click to Save Discount Report.',
									 iconCls:'icon',
									 iconAlign: 'top',
									 width: 40,
									 icon: 'http://www.ximausa.com/img/toolbar/save.png',
									 scale: 'medium',
									 handler: function(){
										 var simple = new Ext.FormPanel({
											url: 'imprimir/properties_rebate_print.php',
											frame:true,
											title: 'Saved Documents.',
											width: 400,
											waitMsgTarget : 'Saving Documents...',
											
											items: [{
														xtype     : 'textfield',
														name      : 'name_save',
														fieldLabel: 'Name',
														value     : '',
														width: 200
													},{
														xtype     : 'hidden',
														name      : 'db',
														value     : county
													},{
														xtype     : 'hidden',
														name      : 'pid',
														value     : pid
													},{
														xtype     : 'hidden',
														name      : 'type',
														value     : 'S'
													}],
											
											buttons: [{
													text: 'Save',
													handler: function(){
														loading_win.show();
														simple.getForm().submit({
															success: function(form, action) {
																loading_win.hide();
																win.close();
																Ext.Msg.alert("Saved Documents", 'Your document has been save.');
															},
															failure: function(form, action) {
																loading_win.hide();
																Ext.Msg.alert("Failure", action.result.msg);
															}
														});
													}
												},{
													text: 'Cancel',
													handler  : function(){
															simple.getForm().reset();
															win.close();
														}
												}]
											});
										 
										var win = new Ext.Window({
											layout      : 'fit',
											width       : 400,
											height      : 170,
											modal	 	: true,
											plain       : true,
											items		: simple,
											closeAction : 'hide',
											buttons: [{
												text     : 'Close',
												handler  : function(){
													win.close();
												}
											}]
										});
										win.show();
									 }
								},'->',{
									 tooltip: 'Click to Close Reports',
									 iconCls:'icon',
									 iconAlign: 'top',
									 width: 40,
									 icon: 'http://www.ximausa.com/img/cancel.png',
									 scale: 'medium',
									  
									 handler: function(){
										 var tab = tabs.getItem('reportsTab');
										 tabs.remove(tab);
									 }
								}]
							})
						}).show();
					 } 
				},{
				
					 tooltip: 'Click to Add properties to My Listing',
					 iconCls:'icon',
					 iconAlign: 'top',
					 width: 40,
					 icon: 'http://www.ximausa.com/img/toolbar/mylisting.png',
					 scale: 'medium',
					 hidden: icon_mylis,
					 
					 handler: function()
					 { 		
					 		 
						if(!user_loged){ login_win.show(); return false;}
						else if(user_block || user_web){Ext.Msg.alert('Warning', 'You are either not logged in or are not allowed to view detailed information.'); return false;}
						
						    Ext.Ajax.request({  
								waitMsg: 'Save My Listing...',
								url: 'mylisting/properties_mylisting.php', 
								method: 'POST', 
								params: { 
								db:county,
								pid:pid,
								astatus:astatus},
								
								success:function(response,options)
								{
									if(response.responseText== 'true' || response.responseText==true)
										Ext.Msg.alert('Mensaje', 'Property added successfully to My Listing.');
									else
										Ext.Msg.alert('Mensaje', response.responseText);
								},
								failure:function(response,options)
								{
									Ext.Msg.alert("Failure", response.responseText);
								}
								
																
						   });//ajax                 
					 }//hander
				  },{
				
					 tooltip: 'Click to add By Owner Shared Properties',
					 iconCls:'icon',
					 iconAlign: 'top',
					 width: 40,
					 icon: 'http://www.ximausa.com/img/toolbar/byowner.png',
					 scale: 'medium',
					 hidden: icon_inv,
					 
				 handler: function()
					 { 		
					 		 
						if(!user_loged){ login_win.show(); return false;}
						else if(user_block || user_web){Ext.Msg.alert('Warning', 'You are either not logged in or are not allowed to view detailed information.'); return false;}
						
						    Ext.Ajax.request({  
								waitMsg: 'Save My Byowner...',
								url: 'mylisting/properties_mybyowner.php?accion=0', 
								method: 'POST', 
								params: { 
								db:county,
								pid:pid,
								astatus:astatus},
								
								success:function(response,options)
								{
									if(response.responseText== 'true' || response.responseText==true)
										Ext.Msg.alert('Mensaje', 'Property added successfully to My Byowner.');
									else
										Ext.Msg.alert('Mensaje', response.responseText);
								},
								failure:function(response,options)
								{
									Ext.Msg.alert("Failure", response.responseText);
								}
								
																
						   });//ajax                 
					 }//hander
				  },{
					tooltip: 'Click to Generate Contract',
					id: 'overviewcontractgenerate',
					iconCls:'icon',
					hidden: true,
					iconAlign: 'top',
					width: 40,
					icon: 'http://www.ximausa.com/img/toolbar/guarantee.png',
					scale: 'medium',
					handler: function()
					 { 		
						if(!user_loged){ login_win.show(); return false;}
						else if(user_block || user_web){Ext.Msg.alert('Warning', 'You are either not logged in or are not allowed to gemerate contract information.'); return false;}
						
						var contracts=new Ext.data.SimpleStore({
										fields: ['id','name'],
											data  : [
											  ['0','As is Sales and Purchase Far Bar contract'],
											  ['1','Lead_Base contract'],
											  ['2','Far Bar Sales and Purchase contract']
											]
									});
						var simple = new Ext.FormPanel({
											url: 'overview_contract/generatecontract.php',
											frame:true,
											monitorValid: true,
											title: 'Select Contract.',
											width: 450,
											waitMsgTarget : 'Generating...',
											items: [{
														xtype     : 'combo',
														name      : 'ctype',
														id: 'ctype',
														hiddenName	:'type',
														fieldLabel: 'Contract',
														typeAhead: true,
														store: contracts,
 											            triggerAction: 'all',
														mode: 'local',
													    triggerAction: 'all',
													    editable: false,
													    emptyText	:'Select ...',
														selectOnFocus:true,
													    allowBlank: false,
														displayField:'name',
													    valueField: 'id',
														value:'0',
														width: 300
													},{
														xtype     : 'hidden',
														name      : 'county',
														value     : county
													},{
														xtype     : 'hidden',
														name      : 'pid',
														value     : pid
													}],
											formBind:true,
											buttonAlign: 'center',
											buttons: [{
													text: 'Generate',
													handler: function(){
														loading_win.show();
														simple.getForm().submit({
															success: function(form, action) {
																loading_win.hide();
																win.close();
																var url='http://www.ximausa.com/'+action.result.pdf;
																//alert(url);
																window.open(url);
															},
															failure: function(form, action) {
																loading_win.hide();
																Ext.Msg.alert("Failure", action.result.msg);
															}
														});
													}
												},{
													text: 'Cancel',
													handler  : function(){
															win.close();
														}
												}]
											});
										 
										var win = new Ext.Window({
											//layout      : 'fit',
											width       : 450,
											height      : 300,
											modal	 	: true,
											plain       : true,
											items		: [simple,
														{
															html: "<br><br>In order to be able to edit the contracts you must have Abobe Reader Pro.<br> You can also do it with the following  free softwares FoxitReader at  <a href='http://www.foxitsoftware.com/pdf/reader/' target='_new'>http://www.foxitsoftware.com/pdf/reader/</a><br> and   PDF-XChange viewer at <a href='http://www.tracker-software.com/product/pdf-xchange-viewer' target='_new'>http://www.tracker-software.com/product/pdf-xchange-viewer</a>",
															xtype: "panel"
														}],
											buttons: [{
												text     : 'Close',
												handler  : function(){
													win.close();
												}
											}]
										});
										win.show();
										win.addListener("beforeshow",function(wind){
												simple.getForm().reset();
										});	
					 }//hander
				},'->',{
					 tooltip: 'Click to Close '+titlec,
					 iconCls:'icon',
					 iconAlign: 'top',
					 width: 40,
					 icon: 'http://www.ximausa.com/img/cancel.png',
					 scale: 'medium',
					 handler: function(){
						 var tab = tabs.getItem(idc);
						 tabs.remove(tab);
					 }
				  }
			],
			autoShow: true
		});
	if(compType){	
		url+='&overview_comp=true';
		idc='overviewCTab';
		titlec=' Overview Comp ';
		menuidc='menu_overviewC';
		tbar='';
	}
	
	
	if(document.getElementById('reportsTab')){
		var tab = tabs.getItem('reportsTab');
		tabs.remove(tab);
	}
	if(document.getElementById('overviewCTab')){
		var tab = tabs.getItem('overviewCTab');
		tabs.remove(tab);
	}
	if(!compType){
		if(document.getElementById('overviewTab')){
			var tab = tabs.getItem('overviewTab');
			tabs.remove(tab);
		}
	      
	          
	}
	tabs.add({
		title: titlec,
		id: idc,
		autoLoad: {url: url, scripts: true, timeout: 10800, discardUrl:true, nocache:true, params:{userweb:user_web,ownerweb:owner_web,masterweb:master_web}},
		closable: true,
		tbar: tbar 
	}).show();
	
	if(Ext.isIE){
		var tab = tabs.getItem(idc);
		tabs.setActiveTab(tab);
		tab.getEl().repaint();
	}
}

function createResult(user_web,realtor_block){
	window.scrollTo(0,0);
	if(document.getElementById('reportsTab')){
		var tab = tabs.getItem('reportsTab');
		tabs.remove(tab);
	}
	
	if(document.getElementById('overviewTab')){
		var tab = tabs.getItem('overviewTab');
		tabs.remove(tab);
	}	

	if(document.getElementById('resultTab')){
		var tab = tabs.getItem('resultTab');
		tabs.remove(tab);
	}
	
	if(realtor_block==false) {
	        var icon_result=false;
	}else{ 
	 	var icon_result=true;
		var icon_mylabel=true;
	}
	
	if(user_web==false) {
	        var icon_mylabel=false;
	}else{ 
	 	var icon_mylabel=true;
	}
	

	
	tabs.add({
		title: ' Result ',
		id: 'resultTab',
		autoLoad: {url: 'properties_result.php', timeout: 10800, scripts: true, discardUrl:true, nocache:true, params:{userweb:user_web,realtorid:user_webid,systemsearch:systemsearch}},
		closable: true
	}).show();
	
	if(Ext.isIE){
		var tab = tabs.getItem('resultTab');
		tabs.setActiveTab(tab);
		tab.getEl().repaint();
	}
}

function createmylisting(user_web,orden){
	window.scrollTo(0,0);
	if(document.getElementById('mylistingTab')){
		var tab = tabs.getItem('mylistingTab');
		tabs.remove(tab);
	}
	tabs.add({
		title: ' My Listing ',
				id: 'mylistingTab',
				cls: 'no-border',
				width: 660,
			autoLoad: {url: 'mysetting_tabs/properties_mylisting_result.php', timeout: 10800, scripts:true, params:{userwebid:user_webid, userweb: user_web,order:orden}},
			 tbar: new Ext.Toolbar({
					width: 'auto',
					items: [' ',{
						  tooltip: 'Click to Show/Hide Map',
					 id: 'toolbarMapmylisting',
					 //text: 'Map',
					 iconCls:'icon',
					 icon: 'http://www.ximausa.com/img/toolbar/map.png',
					 iconAlign: 'top',
					 width: 40,
					 scale: 'medium',
					 enableToggle: true,
					 handler: function(){
						if(document.getElementById('mapmylisting').style.display=='none'){
							document.getElementById('mapmylisting').style.display='';
							
						}else{document.getElementById('mapmylisting').style.display='none'; }
					                    }
					 },{
						 tooltip: 'Click to Print',
						 iconCls:'icon',
						 iconAlign: 'top',
						 width: 40,
						 icon: 'http://www.ximausa.com/img/toolbar/printer.png',
						 scale: 'medium',
						  handler: function(){
						 if(!user_web){
						      if(!user_loged || user_block){ login_win.show(); return false;}
						              } 
						loading_win.show();
						Ext.Ajax.request({  
								waitMsg: 'Printing Report...',
								url: 'toolbars_types/properties_mylisting_pdf.php', 
								method: 'POST', 
								params: {userweb:user_web,
								         realtorid:user_webid},
								
								failure:function(response,options){
									Ext.MessageBox.alert('Warning','file can not be generated');
									loading_win.hide();
								                                  },
								success:function(response,options){
									var rest = Ext.util.JSON.decode(response.responseText);
									var url='http://www.ximausa.com/'+rest.pdf;
									loading_win.hide();
									window.open(url);   		}                                
							 });//ajax
						           
						     }
					  }],autoShow: true
			        })//toolbar
				}).show();
 
 	if(Ext.isIE){
		var tab = tabs.getItem('mylistingTab');
		tabs.setActiveTab(tab);
		tab.getEl().repaint();
	}
}

function pagingResult(page){
	window.scrollTo(0,0);
	var tab = tabsResult.getItem('BasicResult');
	tabsResult.setActiveTab(tab);
	var updater = tab.getUpdater();
	updater.update({url:'result_tabs/properties_basic_result.php?page='+page, timeout: 10800, scripts: true, discardUrl:true, nocache:true,
				   params:{userweb:user_web,systemsearch:systemsearch} });
}

function pagingmylisting(page,total,orden){
	window.scrollTo(0,0);
	var tab = tabs.getItem('mylistingTab');
	tabs.setActiveTab(tab);
	var updater = tab.getUpdater();
	
	updater.update({url:'mysetting_tabs/properties_mylisting_result.php?page='+page+'&total='+total, timeout: 10800, scripts: true, discardUrl:true, nocache:true,
				   params:{userweb:user_web, userwebid:user_webid, order:orden} });
}
function pagingmylistingweb(page,total,orden){
	window.scrollTo(0,0);
	var tab = tabs.getItem('mylistingTab');
	tabs.setActiveTab(tab);
	var updater = tab.getUpdater();
	
	updater.update({url:'mysetting_tabs/properties_mylisting_result_web.php?page='+page+'&total='+total, timeout: 10800, scripts: true, discardUrl:true, nocache:true,
				   params:{masterweb:master_web, masterwebid:master_webid, order:orden} });
}


function colocarDefault(id,val){
	if(val=='Address, City or Zip Code' || val=='Mlnumber' || val=='Parcelid'){
		document.getElementById(id).value='';
	}
}

function colocarDefault2(id,val){
	if(val==''){
		if(search_by_type=='LOCATION' || search_by_type=='MAP')
			document.getElementById(id).value='Address, City or Zip Code';
		if(search_by_type=='PARCELID')
			document.getElementById(id).value='Parcelid';
		if(search_by_type=='MLNUMBER')
			document.getElementById(id).value='Mlnumber';
		if(search_by_type=='CASE')
			document.getElementById(id).value='Case-Number';
	}
}


function cambiarDefault(id,val){
	document.getElementById(id).value=val;
	if(val=='Address, City or Zip Code')
		document.getElementById(search_type+'_tsearch_l').innerHTML='Location';
	if(val=='Mlnumber')
		document.getElementById(search_type+'_tsearch_l').innerHTML='Mlnumber';
	if(val=='Parcelid')
		document.getElementById(search_type+'_tsearch_l').innerHTML='Parcelid';
	if(val=='Case-Number')
		document.getElementById(search_type+'_tsearch_l').innerHTML='Case-Number';
	
}

function verEquity(val,id,id2){
	if(val=='' || val=='RE1' || val=='RE2' || val=='01' || val=='04'){
		document.getElementById(id).style.display='';
		document.getElementById(id2).style.display='';
	}else{
		document.getElementById(id).style.display='none';
		document.getElementById(id2).style.display='none';
	}
}

function OcultarMostrar(val){
	var equity='Debt Equity';
	if(search_type=='FS') equity='Potential Equity';
	
	if(val==true){
		if(document.getElementById(search_type+'_tproptype'))document.getElementById(search_type+'_tproptype').innerHTML='Property Type';
		if(document.getElementById(search_type+'_tpropfore'))document.getElementById(search_type+'_tpropfore').innerHTML='Foreclosure Status';
		if(document.getElementById(search_type+'_proptype'))document.getElementById(search_type+'_proptype').style.display='';
		if(document.getElementById(search_type+'_pendes'))document.getElementById(search_type+'_pendes').style.display='';
		if(document.getElementById(search_type+'_tprice'))document.getElementById(search_type+'_tprice').innerHTML='Price Range';
		if(document.getElementById(search_type+'_tbeds'))document.getElementById(search_type+'_tbeds').innerHTML='Beds';
		if(document.getElementById(search_type+'_tbath'))document.getElementById(search_type+'_tbath').innerHTML='Baths';
		if(document.getElementById(search_type+'_tsqft'))document.getElementById(search_type+'_tsqft').innerHTML='Sqft';
		if(document.getElementById(search_type+'_toccupied'))document.getElementById(search_type+'_toccupied').innerHTML='O. Occupied';
		if(document.getElementById(search_type+'_tpequity')){
			document.getElementById(search_type+'_tpequity').innerHTML='Debt Equity';
			if(search_type=='FS') document.getElementById(search_type+'_tpequity').innerHTML='Potential Equity';
		}
		if(document.getElementById(search_type+'_price_dol1'))document.getElementById(search_type+'_price_dol1').style.display='';
		if(document.getElementById(search_type+'_price_to'))document.getElementById(search_type+'_price_to').innerHTML='to';
		if(document.getElementById(search_type+'_price_dol2'))document.getElementById(search_type+'_price_dol2').style.display='';
		if(document.getElementById(search_type+'_bed'))document.getElementById(search_type+'_bed').style.display='';
		if(document.getElementById(search_type+'_bath'))document.getElementById(search_type+'_bath').style.display='';
		if(document.getElementById(search_type+'_sqft'))document.getElementById(search_type+'_sqft').style.display='';
		if(document.getElementById(search_type+'_pequity'))document.getElementById(search_type+'_pequity').style.display='';
		if(document.getElementById(search_type+'_price_low'))document.getElementById(search_type+'_price_low').style.display='';
		if(document.getElementById(search_type+'_price_hi'))document.getElementById(search_type+'_price_hi').style.display='';
		if(document.getElementById(search_type+'_tentrydate'))document.getElementById(search_type+'_tentrydate').innerHTML='Entry Date';
		if(document.getElementById(search_type+'_entrydate'))document.getElementById(search_type+'_entrydate').style.display='';
		if(document.getElementById(search_type+'_occupied'))document.getElementById(search_type+'_occupied').style.display='';
	}else{
		if(document.getElementById(search_type+'_tproptype'))document.getElementById(search_type+'_tproptype').innerHTML='&nbsp;';
		if(document.getElementById(search_type+'_tpropfore'))document.getElementById(search_type+'_tpropfore').innerHTML='&nbsp;';
		if(document.getElementById(search_type+'_proptype'))document.getElementById(search_type+'_proptype').style.display='none';
		if(document.getElementById(search_type+'_pendes'))document.getElementById(search_type+'_pendes').style.display='none';
		if(document.getElementById(search_type+'_tprice'))document.getElementById(search_type+'_tprice').innerHTML='&nbsp;';
		if(document.getElementById(search_type+'_tbeds'))document.getElementById(search_type+'_tbeds').innerHTML='&nbsp;';
		if(document.getElementById(search_type+'_tbath'))document.getElementById(search_type+'_tbath').innerHTML='&nbsp;';
		if(document.getElementById(search_type+'_tsqft'))document.getElementById(search_type+'_tsqft').innerHTML='&nbsp;';
		if(document.getElementById(search_type+'_tpequity'))document.getElementById(search_type+'_tpequity').innerHTML='&nbsp;';
		if(document.getElementById(search_type+'_toccupied'))document.getElementById(search_type+'_toccupied').innerHTML='&nbsp;';
		if(document.getElementById(search_type+'_price_dol1'))document.getElementById(search_type+'_price_dol1').style.display='none';
		if(document.getElementById(search_type+'_price_to'))document.getElementById(search_type+'_price_to').innerHTML='&nbsp;';
		if(document.getElementById(search_type+'_price_dol2'))document.getElementById(search_type+'_price_dol2').style.display='none';
		if(document.getElementById(search_type+'_bed'))document.getElementById(search_type+'_bed').style.display='none';
		if(document.getElementById(search_type+'_bath'))document.getElementById(search_type+'_bath').style.display='none';
		if(document.getElementById(search_type+'_sqft'))document.getElementById(search_type+'_sqft').style.display='none';
		if(document.getElementById(search_type+'_pequity'))document.getElementById(search_type+'_pequity').style.display='none';
		if(document.getElementById(search_type+'_price_low'))document.getElementById(search_type+'_price_low').style.display='none';
		if(document.getElementById(search_type+'_price_hi'))document.getElementById(search_type+'_price_hi').style.display='none';
		if(document.getElementById(search_type+'_tentrydate'))document.getElementById(search_type+'_tentrydate').innerHTML='&nbsp;';
		if(document.getElementById(search_type+'_entrydate'))document.getElementById(search_type+'_entrydate').style.display='none';
		if(document.getElementById(search_type+'_occupied'))document.getElementById(search_type+'_occupied').style.display='none';
	}
}




function searchForm(id,tipo){
	var value=document.getElementById(id).value;
	var long=document.getElementById(id).value.length;
	var county=document.getElementById(search_type+'_county_search').value;

	if(long>0 && value!='Address, City or Zip Code' && value!='Parcelid' && value!='Mlnumber')
		GuardarSearch(tipo); 
	else{
		if(search_by_type=='MAP' && (value=='Address, City or Zip Code' || value=='Parcelid' || value=='Mlnumber'))
			GuardarSearch(tipo); 
		else 
			GuardarSearch(tipo);
	}
}

function GuardarSearch(tipo){
	var ty='location';	
	var equity=-1;
	if(document.getElementById(search_type+'_pequity'))equity=document.getElementById(search_type+'_pequity').value;
	var entrydate='';
	if(document.getElementById(search_type+'_entrydate'))entrydate=document.getElementById(search_type+'_entrydate').value;
	var _search='';
	if(document.getElementById(search_type+'_search'))_search=document.getElementById(search_type+'_search').value;
	if(document.getElementById(search_type+'_case-number') && document.getElementById(search_type+'_case-number').value!='Case-Number'){
		_search=document.getElementById(search_type+'_case-number').value;	
		ty='case';
	}
	if(document.getElementById(search_type+'_mlnumber') && document.getElementById(search_type+'_mlnumber').value!='Mlnumber'){
		_search=document.getElementById(search_type+'_mlnumber').value;	
		ty='mlnumber';
	}
	if(document.getElementById(search_type+'_parcelid') && document.getElementById(search_type+'_parcelid').value!='Parcelid'){
		_search=document.getElementById(search_type+'_parcelid').value;	
		ty='parcelid';
	}
	var proptype='';
	if(document.getElementById(search_type+'_proptype'))proptype=document.getElementById(search_type+'_proptype').value;	
	var price_low='';
	if(document.getElementById(search_type+'_price_low'))price_low=document.getElementById(search_type+'_price_low').value;	
	var price_hi='';
	if(document.getElementById(search_type+'_price_hi'))price_hi=document.getElementById(search_type+'_price_hi').value;	
	var bed=-1;
	if(document.getElementById(search_type+'_bed'))bed=document.getElementById(search_type+'_bed').value;	
	var bath=-1;
	if(document.getElementById(search_type+'_bath'))bath=document.getElementById(search_type+'_bath').value;	
	var sqft=-1;
	if(document.getElementById(search_type+'_sqft'))sqft=document.getElementById(search_type+'_sqft').value;	
	var pendes=-1;
	if(document.getElementById(search_type+'_pendes'))pendes=document.getElementById(search_type+'_pendes').value;	
	var occupied=-1;
	if(document.getElementById(search_type+'_occupied'))occupied=document.getElementById(search_type+'_occupied').value;
	var mapa_search_latlong='-1';
	if(document.getElementById('mapa_search_latlong'))mapa_search_latlong=document.getElementById('mapa_search_latlong').value;	
	var realtor='-1';
	if(document.getElementById(search_type+'_realtor'))realtor=document.getElementById(search_type+'_realtor').value;
	
	if(search_by_type=='MAP' && mapa_search_latlong=='-1' && _search==''){
		alert('Map shape/polygon is requiered to execute the search');
		return false;
	}
	
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_coresearch.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			search: _search,
			county: document.getElementById(search_type+'_county_search').value,
			tsearch: ty,
			proptype: proptype,
			price_low: price_low,
			price_hi: price_hi,
			bed: bed,
			bath: bath,
			sqft: sqft,
			pequity: equity,
			pendes: pendes,
			search_mapa: mapa_search_latlong,
			entrydate: entrydate,
			search_type: search_type,
			occupied: occupied
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			systemsearch= 'basic';
			createResult(user_web,realtor_block);
		}                                
	});
}

function ShowManageTemplate(){
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_manage_template.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			tipo: 'baseLoad',
			idGridTemplate: search_type
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			var val = response.responseText.split('^');
			var val1 = Ext.decode(val[0]);
			var val2 = Ext.decode(val[1]);
			
			var panel = new Ext.Panel({
				width: 750,
				layout: 'column',
				bodyStyle:'padding:1px;text-align:left;',
				height: 380,
				autoScroll: true,
				items: [
					{
						columnWidth:.55,
						id: 'multiselectall',
						height: 360,
						width: 400,
						autoScroll: true,
						bodyStyle:'text-align:left;',
						items: val1
					},{
						columnWidth:.45,
						items: new Ext.tree.TreePanel({
							id: 'multiselecttemplate',
							height: 360,
							width: 320,
							useArrows: false,
							autoScroll: true,
							animate: true,
							enableDD: true,
							containerScroll: true,
							border: false,
							loader: new Ext.tree.TreeLoader({clearOnLoad: false}),
							rootVisible: false,
							root: {
								nodeType: 'async',
								text: 'Ext JS',
								draggable: false,
								id: 'source'
							},
							listeners: {
								'render': function (tree){
									for(v in val2){
										if(Ext.isNumber(parseInt(v))){
											Ext.getCmp('multiselecttemplate').root.appendChild(new Ext.tree.TreeNode({id:val2[v].id, text:val2[v].text, leaf:val2[v].leaf, iconCls:'treePanel-no-image'}));
										}
									}
								}
							}
						})
					}
				]
			});
			
			var total = new Ext.FormPanel({
				labelWidth: 100, // label settings here cascade unless overridden
				url:'save-form.php',
				frame:true,
				bodyStyle:'padding:5px 5px 0; text-align:left;',
				width: 'auto',
				items: [{
					xtype:'fieldset',
					id: 'new_template',
					checkboxToggle:true,
					title: 'New/Update Template',
					bodyStyle:'text-align:left;',
					autoHeight:true,
					layout: 'form',
					collapsed: true,
					items :[new Ext.form.ComboBox({
						editable: true,
						allowBlank: false,
						emptyText: 'Write Template Name',
						fieldLabel: 'Template Name',
						triggerAction: 'all',
						mode: 'remote',
						store: new Ext.data.JsonStore({
							url: 'properties_manage_template.php',
							baseParams: {'default': 'N'},
							id: 0,
							fields: [
								'tID',
								'tname'
							]
						}),
						width: 130,
						valueField: 'tID',
						displayField: 'tname',
						listeners:{
							'select': function (combo,record,index){
								LoadManageTemplateChecks(record.data.tID);
							},
							'change': function (field,newVal,oldVal){
								for(i=0;i<this.store.getCount();i++){
									if(this.store.getAt(i).data.tID==newVal){
										LoadManageTemplateChecks(newVal);
										return true;
									}
								}
								LoadManageTemplateChecks(-1);
							}
						}
					}),panel],
					buttons: [{
						text: 'Save',
						handler: function (){
							loading_win.show();
							var multy = Ext.getCmp('multiselecttemplate').root;
							var combo = Ext.getCmp('new_template').findByType('combo');
							var campos='';
							var i=0;
							var node = multy.item(i);
							
							while(!node.isLast()){
								if(campos!='') campos+=',';
								campos+=node.id;
								i++;
								node = multy.item(i);
							}
							campos+=','+node.id;
							
							if(combo[0].getValue()!='' && multy.hasChildNodes()>0){
								SaveManageTemplate(combo[0].getValue(),campos);
								win.close();
							}else{
								loading_win.hide();
								Ext.MessageBox.alert('Warning','Please select a Template Name from List to Create or Update.');
							}
						}
					}
					],
					listeners: {
						'collapse': function(panel){
							var com = Ext.getCmp('del_template');
							com.expand(false);
						},
						'expand': function(panel){
							var com = Ext.getCmp('del_template');
							com.collapse(false);
						}
					}
				},{
					xtype:'fieldset',
					id: 'del_template',
					checkboxToggle:true,
					title: 'Delete Template',
					autoHeight:true,
					layout: 'form',
					collapsed: false,
					items :[new Ext.form.ComboBox({
						autoSelect: true,
						autoLoad: true,
						editable: false,
						forceSelection: true,
						fieldLabel: 'Template Name',
						triggerAction: 'all',
						mode: 'remote',
						store: new Ext.data.JsonStore({
							url: 'properties_manage_template.php',
							baseParams: {'default': 'N'},
							id: 0,
							fields: [
								'tID',
								'tname'
							]
						}),
						width: 130,
						valueField: 'tID',
						displayField: 'tname'
					})],
					buttons: [{
						text: 'Delete',
						handler: function (){
							loading_win.show();
							var combo = Ext.getCmp('del_template').findByType('combo');
							if(combo[0].getValue()!=''){
								DeleteManageTemplate(combo[0].getValue());
								win.close();
							}else{
								loading_win.hide();
								Ext.MessageBox.alert('Warning','Please select a Template Name from List to delete.');
							}
						}
					}
					],
					listeners: {
						'collapse': function(panel){
							var com = Ext.getCmp('new_template');
							com.expand(false);
						},
						'expand': function(panel){
							var com = Ext.getCmp('new_template');
							com.collapse(false);
						}
					}
				}]
			});

			var win = new Ext.Window({		
				layout      : 'fit',
				width       : 800,
				height      : 560,
				modal	 	: true,
				plain       : true,
				title: 'Manage Template',
				items		: total
			});
			win.show();
		}                                
	});
	
}

function LoadManageTemplateChecks(template){
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_manage_template.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			tipo: 'load',
			idGridTemplate: search_type,
			temp: template
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			if(document.getElementById('new_template')){
				var ids = Ext.decode(response.responseText);
				var checks = Ext.getCmp('new_template').findByType('checkbox');
				var ar = new Array();
				for(i=0; i<checks.length; i++){
					if(checks[i].getValue())
						checks[i].setValue(false);
					for(j=0; j<ids.length; j++){
						if(checks[i].getName().split('.')[0]==ids[j])
							ar[j]=i;	
					}
				}
				for(i=0; i<ar.length; i++){
					checks[ar[i]].setValue(true);
				}
			}
		}
	});
}

function SaveManageTemplate(idTemp,campos){
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_manage_template.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			tipo: 'save',
			idTemp: idTemp,
			campos: campos
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			loading_win.hide();
			if(response.responseText=='true')
				Ext.MessageBox.alert('Manage Template','Saved Successfully.');
			else
				Ext.MessageBox.alert('Manage Template',response.responseText);
			Ext.getCmp('templateCombo').getStore().reload();
		}
	});
}

function DeleteManageTemplate(idTemp){
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_manage_template.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			tipo: 'delete',
			idTemp: idTemp
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			loading_win.hide();
			if(response.responseText=='true')
				Ext.MessageBox.alert('Manage Template','Deleted Successfully.');
			else
				Ext.MessageBox.alert('Manage Template',response.responseText);
			Ext.getCmp('templateCombo').getStore().reload();
		}
	});
}

function ShowSavedSearch(){
	var fsf = new Ext.FormPanel({
        labelWidth: 75, // label settings here cascade unless overridden
        url:'save-form.php',
        frame:true,
        title: 'Manage Saved Search',
        bodyStyle:'padding:5px 5px 0',
        width: 350,
        items: [{
            xtype:'fieldset',
			id: 'new_saved_search',
            checkboxToggle:true,
            title: 'New Saved Search',
            autoHeight:true,
            defaults: {width: 210},
            defaultType: 'textfield',
            collapsed: true,
            items :[{
                    fieldLabel: 'Name',
                    name: 'name',
                    allowBlank:false
                },{
                    fieldLabel: 'Description',
                    name: 'desc',
					allowBlank: false
                }
            ],
			listeners: {
				'collapse': function(panel){
					var com = Ext.getCmp('list_saved_search');
					com.expand(false);
					Ext.getCmp('save_SS').hide();
					Ext.getCmp('select_SS').show();
					Ext.getCmp('overwrite_SS').show();
					Ext.getCmp('delete_SS').show();
				},
				'expand': function(panel){
					var com = Ext.getCmp('list_saved_search');
					com.collapse(false);
					Ext.getCmp('save_SS').show();
					Ext.getCmp('select_SS').hide();
					Ext.getCmp('overwrite_SS').hide();
					Ext.getCmp('delete_SS').hide();
				}
			}
        },{
            xtype:'fieldset',
			id: 'list_saved_search',
			checkboxToggle:true,
			collapsed: false,
            title: 'List Saved Searches',
            autoHeight:true,
            items :[
				new Ext.form.ComboBox({
					fieldLabel: 'List',
					triggerAction: 'all',
					mode: 'remote',
					store: new Ext.data.JsonStore({
						url: 'properties_saved_search.php',
						forceSelection: true,
						id: 0,
						fields: [
							'ssID',
							'ssname'
						]
					}),
					valueField: 'ssID',
					displayField: 'ssname'
				})
            ],
			listeners: {
				'collapse': function(panel){
					var com = Ext.getCmp('new_saved_search');
					com.expand(false);
					Ext.getCmp('save_SS').show();
					Ext.getCmp('select_SS').hide();
					Ext.getCmp('overwrite_SS').hide();
					Ext.getCmp('delete_SS').hide();
				},
				'expand': function(panel){
					var com = Ext.getCmp('new_saved_search');
					com.collapse(false);
					Ext.getCmp('save_SS').hide();
					Ext.getCmp('select_SS').show();
					Ext.getCmp('overwrite_SS').show();
					Ext.getCmp('delete_SS').show();
				}
			}
        }],

        buttons: [{
            text: 'Save',
			id: 'save_SS',
			handler: function(){
				var name = Ext.getCmp('new_saved_search').getComponent(0);
				var desc = Ext.getCmp('new_saved_search').getComponent(1);
				if(name.isValid() && desc.isValid()){
					GuardarSearchSaved(name.getValue(),desc.getValue());
					win.close();
				}else
					Ext.Msg.alert('Manage Saved Searchs', 'Please fill the name and description field to save the search.');
			}
        },{
            text: 'Select',
			id: 'select_SS',
			handler: function(){
				var list = Ext.getCmp('list_saved_search').getComponent(0);
				var ssid = list.getValue();
				if(Ext.isEmpty(ssid))
					Ext.Msg.alert('Manage Saved Searchs', 'Please select a Saved Search from List to load.');
				else{
					SelectSearchSaved(ssid);
					win.close();
				}
			}
        },{
            text: 'Overwrite',
			id: 'overwrite_SS',
			handler: function(){
				var list = Ext.getCmp('list_saved_search').getComponent(0);
				var ssid = list.getValue();
				if(Ext.isEmpty(ssid))
					Ext.Msg.alert('Manage Saved Searchs', 'Please select a Saved Search from List to overwrite.');
				else{
					OverwriteSearchSaved(ssid);
					win.close();
				}
			}
        },{
            text: 'Delete',
			id: 'delete_SS',
			handler: function(){
				var list = Ext.getCmp('list_saved_search').getComponent(0);
				var ssid = list.getValue();
				if(Ext.isEmpty(ssid))
					Ext.Msg.alert('Manage Saved Searchs', 'Please select a Saved Search from List to delete.');
				else{
					DeleteSearchSaved(ssid);
					win.close();
				}
			}
        }]
    });
	
	var win = new Ext.Window({		
		layout      : 'fit',
		width       : 370,
		height      : 300,
		modal	 	: true,
		plain       : true,
		items		: fsf
	});
	win.show();
}

function GuardarSearchSaved(name,desc){
	var ty='location';	
	var equity=-1;
	if(document.getElementById(search_type+'_pequity'))equity=document.getElementById(search_type+'_pequity').value;
	var entrydate='';
	if(document.getElementById(search_type+'_entrydate'))entrydate=document.getElementById(search_type+'_entrydate').value;
	var _search='';
	if(document.getElementById(search_type+'_search'))_search=document.getElementById(search_type+'_search').value;	
	if(document.getElementById(search_type+'_case-number') && document.getElementById(search_type+'_case-number').value!='Case-Number'){
		_search=document.getElementById(search_type+'_case-number').value;	
		ty='case';
	}
	if(document.getElementById(search_type+'_mlnumber') && document.getElementById(search_type+'_mlnumber').value!='Mlnumber'){
		_search=document.getElementById(search_type+'_mlnumber').value;	
		ty='mlnumber';
	}
	if(document.getElementById(search_type+'_parcelid') && document.getElementById(search_type+'_parcelid').value!='Parcelid'){
		_search=document.getElementById(search_type+'_parcelid').value;	
		ty='parcelid';
	}
	var proptype='';
	if(document.getElementById(search_type+'_proptype'))proptype=document.getElementById(search_type+'_proptype').value;	
	var price_low='';
	if(document.getElementById(search_type+'_price_low'))price_low=document.getElementById(search_type+'_price_low').value;	
	var price_hi='';
	if(document.getElementById(search_type+'_price_hi'))price_hi=document.getElementById(search_type+'_price_hi').value;	
	var bed=-1;
	if(document.getElementById(search_type+'_bed'))bed=document.getElementById(search_type+'_bed').value;	
	var bath=-1;
	if(document.getElementById(search_type+'_bath'))bath=document.getElementById(search_type+'_bath').value;	
	var sqft=-1;
	if(document.getElementById(search_type+'_sqft'))sqft=document.getElementById(search_type+'_sqft').value;	
	var pendes=-1;
	if(document.getElementById(search_type+'_pendes'))pendes=document.getElementById(search_type+'_pendes').value;	
	var occupied=-1;
	if(document.getElementById(search_type+'_occupied'))occupied=document.getElementById(search_type+'_occupied').value;
	var mapa_search_latlong='-1';
	if(document.getElementById('mapa_search_latlong'))mapa_search_latlong=document.getElementById('mapa_search_latlong').value;	
	
	if(search_by_type=='MAP' && mapa_search_latlong=='-1' && _search==''){
		Ext.Msg.alert('Search', 'Map shape/polygon is requiered to execute the search.');
		return false;
	}
	
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_saved_search.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			tipo: 'save',
			name: name,
			desc: desc,
			search: _search,
			county: document.getElementById(search_type+'_county_search').value,
			tsearch: ty,
			proptype: proptype,
			price_low: price_low,
			price_hi: price_hi,
			bed: bed,
			bath: bath,
			sqft: sqft,
			pequity: equity,
			pendes: pendes,
			search_mapa: mapa_search_latlong,
			entrydate: entrydate,
			search_type: search_type,
			occupied: occupied
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			
			if(response.responseText=='true')
				Ext.Msg.alert('Manage Saved Searchs', 'Saved successfully.');
			else
				Ext.Msg.alert('Manage Saved Searchs', response.responseText);
		}                                
	});
}
var intervalID=null;
var ss_data=null;
function SelectSearchSaved(ssid){
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_saved_search.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			tipo: 'select',
			ssid: ssid
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			var resp = response.responseText.split('^');
			if(resp[0]=='true'){
				ss_data = Ext.decode(resp[1]);				
				doSearchTypeFilter(ss_data.basic.search_type);				
				LoadSearchSaved();
			}else
				Ext.Msg.alert('Manage Saved Searchs', response.responseText);

		}                                
	});
}

function LoadSearchSaved(){
	if(ss_data.basic.tsearch.toUpperCase()=='LOCATION') doSearchByFilter(ss_data.basic.tsearch.toUpperCase());
	else if(ss_data.basic.tsearch.toUpperCase()=='CASE')
		if(document.getElementById(search_type+'_case-number'))document.getElementById(search_type+'_case-number').value = ss_data.basic.search;
	else if(ss_data.basic.tsearch.toUpperCase()=='PARCELID')
		if(document.getElementById(search_type+'_parcelid'))document.getElementById(search_type+'_parcelid').value = ss_data.basic.search;
	else if(ss_data.basic.tsearch.toUpperCase()=='MLNUMBER')
		if(document.getElementById(search_type+'_mlnumber'))document.getElementById(search_type+'_mlnumber').value = ss_data.basic.search;
	
	if(document.getElementById('mapa_search_latlong'))document.getElementById('mapa_search_latlong').value=ss_data.basic.search_mapa;

	if(ss_data.basic.search_mapa!='-1' && ss_data.basic.search_mapa!=null){
		if(document.getElementById('mapSearch') && document.getElementById('mapSearch').style.display=='') doSearchByFilter('MAP_OFF');
		doSearchByFilter('MAP');
		document.getElementById(search_type+'_combo_search_by').value = 'MAP';

		var _xpoints=new Array();
		var latlong = ss_data.basic.search_mapa.split('/');
		for(x=0;x<latlong.length;x++){
			_xpoints.push(new VELatLong(latlong[x].split(",")[0],latlong[x].split(",")[1]));
		}

		mapSearch.points2shape(_xpoints);
	}
	if(document.getElementById(search_type+'_county_search'))document.getElementById(search_type+'_county_search').value = ss_data.basic.county;
	if(document.getElementById(search_type+'_pequity'))document.getElementById(search_type+'_pequity').value=ss_data.basic.pequity;
	if(document.getElementById(search_type+'_entrydate'))document.getElementById(search_type+'_entrydate').value=ss_data.basic.entrydate;
	if(document.getElementById(search_type+'_search') && ss_data.basic.tsearch.toUpperCase()=='LOCATION')document.getElementById(search_type+'_search').value=ss_data.basic.search;	
	if(document.getElementById(search_type+'_proptype'))document.getElementById(search_type+'_proptype').value=ss_data.basic.proptype;	
	if(document.getElementById(search_type+'_price_low'))document.getElementById(search_type+'_price_low').value=ss_data.basic.price_low;	
	if(document.getElementById(search_type+'_price_hi'))document.getElementById(search_type+'_price_hi').value=ss_data.basic.price_hi;	
	if(document.getElementById(search_type+'_bed'))document.getElementById(search_type+'_bed').value=ss_data.basic.bed;	
	if(document.getElementById(search_type+'_bath'))document.getElementById(search_type+'_bath').value=ss_data.basic.bath;	
	if(document.getElementById(search_type+'_sqft'))document.getElementById(search_type+'_sqft').value=ss_data.basic.sqft;	
	if(document.getElementById(search_type+'_pendes'))document.getElementById(search_type+'_pendes').value=ss_data.basic.pendes;
	if(document.getElementById(search_type+'_occupied'))document.getElementById(search_type+'_occupied').value=ss_data.basic.occupied ? ss_data.basic.occupied : '-1';			
}

function DeleteSearchSaved(ssid){
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_saved_search.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			tipo: 'delete',
			ssid: ssid
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			if(response.responseText=='true')
				Ext.Msg.alert('Manage Saved Searchs', 'Delete successfully.');
			else
				Ext.Msg.alert('Manage Saved Searchs', response.responseText);

		}                                
	});
}

function OverwriteSearchSaved(ssid){
	var ty='location';	
	if(search_by_type=='MLNUMBER') 
		ty='mlnumber';
	if(search_by_type=='PARCELID') 
		ty='parcelid';
	if(search_by_type=='CASE')
		ty='case';
	var equity=-1;
	if(document.getElementById(search_type+'_pequity'))equity=document.getElementById(search_type+'_pequity').value;
	var entrydate='';
	if(document.getElementById(search_type+'_entrydate'))entrydate=document.getElementById(search_type+'_entrydate').value;
	var _search='';
	if(document.getElementById(search_type+'_search'))_search=document.getElementById(search_type+'_search').value;	
	var proptype='';
	if(document.getElementById(search_type+'_proptype'))proptype=document.getElementById(search_type+'_proptype').value;	
	var price_low='';
	if(document.getElementById(search_type+'_price_low'))price_low=document.getElementById(search_type+'_price_low').value;	
	var price_hi='';
	if(document.getElementById(search_type+'_price_hi'))price_hi=document.getElementById(search_type+'_price_hi').value;	
	var bed=-1;
	if(document.getElementById(search_type+'_bed'))bed=document.getElementById(search_type+'_bed').value;	
	var bath=-1;
	if(document.getElementById(search_type+'_bath'))bath=document.getElementById(search_type+'_bath').value;	
	var sqft=-1;
	if(document.getElementById(search_type+'_sqft'))sqft=document.getElementById(search_type+'_sqft').value;	
	var pendes=-1;
	if(document.getElementById(search_type+'_pendes'))pendes=document.getElementById(search_type+'_pendes').value;	
	var occupied=-1;
	if(document.getElementById(search_type+'_occupied'))occupied=document.getElementById(search_type+'_occupied').value;
	var mapa_search_latlong='-1';
	if(document.getElementById('mapa_search_latlong'))mapa_search_latlong=document.getElementById('mapa_search_latlong').value;	
	
	if(search_by_type=='MAP' && mapa_search_latlong=='-1' && _search==''){
		//alert('Map shape/polygon is requiered to execute the search');
		Ext.Msg.alert('Search', 'Map shape/polygon is requiered to execute the search.');
		return false;
	}
	
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_saved_search.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			tipo: 'overwrite',
			ssid: ssid,
			search: _search,
			county: document.getElementById(search_type+'_county_search').value,
			tsearch: ty,
			proptype: proptype,
			price_low: price_low,
			price_hi: price_hi,
			bed: bed,
			bath: bath,
			sqft: sqft,
			pequity: equity,
			pendes: pendes,
			search_mapa: mapa_search_latlong,
			entrydate: entrydate,
			search_type: search_type,
			occupied: occupied
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			if(response.responseText=='true')
				Ext.Msg.alert('Manage Saved Searchs', 'Overwrite successfully.');
			else
				Ext.Msg.alert('Manage Saved Searchs', response.responseText);
		}                                
	});
}

function ShowSavedSearchParameter(){
	var psp = new Ext.FormPanel({
        labelWidth: 75, // label settings here cascade unless overridden
        //url:'save-form.php',
        frame:true,
        //title: 'Manage Saved Parameters',
        bodyStyle:'padding:5px 5px 0',
        width: 350,
        items: [{
            xtype:'fieldset',
			id: 'new_saved_parameter',
            checkboxToggle:true,
            title: 'New Saved Parameter',
            autoHeight:true,
            defaults: {width: 210},
            defaultType: 'textfield',
            collapsed: true,
            items :[{
                    fieldLabel: 'Name',
                    name: 'name',
                    allowBlank:false
                },{
                    fieldLabel: 'Description',
                    name: 'desc',
					allowBlank: false
                }
            ],
			listeners: {
				'collapse': function(panel){
					var com = Ext.getCmp('list_saved_search');
					com.expand(false);
					Ext.getCmp('save_SP').hide();
					Ext.getCmp('select_SP').show();
					Ext.getCmp('overwrite_SP').show();
					Ext.getCmp('delete_SP').show();
				},
				'expand': function(panel){
					var com = Ext.getCmp('list_saved_search');
					com.collapse(false);
					Ext.getCmp('save_SP').show();
					Ext.getCmp('select_SP').hide();
					Ext.getCmp('overwrite_SP').hide();
					Ext.getCmp('delete_SP').hide();
				}
			}
        },{
            xtype:'fieldset',
			id: 'list_saved_search',
			checkboxToggle:true,
			collapsed: false,
            title: 'List Saved Parameters',
            autoHeight:true,
            items :[
				new Ext.form.ComboBox({
					fieldLabel: 'List',
					triggerAction: 'all',
					mode: 'remote',
					store: new Ext.data.JsonStore({
						url: 'properties_saved_searchAdv.php',
						forceSelection: true,
						id: 0,
						fields: ['ssID','ssname']
					}),
					valueField: 'ssID',
					displayField: 'ssname'
				})
            ],
			listeners: {
				'collapse': function(panel){
					var com = Ext.getCmp('new_saved_parameter');
					com.expand(false);
					Ext.getCmp('save_SP').show();
					Ext.getCmp('select_SP').hide();
					Ext.getCmp('overwrite_SP').hide();
					Ext.getCmp('delete_SP').hide();
				},
				'expand': function(panel){
					var com = Ext.getCmp('new_saved_parameter');
					com.collapse(false);
					Ext.getCmp('save_SP').hide();
					Ext.getCmp('select_SP').show();
					Ext.getCmp('overwrite_SP').show();
					Ext.getCmp('delete_SP').show();
				}
			}
        }],

        buttons: [{
            text: 'Save',
			id: 'save_SP',
			handler: function(){
				var name = Ext.getCmp('new_saved_parameter').getComponent(0);
				var desc = Ext.getCmp('new_saved_parameter').getComponent(1);
				if(name.isValid() && desc.isValid()){
					GuardarSearchSavedParameter(name.getValue(),desc.getValue());
					win.close();
				}else
					Ext.Msg.alert('Manage Saved Parameters', 'Please fill the name and description field to save the parameter.');
			}
        },{
            text: 'Select',
			id: 'select_SP',
			handler: function(){
				var list = Ext.getCmp('list_saved_search').getComponent(0);
				var ssid = list.getValue();
				if(Ext.isEmpty(ssid))
					Ext.Msg.alert('Manage Saved Parameters', 'Please select a Saved Parameters from List to load.');
				else{
					SelectSearchSavedParameter(ssid);
					win.close();
				}
			}
        },{
            text: 'Overwrite',
			id: 'overwrite_SP',
			handler: function(){
				var list = Ext.getCmp('list_saved_search').getComponent(0);
				var ssid = list.getValue();
				if(Ext.isEmpty(ssid))
					Ext.Msg.alert('Manage Saved Parameters', 'Please select a Saved Parameters from List to overwrite.');
				else{
					OverwriteSearchSavedParameter(ssid);
					win.close();
				}
			}
        },{
            text: 'Delete',
			id: 'delete_SP',
			handler: function(){
				var list = Ext.getCmp('list_saved_search').getComponent(0);
				var ssid = list.getValue();
				if(Ext.isEmpty(ssid))
					Ext.Msg.alert('Manage Saved Parameters', 'Please select a Saved Parameters from List to delete.');
				else{
					DeleteSearchSavedParameter(ssid);
					win.close();
				}
			}
        }]
    });
	
	var win = new Ext.Window({		
		title: 'Manage Saved Parameters',
		layout      : 'fit',
		width       : 370,
		height      : 300,
		modal	 	: true,
		plain       : true,
		items		: psp
	});
	win.show();
}

function GuardarSearchSavedParameter(name,desc){
	if(search_by_type=='MAP' && document.getElementById('mapa_search_latlongAdv').value=='-1'){
		Ext.Msg.alert('Search', 'Map shape/polygon is requiered to execute the search.');
		return false;
	}

	formulsearchadv.getForm().submit({
		url: 'properties_saved_searchAdv.php', 
		method: 'POST',
		params: { tipo: 'save', name: name, desc: desc },
		waitTitle: 'Please wait..',
		waitMsg: 'Sending data...',
		success: function(form, action) {
			if(action.response.responseText=='true')
				Ext.Msg.alert('Manage Saved Parameters', 'Saved Parameters successfully.');
			else
				Ext.Msg.alert('Manage Saved Parameters', action.response.responseText);
		},
		failure: function(form, action) {
			obj = Ext.util.JSON.decode(action.response.responseText);
			Ext.Msg.alert("Failure", obj.errors.reason);
		}
	});
}

function DeleteSearchSavedParameter(ssid){
	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_saved_searchAdv.php', 
		method: 'POST',
		timeout :600000,
		params: { 
			tipo: 'delete',
			ssid: ssid
		},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			if(response.responseText=='true')
				Ext.Msg.alert('Manage Saved Parameters', 'Delete successfully.');
			else
				Ext.Msg.alert('Manage Saved Parameters', response.responseText);

		}                                
	});
}

function OverwriteSearchSavedParameter(ssid){
	if(search_by_type=='MAP' && document.getElementById('mapa_search_latlongAdv').value=='-1'){
		Ext.Msg.alert('Search', 'Map shape/polygon is requiered to execute the search.');
		return false;
	}

	formulsearchadv.getForm().submit({
		url: 'properties_saved_searchAdv.php', 
		method: 'POST',
		params: { tipo: 'overwrite', ssid: ssid },
		waitTitle: 'Please wait..',
		waitMsg: 'Sending data...',
		success: function(form, action) {
			if(action.response.responseText=='true')
				Ext.Msg.alert('Manage Saved Parameters', 'Overwrite successfully.');
			else
				Ext.Msg.alert('Manage Saved Parameters', action.response.responseText);
		},
		failure: function(form, action) {
			obj = Ext.util.JSON.decode(action.response.responseText);
			Ext.Msg.alert("Failure", obj.errors.reason);
		}
	});

}

function SelectSearchSavedParameter(ssid){

	Ext.Ajax.request( 
	{  
		waitMsg: 'Validating...',
		url: 'properties_saved_searchAdv.php', 
		method: 'POST',
		params: { tipo: 'select',ssid: ssid, dataarr: 'no'},
		
		failure:function(response,options){
			Ext.MessageBox.alert('Warning','ERROR');
		},
		success:function(response,options){
			var results=response.responseText;//alert(results);return;
			var aRes=results.split("^");
			
			if(aRes[0]=='true')
			{
				var rest = Ext.util.JSON.decode(aRes[1]);
				var havemortgage = aRes[2];
				
				if(Ext.getCmp('PR'))Ext.getCmp('PR').collapse();
				if(Ext.getCmp('PRMORE'))Ext.getCmp('PRMORE').collapse();
				if(Ext.getCmp('FS'))Ext.getCmp('FS').collapse();
				if(Ext.getCmp('FSMORE'))Ext.getCmp('FSMORE').collapse();
				if(Ext.getCmp('BO'))Ext.getCmp('BO').collapse();
				if(Ext.getCmp('BOMORE'))Ext.getCmp('BOMORE').collapse();
				if(Ext.getCmp('FO'))Ext.getCmp('FO').collapse();

				if(Ext.getCmp('MO'))
				{
					if(havemortgage=='N')
					{
						Ext.getCmp('MO').disable();
						Ext.getCmp('MO').setVisible(false);
					}
					if(havemortgage=='Y')
					{
						Ext.getCmp('MO').enable();
						Ext.getCmp('MO').setVisible(true);
						Ext.getCmp('MO').collapse();
					}
				}
				
				for(var i=0;i<rest.length;i++)
					Ext.getCmp(rest[i]).expand();
					

				formulsearchadv.getForm().reset();
				for(x=0;x<arrinpbetween.length;x++)
				{	
					Ext.getCmp(arrinpbetween[x]).setVisible(false);
				}
				arrinpbetween=new Array();
				if(mapSearchAdv!=null)
				{
					search_by_typeAdv='MAP_OFF';
					mapSearchAdv.cleaner()
				}
						
				formulsearchadv.getForm().load({
					url: 'properties_saved_searchAdv.php', 
					params: {  tipo: 'select', ssid: ssid, dataarr: 'yes' },
					success: function(form, action) {
						//Ext.Msg.alert("Success", action.response.responseText);
						
						var val=Ext.getCmp('nproperty').getValue();
						var valcur=Ext.getCmp('nproptype').getValue();
						if(val=='FR')val='FS';
						if(val=='BOR')val='BO';
						var cprop = Ext.getCmp('nproptype');        
						cprop.clearValue();
						cprop.store.removeAll();
						
						switch (val)
						{
							case 'PR': case 'FO': case 'MO'://public records  foreclosure
								cprop.store.add(new cprop.store.recordType({valuec:'*',textc:'Any Type'}));
								cprop.store.add(new cprop.store.recordType({valuec:'01',textc:'Single Family'}));
								cprop.store.add(new cprop.store.recordType({valuec:'04',textc:'Condo/Town/Villa'}));
								cprop.store.add(new cprop.store.recordType({valuec:'03',textc:'Multi Family +10'}));
								cprop.store.add(new cprop.store.recordType({valuec:'08',textc:'Multi Family -10'}));
								cprop.store.add(new cprop.store.recordType({valuec:'11',textc:'Commercial'}));
								cprop.store.add(new cprop.store.recordType({valuec:'00',textc:'Vacant Land'}));
								cprop.store.add(new cprop.store.recordType({valuec:'02',textc:'Mobile Home'}));
								cprop.store.add(new cprop.store.recordType({valuec:'99',textc:'Other'}));
							break;
							case 'FS': case 'BO':  //listing
								cprop.store.add(new cprop.store.recordType({valuec:'*',textc:'Any Type'}));
								cprop.store.add(new cprop.store.recordType({valuec:'01',textc:'Single Family'}));
								cprop.store.add(new cprop.store.recordType({valuec:'04',textc:'Condo/Town/Villa'}));
								cprop.store.add(new cprop.store.recordType({valuec:'08',textc:'Multi Family'}));
								cprop.store.add(new cprop.store.recordType({valuec:'11',textc:'Commercial'}));
								cprop.store.add(new cprop.store.recordType({valuec:'00',textc:'Vacant Land'}));
								cprop.store.add(new cprop.store.recordType({valuec:'02',textc:'Mobile Home'}));
							break;
						}
						cprop.setValue(valcur);		
						
						
						var cfore = Ext.getCmp('nforeclosure');        
						valcur=Ext.getCmp('nforeclosure').getValue();
						cfore.clearValue();
						cfore.store.removeAll();
						if(val=='FO')//foreclosure
						{
								cfore.store.add(new cfore.store.recordType({valuec:'-1',textc:'Any'}));
								cfore.store.add(new cfore.store.recordType({valuec:'P',textc:'Pre-Foreclosed'}));
								cfore.store.add(new cfore.store.recordType({valuec:'F',textc:'Foreclosed'}));
						}
						else//other outpput NOT foreclosure
						{
								cfore.store.add(new cfore.store.recordType({valuec:'-1',textc:'Any'}));
								cfore.store.add(new cfore.store.recordType({valuec:'N',textc:'No'}));
								cfore.store.add(new cfore.store.recordType({valuec:'P',textc:'Pre-Foreclosed'}));
								cfore.store.add(new cfore.store.recordType({valuec:'F',textc:'Foreclosed'}));
						}
						cfore.setValue(valcur);	
						
						if(mapSearchAdv!=null && document.getElementById('mapa_search_latlongAdv').value!='-1' && document.getElementById('mapa_search_latlongAdv').value!=null)
						{
							search_by_typeAdv='MAP';
							if(document.getElementById('mapSearchAdv') && document.getElementById('mapSearchAdv').style.display=='none')
								mapSearchAdv.control_map();

							mapSearchAdv.centerMapCounty(document.getElementById('occounty').value,true);
							
							var _xpoints=new Array();
							var latlong = document.getElementById('mapa_search_latlongAdv').value.split('/');
							for(x=0;x<latlong.length;x++){
								_xpoints.push(new VELatLong(latlong[x].split(",")[0],latlong[x].split(",")[1]));
							}
							mapSearchAdv.points2shape(_xpoints);
							mapSearchAdv.map.SetMapView(_xpoints);
						}

						//ajax select between
						Ext.Ajax.request( 
						{  
							waitMsg: 'Validating...',
							url: 'properties_saved_searchAdv.php', 
							method: 'POST',
							params: { tipo: 'selectbetween',ssid: ssid, dataarr: 'yes'},
							
							failure:function(response,options){
								Ext.MessageBox.alert('Warning','ERROR');
							},
							success:function(response,options){
								var results=response.responseText;//alert(results);return;
								var rest = Ext.util.JSON.decode(results);

								for(i=0;i<rest.data.length;i++)
								{
									txfield=rest.data[i].inputn;
									valcur=rest.data[i].inputv;
									//alert(txfield+"#"+valcur);
									Ext.getCmp(txfield).setVisible(true);
									Ext.getCmp(txfield).setValue(valcur);
									arrinpbetween.push(txfield);
								}
								
//								var cfore = Ext.getCmp('nforeclosure');        
//								valcur=Ext.getCmp('nforeclosure').getValue();
//								cfore.clearValue();
//								cfore.setValue(valcur);	
							},
							failure: function(form, action) {
								Ext.Msg.alert("Failure", action.result.errorMessage);
							}
						});
						
						
					},
					failure: function(form, action) {
						Ext.Msg.alert("Failure", action.result.errorMessage);
					}
				});
				
			}
			else
				Ext.Msg.alert('Manage Saved Parameters', response.responseText);

		}                                
	});

}

function expandir(fila,imagen)
{
	var mfila=document.getElementById(fila).style.display;
	if(mfila==null || mfila=="none")
	{
		document.getElementById(fila).style.display="inline";
		document.getElementById(imagen).src="../../img/up.png";
		document.getElementById(imagen).alt="Ocultar";
	}
	else
	{
		document.getElementById(fila).style.display="none";
		document.getElementById(imagen).src="../../img/down.png";
		document.getElementById(imagen).alt="Mostrar";
	}

}

function contacto(agentemail,address){
	    var mylisting=true;
		var simple = new Ext.FormPanel
		({
			labelWidth: 100, 
			url:'contactussendmail.php?email_user='+agentemail+'&mylisting='+mylisting+'&address_email='+address,
			frame:true,
			title: 'Contact AGENT', // titulo de la ventana
			bodyStyle:'padding:5px 5px 0', // estilo del boton
			width: 200,  
			defaults: {width: 200},
			waitMsgTarget : 'Send Message...',
			
			items: [{
					fieldLabel: 'Name',
					xtype: 'textfield',
					name: 'nombre'
					
				    },{
					fieldLabel: 'E-mail',  // etiqueta  
					xtype: 'textfield',   // tipo de campo   
					name: 'correo',      // variable
					vtype: 'email'  //tipo de variable
					
					 },{
					fieldLabel: 'Company',  // etiqueta  
					xtype: 'textfield',   // tipo de campo   
					name: 'empresa'      // variable
				
					  },{
					fieldLabel: 'Phone',  // etiqueta  
					xtype: 'textfield',   // tipo de campo   
					name: 'telefono'      // variable
				
					  },{
					fieldLabel: 'City - County',  // etiqueta  
					xtype: 'textfield',   // tipo de campo   
					name: 'ciudad'      // variable
				
					  },{
					fieldLabel: 'Your Message',  // etiqueta  
					xtype: 'htmleditor',   // tipo de campo
					id:'COMENTARIO',
					name: 'comentario',      // variable
				    height:200,
                    anchor:'98%'
				    }],
	
			buttons: [{
				text: 'Send',  
				handler: function() 
				{   
				 simple.getForm().submit({
					 
					 success: function(form, action)
											 {          
											 win.close();
							                 Ext.Msg.alert('Mensaje', 'Message Sent');
											 }, 
											 failure: function(form, action) 
											 {
								             Ext.Msg.alert("Failure", 'Message No Sent');
							                 }
					                	     });												
								
				}

				},{
				text: 'Cancel',
				handler  : function(){
                        {win.close();}
                    }
			         }]
		});
		 ///////////////// Habilita la nueva ventana con sus propiedades
		  
		  win = new Ext.Window({
			
			layout      : 'fit',
			width       : 680,
			height      : 350,
			modal	 	: true,
			plain       : true,
			items		: simple

		                    });
        /////////////////////////////////////////////////
		
        win.show(); // apertura de la ventana
		win.addListener("beforeshow",function(win)
											  {
			                                   simple.getForm().reset();
			                                  });
	}	
	
function close_login_win_allcounty(user,close)
{
	//loading_win.show();
	var newprice=document.getElementById("newprice").value;
	var prorate=document.getElementById("proratecommercial").value;
	//if(close==0 && 	document.getElementById("chcommercial").checked==false)close=1;
	var parametros="oper=allcountyactivate&userid="+user+"&newprice="+newprice+"&prorate="+prorate+"&close="+close;
//alert(parametros);	return;		
	var ajax=nuevoAjax();
	ajax.open("POST", "includes/properties_updateuser.php", true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send(parametros);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)	
		{
			var results=ajax.responseText;
//alert(results);return;
			var aRes=results.split("^");
			//loading_win.hide();
			if(aRes[0]>0)
			{
				login_win_allcounty.hide()
				if(aRes[0]==1)
				{
					Ext.Msg.alert('All County Promotion', aRes[1]);//document.getElementById("msgerror5").innerHTML=aRes[1];
				}
				if(systemwhat==1)location.href='properties_search.php';
				else location.href='pagmenu1.php';
			}
			else
				document.getElementById("msgerror5").innerHTML=aRes[1];	
			//document.getElementById("waitGuarda").style.visibility="hidden";
		} //fin de ajax readyState
	}//fin de ajax.onreadystatechange

}

function close_login_win_commercial(user,close)
{
	//loading_win.show();
	var newprice=document.getElementById("newprice").value;
	var proratecommercial=document.getElementById("proratecommercial").value;
	var pricecommercial=document.getElementById("pricecommercial").value;
	//if(close==0 && 	document.getElementById("chcommercial").checked==false)close=1;
	var parametros="oper=ActivateCommercialAskLogin&userid="+user+"&newprice="+newprice+"&proratecommercial="+proratecommercial+"&pricecommercial="+pricecommercial+"&close="+close;
//alert(parametros);	return;		
	var ajax=nuevoAjax();
	ajax.open("POST", "includes/properties_updateuser.php", true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send(parametros);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)	
		{
			var results=ajax.responseText;
//alert(results);return;
			var aRes=results.split("^");
			//loading_win.hide();
			if(aRes[0]>0)
			{
				login_win_commercial.hide()
				if(aRes[0]==1)
				{
					Ext.Msg.alert('New Residential and Commercial Version', aRes[1]);//document.getElementById("msgerror5").innerHTML=aRes[1];
				}
				if(systemwhat==1)location.href='properties_search.php';
				else location.href='pagmenu1.php';
			}
			else
				document.getElementById("msgerror5").innerHTML=aRes[1];	
			//document.getElementById("waitGuarda").style.visibility="hidden";
		} //fin de ajax readyState
	}//fin de ajax.onreadystatechange

}	

function wizard_byowner()
{
	
}
