/*
	popstuff
	function to automatically add popup window calls to each link
	with a target
*/
// set up some parameters so window relates to the parent window

if (window.parent.innerWidth) var w = window.parent.innerWidth-80;
else if (parent.document.body.offsetWidth) var w = parent.document.body.offsetWidth-80;

if (window.parent.innerHeight) var h = window.parent.innerHeight-30;
else if (parent.document.body.offsetHeight) var h = parent.document.body.offsetHeight-50;

if (window.parent.screenX) var l = window.parent.screenX+30;
else var l = 30;

if (window.parent.screenY) var t = window.parent.screenY+30;
else var t = 30;


function countEmail(listid,linktype)
{
	var myrequrl = "mail-tracker.php?id="+listid;
    if (linktype!=""||linktype!="undefined") myrequrl+="&type="+linktype;
	if (window.XMLHttpRequest) {
        myreq = new XMLHttpRequest();
        myreq.open("GET", myrequrl, true);
        myreq.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        myreq = new ActiveXObject("Microsoft.XMLHTTP");
        if (myreq) {
            myreq.open("GET", myrequrl, true)
            myreq.send();
        }
    }
}

function countEvent(evtable,evid)
{
	var myrequrl = "event-tracker.php?table="+evtable+"&id="+evid;
    	if (window.XMLHttpRequest) {
        myreq = new XMLHttpRequest();
        myreq.open("GET", myrequrl, true);
        myreq.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        myreq = new ActiveXObject("Microsoft.XMLHTTP");
        if (myreq) {
            myreq.open("GET", myrequrl, true)
            myreq.send();
        }
    }
}

function initpop()
{
	var windowAttributes='width='+w+',height='+h+',left='+l+',top='+t+', scrollbars=yes, location=yes, resizable=yes, status=yes';
	var mtoAttributes = 'width=10,height=10,left=0,top=0,scrollbars=no,location=no,resize=no';
	var as,i,popfun;
	as=document.getElementsByTagName('a');
	for (i=0;i<as.length;i++)
	{
		if(as[i].target && !as[i].onclick && as[i].target.indexOf("_blank")>-1)
		// keeps it from cancelling out Highslide events and parent links
		{
			popfun=function(){window.open(this.href,'',windowAttributes);return false;};  //
			as[i].onclick=popfun;
			as[i].onkeypress=popfun;
		}
     }
     	for (i=0;i<as.length;i++)
	{
		if (as[i].href=="mailto:info@welcometostratford.com")
		{
                popfun=function(){window.open('infoconversion.html','',mtoAttributes);return false;};  //
		    as[i].onclick=popfun;
		    as[i].onkeypress=popfun;
		}
	}
}

// With thanks to Scott Andrew
function addEvent(obj, evType, fn)
{
	if (obj.addEventListener)
	{
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}


addEvent(window,'load',initpop);


