//Javascript DOM Helper
function domFunction(f, a){
	var n = 0;
	var t = setInterval(function()	{
		var c = true;
		n++;
		if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null))	{
			c = false;
			if(typeof a == 'object'){
				for(var i in a)	{
					if ( (a[i] == 'id' && document.getElementById(i) == null) || (a[i] == 'tag' && document.getElementsByTagName(i).length < 1)	) { 
						c = true; 
						break; 
					}
				}
			}
			if(!c) { f(); clearInterval(t); }}
		if(n >= 60)	{
			//clear the timer
			clearInterval(t);
		}
	}, 250);
}
// Open Window
function openWin(page,ww,wh)
{
   var sw;
   var sh;
   var ssx;
   var ssy;
   var winopt;

   sw=new Number(screen.availWidth);
   sh=new Number(screen.availHeight);
   ssx = (sw/2)-(ww/2);
   ssy= (sh/2)-(wh/2);

   if (ssy <0) {
   	ssy=0;
   }
   if (ssx <0) {
   	ssx=0;
   }
	winopt = "width=" + ww + ",height=" + wh + ",resizable=1,scrollbars=1,status=1,titlebar=1,screenX="+ ssx + ", screenY=" + ssy + ", Top=" + ssy + ", Left=" + ssx +",toolbar=yes,menubar=yes,location=yes"
	window.open(page,'_blank', winopt);
}
function getLink(a, id){
    var host;
    switch(a){
        case 1:
            host = "http://www.asseenontvnetwork.com/track/click/"+id+"/";
            break;
        case 2:
            host = "";//new affiliate
            break;
        default:
            host = "http://www.asseenontvnetwork.com/track/click/"+id+"/";
            break;
    }
    openWin(host, screen.availWidth, screen.availHeight);
}
function EmailFriend(link){
    var page;
    page = window.location;
    return GB_showCenter('Email A Friend', link.href+"?r="+page, 420, 450);
}
    

