//JK Popup Window Script (version 3.0)- By JavaScript Kit (http://www.javascriptkit.com)
//Visit JavaScriptKit.com for free JavaScripts
//This notice must stay intact for legal use
//Win Type: Pop Under | Session Only
    
//Specify URLs to randomly select from and popup/popunder:
//To display a single URL, just remove all but the first entry below:
var popurls=new Array()
popurls[0]="http://www.eldercarelinkdirectory.com/listings.php?src=ecl";
popurls[1]="pophcsurvey1.aspx"+window.location.search;

function openpopup(popurl){
    w=800
    h=600
    var p = "toolbar,location,status,scrollbars,menubar,resizable";
    if (window.screen) { 
        w = window.screen.availWidth; 
        h = window.screen.availHeight; 
        p = p + ",height="+h+", width="+w+",top=0,left=0";
    }else{
        p = p + ',fullscreen';
    }
    var winpops=window.open(popurl,"",p)
    winpops.blur()
    window.focus()
}

function get_cookie(Name) {
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search)
        if (offset != -1) { // if cookie exists
            offset += search.length
            // set index of beginning of value
            end = document.cookie.indexOf(";", offset);
            // set index of end of cookie value
            if (end == -1)
                end = document.cookie.length;
                returnvalue=unescape(document.cookie.substring(offset, end))
            }
        }
    return returnvalue;
}

function loadornot(index){
    if (get_cookie('jkpopup'+index)==''){
        openpopup(popurls[index])
        document.cookie="jkpopup"+index+"=yes"
    }
}

var surveyRule = {
	'.openPopUnder' : function(element){
		element.onclick = function(){
			loadornot(1);
		}
	}
};

var dirRule = {
	'.openDirPopUnder' : function(element){
		element.onclick = function(){
			loadornot(0);
		}
	}
};
	
Behaviour.register(surveyRule);
Behaviour.register(dirRule);