﻿//Copyright 2view Media ARR
function openWindow(url,features){winpops=window.open(url,"",features,"");}
function getCookie(c){var dc=document.cookie;if(dc.length>0){begin = dc.indexOf(c);if(begin!=-1){begin+=c.length;end=dc.indexOf(";",begin);if(end==-1)end=dc.length;return unescape(dc.substring(begin, end));}}return null;}
function saveListing(pid,mlsid){if(getCookie('subscriber=')==null){alert('You must login to save listings.  Click the subscribers tab above to login or register.');}else{window.location='/subscribers/listings/?q=add&pid='+pid+'&mlsid='+mlsid;}}
function $(e){if(typeof e=='string')e=document.getElementById(e);return e};
function iClear(o,iv){if(o.value==iv){o.value='';}}
function collect(a,f){var n=[];for(var i=0;i<a.length;i++){var v=f(a[i]);if(v!=null)n.push(v)}return n};
ajax={};
ajax.x=function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}};
ajax.serialize=function(f){var g=function(n){return f.getElementsByTagName(n)};var nv=function(e){if(e.name)return encodeURIComponent(e.name)+'='+encodeURIComponent(e.value);else return ''};var i=collect(g('input'),function(i){if((i.type!='radio'&&i.type!='checkbox')||i.checked)return nv(i)});var s=collect(g('select'),nv);var t=collect(g('textarea'),nv);return i.concat(s).concat(t).join('&');};
ajax.send=function(u,f,m,a){var x=ajax.x();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseText)};if(m=='POST')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a)};
ajax.get=function(url,func){ajax.send(url,func,'GET')};
ajax.gets=function(url){var x=ajax.x();x.open('GET',url,false);x.send(null);return x.responseText};
ajax.post=function(url,func,args){ajax.send(url,func,'POST',args)};
ajax.update=function(url,elm){var e=$(elm);var f=function(r){e.innerHTML=r};ajax.get(url,f)};
ajax.submit=function(url,elm,frm){var e=$(elm);var f=function(r){e.innerHTML=r};ajax.post(url,f,ajax.serialize(frm))};
var _ddZ = 1;
function DropDownMenu(tab,container) { 
    this.t = $(tab);
    this.c = $(container);
    this.to = null;
    this.cl = null;
    
    var self = this;
    this.t.onmouseover = function() { self.Expand(); }
    this.t.onmouseout = function() { self.to = setTimeout(function() { self.Contract(); },300); }
    this.c.onmouseover = function() { self.Expand(); }
    this.c.onmouseout = function() { self.to = setTimeout(function() { self.Contract(); },300); }
}
DropDownMenu.prototype.Expand=function(){clearTimeout(this.to);if(this.cl==null && this.cl!=this.t.className)this.cl=this.t.className;this.c.style.display='block';this.c.style.zIndex=++_ddZ;this.t.className='hover';this.Align();}
DropDownMenu.prototype.Contract=function() {this.c.style.display='none';this.t.className=this.cl;}
DropDownMenu.prototype.Align = function() {this.c.style.left=this.t.offsetLeft+'px';var oB=0;var p=this.t.parentNode;while(p!=null){if(p.offsetTop){oB+=p.offsetTop;}p=p.parentNode;}this.c.style.top=oB + this.t.clientHeight+'px';}
var ct = 't1';var cd = 'd1';
function openTab(tab,data) {$(ct).className = '';$(cd).style.display = 'none';ct = tab;cd = data;$(ct).className = 'on';$(cd).style.display = 'block';  }
function expandTree(){if(area != '') {var ele = $('a_'+area);if(ele){ele.className = 'on';if(ele.nextSibling){ele.nextSibling.style.display = 'block';}}if(burb != '') {var ele2 = $('s_'+burb);if(ele2){ele2.className = 'on';} }}}
function bookmark(url,title) {if ( window.external) { window.external.AddFavorite(url,title) } else { alert("Sorry! Your browser doesn't support this.  Try bookmarking the page manually :)"); } }

function OpenFullScreen(url,page) { 
    //Check browser
    var isNav = (navigator.appName.indexOf("Netscape")  != -1) ? true : false; 
    var isIE  = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
    //Check Platform 
    var isMac = (navigator.platform.indexOf("Mac") > -1) ? true : false; 
    var isWin = (navigator.platform.indexOf("Win") > -1) ? true : false; 
    //Set global window options
    var opts = "toolbar=no,location=no,status=no,directories=no,scrollbars=no,resizable=yes,menubar=no";
    //Set platform and browser specific options
    if (isNav) {    
        opts += ",width=" + screen.availWidth + ",height=" + screen.availHeight + ",screenX=0,screenY=0";
    } 
    else if (isIE) { 
        opts += ",left=0,top=0";
        if (isMac) { 
            opts += ",width=" + (screen.availWidth - 13) + ",height=" + (screen.availHeight - 32); 
        } 
        else if (isWin) {
            if (navigator.appVersion.indexOf("MSIE 7") != -1) {            
                opts += ",fullscreen=yes";
            }
            else {
                opts += ",width=" + (screen.availWidth - 12) + ",height=" + (screen.availHeight - 25); 
            }
        } 
        else { 
            opts += ",width=" + screen.availWidth + ",height=" + screen.availHeight; 
        } 
    }
    else { 
      return;
    } 
    
	if (page == "media")
		url += "&w=" + screen.availWidth + "&h=" + screen.availHeight;
        
    //open a new window 
    var winMedia = window.open(url, "_blank", opts); 
    winMedia.focus(); 
    //Move to 0,0 (javascript 1.2) 
    if (parseInt(navigator.appVersion) >= 4) { 
        //winMedia.moveTo(0,0); 
    } 
}