function LoadValueFromCookies()
{	if(GetCookie('name'))
	{	$id('txtName').value = GetCookie('name');
	//	$id('txtPhone').value = GetCookie('phone');
		$id('txtEmail').value = GetCookie('email');
		$id('txtLastName').value = GetCookie('lastname');
		if($id('txtLoginEmail') != null)
		$id('txtLoginEmail').value = GetCookie('email');}
}
function switchText(object, baseText, eventName)
{	if (eventName == "blur"){
			if (object.value == ""){
				object.value = baseText;}
	}else{	if (object.value == baseText){object.value = "";}
}}
function $id(elementId){
    var element=null;
    if (typeof elementId == 'string'){element = document.getElementById(elementId);}
    return element;}

function SetCookie(name,value,days) {
	if (days) {var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function GetCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}
	return null;
}
function DeleteCookie(name) {createCookie(name,"",-1);}
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i; 
   if (strEmail.search(validRegExp) == -1) {return false;} 
    return true; 
}
/*function isValidPhone(strPhone){
  validRegExp = '^\\(\\d{3}\\)?\\d{3}( |-)?\\d{4}|^\\d{3}( |-)?\\d{3}( |-)?\\d{4}'; 
   if (strPhone.search(validRegExp) == -1) {return false;} 
    return true; 
}*/
function PopupWebsite(obj)
{	var url = $id(obj).value;
	if(url.length ==0) return false;
	window.open('http://'+ url);
}
function ShowImage(ref){window.open("../ViewImage.aspx?ImgSrc="+ref,'ViewImage',"dialogWidth:930px;dialogHeight:730px;top:100px;left:100px;status:0;scroll:1;resizable:yes;");}
var timerlen = 8;
var slideAniLen = 250;
var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();
function slidedown(objname){
        if(moving[objname]){ return;}
        if(document.getElementById(objname).style.display != "none"){ return;}
        moving[objname] = true;
        dir[objname] = "down";
        startslide(objname);
}
function slideup(objname){
        if(moving[objname]) return;
        if(document.getElementById(objname).style.display == "none"){return;}
        moving[objname] = true;
        dir[objname] = "up";
        startslide(objname);
}
function startslide(objname){
        obj[objname] = document.getElementById(objname);
        endHeight[objname] = parseInt(obj[objname].style.height);
        startTime[objname] = (new Date()).getTime();
        if(dir[objname] == "down"){obj[objname].style.height = "1px";}
        obj[objname].style.display = "block";
        timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
}
function slidetick(objname){
        var elapsed = (new Date()).getTime() - startTime[objname];
        if (elapsed > slideAniLen){endSlide(objname)}
        else {  var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
                if(dir[objname] == "up"){d = endHeight[objname] - d;}
                obj[objname].style.height = d + "px";
    }return;
}
function endSlide(objname){
        clearInterval(timerID[objname]);
        if(dir[objname] == "up"){obj[objname].style.display = "none";}
        obj[objname].style.height = endHeight[objname] + "px";
        delete(moving[objname]);
        delete(timerID[objname]);
        delete(startTime[objname]);
        delete(endHeight[objname]);
        delete(obj[objname]);
        delete(dir[objname]);
        return;
}
function ValidateData(objFirstname,objLastname,objPhone,objEmail,ObjMoveinDate)
{	var Firstname = objFirstname.value;
	var Lastname = objLastname.value;
	//var phone = objPhone.value;
	var phone = "";
	var email = objEmail.value;
	var MoveinDate = ObjMoveinDate.value;	
	var flag = true;
	if(Firstname=='First name'|| Firstname=='' ) {objFirstname.value = '';objFirstname.focus();flag=false;}
	if(Lastname=='Last name'|| Lastname=='' ) {objLastname.value = '';objLastname.focus();flag=false;}
	if(MoveinDate=='' ) {ObjMoveinDate.focus();flag=false;}		
	if(email=='Email' || email==''){objEmail.value='';objEmail.focus();flag=false;}
	else if(!isValidEmail(email)){alert('Please enter a valid email address.');objEmail.value='';objEmail.focus();return false;}	
	/*if(phone=='Phone' || phone==''){objPhone.value='';objPhone.focus();flag=false;}
	else if(!isValidPhone(phone)){alert('Please enter a valid phone number.');objPhone.value='';objPhone.focus();return false;}	
	*/
	if(!flag){alert("Before gaining access you must register for FREE on the homepage. All fields required.");}
	return flag;
}
function changecolor(element, CSSclass) { element.className=CSSclass;}
function ShowLoginAlert(msg){alert(msg);}
function SetInnerHtml(objID,objValue)
{	if(navigator.userAgent.indexOf("Safari") >= 0){
		if(document.getElementById(objID)!=null)
			document.getElementById(objID).innerHTML=objValue;}
}
function RedirectToAnotherPage(msg,redirectURL)
{	ShowLoginAlert(msg);			
	window.location.href= redirectURL;}

function ViewUserinfoBlock(trUserInfo,divMoveinDate1)
{	if(document.getElementById(trUserInfo)!=null){document.getElementById(trUserInfo).style.display='block';}
	if(document.getElementById(divMoveinDate1)!=null){document.getElementById(divMoveinDate1).style.display='block';}
}
function SetFocusSC(lnkLetsGo,dvBtn,txtVC,spanCallmsg)
{	if($id(lnkLetsGo)!=null){
		if(document.getElementById(dvBtn).style.visibility!='hidden')
			$id(lnkLetsGo).focus();}		
	if($id(txtVC)!=null){$id(txtVC).focus();}	
	if(document.getElementById(dvBtn)!=null){document.getElementById(dvBtn).style.visibility='hidden';}	
	if(document.getElementById(spanCallmsg)!=null){document.getElementById(spanCallmsg).style.display='block';}
}
function SetCookies(Fname,Lname,phone,email)
{
// imtiaz
phone ="";	
SetCookie( 'name', Fname, 11);
	SetCookie( 'phone', phone, 11);
	SetCookie( 'email', email, 11);
	SetCookie( 'lastname', Lname, 11);	
}
function OpenPrintPopup(buildingid,LISTINGID,type)
{	if(type=="Detail"){window.open("http://skipbrokers.com/Utils/PrintPreviewPopup.aspx?Detail='Detail'&BuildingID="+buildingid+"&ListingID="+LISTINGID,"PrintPopup","location=0,status=0,scrollbars=yes,resizable=1,width=750,height=750,top=10,left=200");}
	else if(type=="Search"){window.open("http://skipbrokers.com/PrintPreviewPopup.aspx?Search='Search'&BuildingID="+buildingid+"&ListingID="+LISTINGID,"PrintPopup","location=0,status=0,scrollbars=1,resizable=0,width=750,height=250; top=300px;left=200px;");}		
}
function OpenMail(buildingid,LISTINGID,type)
{	if(type=="Detail"){window.location.href="http://skipbrokers.com/Utils/EmailToFriend.aspx?Detail='Detail'&BuildingID="+buildingid+"&ListingID="+LISTINGID;}
	else if(type=="Search"){parent.window.location.href="http://skipbrokers.com/Utils/EmailToFriend.aspx?Search='Search'&BuildingID="+buildingid+"&ListingID="+LISTINGID;}
}
function ViewBuildingImages(BuildingID){window.open("/Properties/ViewPhotosPopup.aspx?BuildingID="+BuildingID,"BuildingImage","location=0,status=0,scrollbars=1,resizable=yes,width=800px,height=600px; top=100px;left=100px;");}		
function ViewListingImages(ListingID){window.open("/Properties/ViewPhotosPopup.aspx?ListingID="+ListingID,"ListingImage","location=0,status=0,scrollbars=1,resizable=yes,width=800px,height=600px; top=100px;left=100px;");}

function OpenSubscription(){parent.window.location.href="/Subscription/PrePayment.aspx";}

function PropertyDetail(BUILDINGID,LISTINGID,QS){parent.window.location.href="../Properties/PropertyDetail.aspx?BuildingID="+BUILDINGID+"&ListingID="+LISTINGID+"&QS="+QS;}
function ScrolltoTop(){parent.document.body.scrollTop=0;}