﻿// JScript File
function validateSoldForm()
{
    var ErrMsg = '';
	var flag = true;
	if ((document.getElementById("ctl00_MasterTopFooter_txtSoldName").value == "") || (document.getElementById("ctl00_MasterTopFooter_txtSoldName").value.length==0) ||(document.getElementById("ctl00_MasterTopFooter_txtSoldName").value==null))
	{
		ErrMsg+="Please Enter Name \n";
	}
	
	if((document.getElementById("ctl00_MasterTopFooter_txtSoldEmail").value == "") || (document.getElementById("ctl00_MasterTopFooter_txtSoldEmail").value.length==0) ||(document.getElementById("ctl00_MasterTopFooter_txtSoldEmail").value==null))
	{
		ErrMsg+="Please Enter E-Mail Address \n";
	}
	
	if ((document.getElementById("ctl00_MasterTopFooter_txtSoldEmail").value.length!=0) && (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("ctl00_MasterTopFooter_txtSoldEmail").value)==false))
	{
		ErrMsg+="Invalid Email Address \n";
	}
	if (ErrMsg != '')
	{
		alert(ErrMsg);
		flag=false;
		return flag;
	}
	else
	{ 
	    
	}
}

function CloseMessage()
 {
    if(document.getElementById("NotLoggedIn"))
            {
                document.getElementById("NotLoggedIn").style.display="none";
            }
 }
 function ShowMeEverything()
    {
    var obj=document.getElementById("spnShowme")
   
    if (document.getElementById("trExtraDetail")!=null)
        {
            if (document.getElementById("trExtraDetail").style.display=='none')
            {
            document.getElementById("trExtraDetail").style.display='Block'
            document.getElementById("spnShowme").innerHTML=="";
            document.getElementById("spnShowme").innerHTML="Show Me less"
             document.getElementById("SpnAdd").innerHTML=""
            document.getElementById("SpnAdd").innerHTML="-"
            }
            else
            {
             document.getElementById("spnShowme").innerHTML=="";
             document.getElementById("spnShowme").innerHTML="Show Me Everything"
            document.getElementById("SpnAdd").innerHTML=""
            document.getElementById("SpnAdd").innerHTML="+"
             document.getElementById("trExtraDetail").style.display='none'
            }
        }
    }
   
   function Popuprental(ComplexName,PropertTypeName,RentalAddress)
   {
    	    theURL='../MLSListings/popuprental.aspx?ComplexName='+ComplexName+'&PropertTypeName='+PropertTypeName+'&Address='+RentalAddress; 
			winName="LuxuryRentals";
			features="width=500,height=550,scrollbars=yes,resizable=yes";
			window.open(theURL,winName,features);
   }
   
    function HideHeaderPrint111()
    {
    if (document.getElementById('header'))
    {
    document.getElementById('header').style.display='none';
    document.getElementById('trNextStep').style.display='none';
    document.getElementById('trAgent').style.display='none';
    document.getElementById('trRecent').style.display='none';
    document.getElementById('trSearch').style.display='none';
    if (document.getElementById('footer'))
    document.getElementById('footer').style.display='none';
    document.getElementById('trComment').style.display='none';
    document.getElementById('ListingAgentInfo').style.display='none';

    document.getElementById("PrintButton").style.display="block";
    return false;
    document.getElementById('header').style.display='block';
    document.getElementById('trNextStep').style.display='block';
    document.getElementById('trAgent').style.display='block';
    document.getElementById('trRecent').style.display='block';
    document.getElementById('trSearch').style.display='block';
    if (document.getElementById('footer'))
    document.getElementById('footer').style.display='block';
    document.getElementById('trComment').style.display='block';
    document.getElementById('ListingAgentInfo').style.display='block';
    }
    }
    var imgWidth;
    var imgHeight;
    function GetImagesWidth_Height()
    {
	    var args=GetImagesWidth_Height.arguments;
	    imgWidth=args[0];
	    imgHeight=args[1];
    }
    
    function ShowPrintDiv()
    {
        if(document.getElementById("main"))
                    document.getElementById("main").style.display="none";
        if(document.getElementById("footer"))
                    document.getElementById("footer").style.display="none";
        if(document.getElementById("divPrintDetails"))
            document.getElementById("divPrintDetails").style.display="BLOCK";
            window.print()
            if(document.getElementById("main"))
                    document.getElementById("main").style.display="BLOCK";
        if(document.getElementById("footer"))
                    document.getElementById("footer").style.display="BLOCK";
        if(document.getElementById("divPrintDetails"))
            document.getElementById("divPrintDetails").style.display="none";
    }    
   
    function ShowHideEstimate()
    {
        if (document.getElementById("divEstimate"))
        {
            if (document.getElementById("divEstimate").style.display=="none")
            {
                document.getElementById("divEstimate").style.display="BLOCK";
            }
            else
            {
                document.getElementById("divEstimate").style.display="none";
            }
        }
    }
    function ShowHideDivs()
    {
        var args = ShowHideDivs.arguments;
        if (document.getElementById(args[0]))
        {
            if (document.getElementById(args[0]).style.display=="none")
            {
                document.getElementById(args[0]).style.display="BLOCK";
            }
            else
            {
                document.getElementById(args[0]).style.display="none";
            }
        }
    }
    
    function ShowWhyBrokerInfo()
    {
        if (document.getElementById("divWhyBrokerInfo"))
        {
            if (document.getElementById("divWhyBrokerInfo").style.display=="none")
            {
                document.getElementById("divWhyBrokerInfo").style.display="BLOCK";
            }
            else
            {
                document.getElementById("divWhyBrokerInfo").style.display="none";
            }
        }
    }
    function changePhoto(idx)
    {
	     var width,height
	     document.getElementById("photo").src = eval('img' + idx).src;
	     width = imageWidthCondo[idx];
         height = imageHeightCondo[idx];
	     fitPic(width,height);
    }
    
	function imageWindowdevelopment(imgCount,ListingID)
	{
		
		theURL='ShowMoreImages.aspx?End='+ imgCount + "&ID=" + ListingID ; 
			winName="ExclusiveListingsImages";
		features="width=550,height=560";
		window.open(theURL,winName,features);
	}
    function NewWindowSchool(url)
    {
        winName="SchoolReports";
        features="width=550,height=510,scrollbars=1";
        window.open(url,winName,features);
    }
    function openwindow1()
	{//alert(theURL)
		var args=openwindow1.arguments;
		winName="Condodomain";
		if(args[1]!="")
		{
		    features="width=300,height=200,scrollbars=1";
		}
		else
		{
		    features="width=300,height=200,scrollbars=1";
		}
		window.open(args[0],winName,features);
	}
	function openwindowForLinks()
	{//alert(theURL)
		var args=openwindowForLinks.arguments;
		winName="Condodomain";
		
		    features="width="+args[3]+",height="+args[4]+",scrollbars=1";
		var TheUrl=args[0]+"?ListingID="+args[1]+"&mls="+args[2];
		
		
		window.open(TheUrl,winName,features);
	}
	
	function OpenReportsPopup()
	{
		var args=OpenReportsPopup.arguments;
		winName=args[0];
		if (args[3]=='' || args[3]=='undefined')
		{
		    TheUrl=args[1];
		    
		}
		else
		{
		    TheUrl=args[1]+"?Zip="+args[3];
		}
		features=args[2];
		window.open(TheUrl,winName,features);
	}
	
	function fitPic(imgW,imgH) 
    {
       var objPhoto;
       var i,width, height;
       objPhoto = document.getElementById('photo');
       var imgMaxWidth=410;
       var imgMaxHeight=283;
       if(!(imgW) && !(imgH))
       {
         width = objPhoto.width;
         height = objPhoto.height;
         ratio = width/height;             
       }
       else
       {
         width = imgW;
         height = imgH;
         ratio = imgW/imgH; 
         objPhoto.width = imgW;
         objPhoto.height= imgH;              
       }
         if(width>imgMaxWidth && height>imgMaxHeight)
         {
          objPhoto.width=imgMaxWidth;
          objPhoto.height=imgMaxWidth/ratio;
         } 
         if(width>imgMaxWidth && height<imgMaxHeight)
         {
          objPhoto.width = width/ratio;
          objPhoto.height= height;
         }

         if(width<imgMaxWidth && height>imgMaxHeight)
         {
          ratio = width/imgMaxHeight; 
          objPhoto.width = width/ratio;
          objPhoto.height = imgMaxHeight;
         }
         if (objPhoto.width>=imgMaxWidth )
	     {
		    objPhoto.width=imgMaxWidth;
			
	     }
	     if(objPhoto.height>=imgMaxHeight)
	     {
	        objPhoto.height=imgMaxHeight;
	     }
	     objPhoto.width="410"
	     objPhoto.height="283" 
    }