// JavaScript Document
function createMessageObj()
{
	//Used:
	//studenthousingRoot1.master
	
	messageObj = new DHTML_modalMessage();	// We only create one object of this class
	messageObj.setShadowOffset(5);	// Large shadow	
	
}

function pageSettings(messageContent, cssClass, pgname)
{
	//Used:
	//studenthousingRoot1.master
	
	//alert("GHJGHJ");
	if(document.getElementById("ctl00_idheader_logn").innerHTML == "Logout"){
		window.location = '/logout.aspx';
	}else{
	var messageContent = '<div id="loginpopup"><div class="header"><div class="lcorner"></div><div class="stitle"></div><div style="height:10px"></div><div class="alerthead" style="height:20px">&nbsp;Member Login&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="/imagesApr/closebox.gif" onclick="closeModel();" /></div><div class="line">&nbsp;</div><div class="clear" style="height:10px">&nbsp;</div></div><div class="mbox"><table><tr><td style="text-align:right;color:#2a76b0" >&nbsp;&nbsp;Email:</td><td><input type="text" id="txtEmail" style="padding:2px;" Width="180px"/></td></tr><tr><td style="text-align:right;color:#2a76b0">&nbsp;&nbsp;Password:</td><td><input type="password" style="padding:2px;" ID="txtPassword" Width="180px" /> </td></tr><tr><td></td><td> <dd class="forgetpwd"><a ID="lnkForgotPassword" href="/forgot-password.aspx">Forgot Password?</a></td></tr><tr><td style="height:15px"></td><td><span id="ctl00_msger"></span></td></tr><tr><td style="text-align:left"> <input type="button"  onclick="chekUser2(\'' + pgname + '\');" ID="btnSubmit2" runat="server" Value="Login!"></td><td></td></tr> </table></div> </div><div style="text-align:center"></div>';
		messageObj.setHtmlContent(messageContent);
		messageObj.setSize(285,170);
		//messageObj.setCssClassMessageBox(cssClass);
		messageObj.setSource(false);	// no html source since we want to use a static message here.
		messageObj.setShadowDivVisible(false);	// Disable shadow for these boxes	
		messageObj.display();
	}
}

function searchBoxClick()
{
	//Used:
	//studenthousingRoot.master
	//studenthousingRoot1.master
	
	document.getElementById('ctl00_idheader_txtaptSearch').value = '';
}

function checkLogin()
{
	//Used:
	//studenthousingRoot1.master
	
	if(document.getElementById("ctl00_idheader_logn").innerHTML == "Logout")
	{
	  window.location = "/myaccount.htm";
	}
	else
	{
	 window.location = "/my-account.aspx";
	}
   
}

function valiadteUser2(pgname)
{
	//Used:
	//studenthousingRoot1.master
	    
   
	var arrObj = new Array();
	var checkFlag = true;
	var ErrMsg = '';
   
	if(isBlank(document.getElementById("txtEmail")))
	{
		arrObj.push(document.getElementById("txtEmail"));
		ErrMsg = ErrMsg + '* Email address field is required!\n';
		checkFlag = false;
	}    
	
	 if(isBlank(document.getElementById("txtPassword")))
	{
		arrObj.push(document.getElementById("txtPassword"));
		ErrMsg = ErrMsg + '* Password field is required!\n';
		checkFlag = false;
	}    
   
   
		
   // alert(txtmanagerEmail);
	else if(!isValidEmail(document.getElementById("txtEmail")))
	{
		arrObj.push(document.getElementById("txtEmail"));
		ErrMsg = ErrMsg + '* Please enter valid Email address!\n';
		checkFlag = false;
	}
	
   
   
  if(!checkFlag)
	{
		arrObj[0].focus();
		alert(ErrMsg);
					
		return false;                
	}
	else
	{
	 var uname = document.getElementById("txtEmail").value;
	 var pass = document.getElementById("txtPassword").value;
	 var patth="";
	 var qstring="";
	try
	{
	  // alert(globalPat);
		 qstring=globalString;
		
		 patth =globalPat; 
	 }
	 catch(err)
	 {
	 
	 }
	//alert("DSFSDF");
	checkUserAxLogin(uname , pass, pgname,patth,qstring)
	   return true;                
  }
}

function callOnSearch(txt)
{
	//Used:
	//studenthousingRoot1.master
	
	var checkFlag = true;

	if(isBlanknew(txt)||txt.value=='Apartment Name, City, State or Zip Code')
		checkFlag = false;
     
	if(!checkFlag)                          
		return false;                
}

function callOnSearch()
 {       
 	//Used:
	//studenthousingRoot.master
	
	var arrObj = new Array();
	var checkFlag = true;
	var ErrMsg = '';
	
	var txt=document.getElementById('ctl00_idheader_txtaptSearch');
	
	if(isBlanknew(txt)||txt.value=='Apartment Name, City, State or Zip Code')
	{
	
	 checkFlag = false;
	}      
	
	if(!checkFlag)
	{
						
		return false;                
	}
}
	  
function isBlanknew(oReff)
{
	//Used:
	//studenthousingRoot.master
	//studenthousingRoot1.master
	
	var checkFlag;
	if(trim(oReff.value).length <= 0)
		checkFlag = true;
	else
		checkFlag = false;
	return checkFlag;
}
   
function trim(str)
{
	//Used:
	//studenthousingRoot.master
	//studenthousingRoot1.master
	
	return str.replace(/^\s+|\s+$/g, '');
}


function openSignUpPopUp()
{
	//Used:
	//studenthousingRoot1.master
	
	var confirmWin = null;
	var height='470';
	var width='321';
	var size='no';
	y = (screen.availHeight - height)/2;
	x = (screen.availWidth - width)/2;
	var attrib="width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=no," + 
		  "status=no,toolbar=no,directories=no,menubar=no,location=no,screenX="+x+",screenY="+y+",top="+y+",left="+x;   
	confirmWin=window.open("/advice-signup.aspx",null,attrib);
	
	if((confirmWin != null) && (confirmWin.opener==null))
		confirmWin.opener = self;
}

function closeModel()
{
	//Used:
	//studenthousingRoot1.master
	
	messageObj.close();
}

function chekUser2(pgname)
{
	//Used:
	//studenthousingRoot1.master

    valiadteUser2(pgname);
}   

function displayStaticMessage1(messageContent,cssClass,pgname)
{
	//Used:
	//studenthousingRoot1.master
	
	closeSignUpDiv();
	pageSettings(messageContent, cssClass, pgname);
}

function callAjaxtoSave()
{
	//Used:
	//studenthousingRoot1.master
	
	//messageObj.close();
}

function closeMessage()
{
	//Used:
	//studenthousingRoot1.master
	
	document.getElementById("imgsav").innerHTML = "Saved Successfully............."
	//messageObj.close();	
}

function openSignUpDiv(raterental)
{
	//Used:
	//studenthousingRoot1.master
    if (raterental == 'true') {
        document.getElementById("raterental").value = "true";
    }
	var divBack = document.getElementById("divBack");        
	var gsignup = document.getElementById("signup");
	divBack.style.display="block";

	var arrayPageSize = getPageSize();
	
	divBack.style.width = arrayPageSize[0] + 'px';
	divBack.style.height = arrayPageSize[1] + 30 + 'px';
						  
	gsignup.style.display="block"; 
}

function closeSignUpDiv()
{
	//Used:
	//studenthousingRoot1.master
	  
	var gesignup = document.getElementById("signup"); 
	var divBack = document.getElementById("divBack");       
	gesignup.style.display="none";
	divBack.style.display = "none";
}

function validateForm()
{
	//Used:
	//studenthousingRoot1.master
	
	var arrObj = new Array();
	var checkFlag = true;
	var ErrMsg = '';
	//raterental = document.getElementById("raterental");
	fName = document.getElementById("fname");
	lName = document.getElementById("lname");
	Email = document.getElementById("email");
	Password = document.getElementById("password");
	RetypePassword = document.getElementById("retypepassword");
	Location = document.getElementById("location");                
	 
	if(isBlank(fName))
	{
		arrObj.push(fName);
		ErrMsg = ErrMsg + '*  First Name field is required!\n';
		checkFlag = false;
	}
	
	if(isBlank(lName))
	{
		arrObj.push(lName);
		ErrMsg = ErrMsg + '*  Last Name field is required!\n';
		checkFlag = false;
	}
	
	if(isBlank(Email))
	{
		arrObj.push(Email);
		ErrMsg = ErrMsg + '*  Email field is required!\n';
		checkFlag = false;
	}
	
	else if(!isValidEmail(Email))
	{
		arrObj.push(Email);
		ErrMsg = ErrMsg + '*  Please enter valid Email address!\n';
		checkFlag = false;
	}
	if(isBlank(Password))
	{
		arrObj.push(Password);
		ErrMsg = ErrMsg + '*  Password field is required!\n';
		checkFlag = false;
	}
	
	else if(!isValidPassword(Password))
	{
		arrObj.push(Password);
		ErrMsg = ErrMsg + '*  Please enter valid Password!\n';
		checkFlag = false;
	}
	
	if(isBlank(RetypePassword))
	{
		arrObj.push(RetypePassword);
		ErrMsg = ErrMsg + '*  Retype Password field is required!\n';
		checkFlag = false;
	}
	
	else if(!isValidPassword(RetypePassword))
	{
		arrObj.push(RetypePassword);
		ErrMsg = ErrMsg + '*  Please enter valid Retype Password!\n';
		checkFlag = false;
	}
	
	else if(!isConfirm(Password,RetypePassword))
	{
		 arrObj.push(Password);
		 ErrMsg = ErrMsg + '*  Password Confirmation Failed.Please Re-Enter Your Passwword in the Password confirmation Field!\n';
		 checkFlag = false;
	}
	
	if(isBlank(Location))
	{
		arrObj.push(Location);
		ErrMsg = ErrMsg + '*  Location field is required!\n';
		checkFlag = false;
	}        
	
	if(!checkFlag)
	{
		arrObj[0].focus();
		alert(ErrMsg);
						
		return false;                
	}
	else
	{           
		ExecuteCall(Email.value);                                                     
	}
}

function getPageSize()
{
	//Used:
	//studenthousingRoot1.master
		
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) 
	{	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} 
	else 
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) 
	{	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) 
	{ // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function SearchOpen()
{
	//searchRoot2.master
	var txtId=document.getElementById('ctl00_idheader_txtaptSearch')
	var text=document.getElementById('ctl00_idheader_txtaptSearch').value;
	
	if(isBlanknew(txtId)||text=='Apartment Name, City, State or Zip Code')
	{
		return false;
	}
	else
	{
		window.location="/SearchProcess.aspx?txt="+text;
		return true;
	}  
}

function openSignUpDiv1()
{     
	//searchRoot5.master
	closeModel();
	var divBack = document.getElementById("divBack");     
	var  gsignup; 
	gsignup = document.getElementById("signup");
	gsignup.style.display="block";    
	
	divBack.style.display="block";
	
	//---------------
	var arrayPageSize = getPageSize();
	
	divBack.style.width = arrayPageSize[0] + 'px';
	divBack.style.height = arrayPageSize[1] + 30 + 'px';
	//---------------
	   
}

function redirectToPrivacyPolicy()
{
	//masterFavroit.master
	window.location="privacy-policy.aspx";        
}

function redirectToLogin()
{
	//masterFavroit.master
	window.location = "/my-account.aspx";                
}
