function aaPopups() {
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
  	if (links[i].className.match("popup")) {
      links[i].onclick = function() {
        window.open(this.href);
        return false;
      }
    }
  }
}

function aaBookmarks() {
	var path = window.location.pathname;
	var title = document.title;
	var aaBookmarks_div = document.getElementById("aaBookmarks");
	if(aaBookmarks_div) {
		aaBookmarks_div.innerHTML = '<h2><a href="/common/social-bookmarking.html">Save this link on...</a></h2>' +
		'<ul>' +
		'<li class="delicious"><a href="http://del.icio.us/post?url=http://www.theaa.com'+path+'&amp;title='+title+'">del.icio.us</a></li>' +
		'<li class="digg"><a href="http://digg.com/submit?url=http://www.theaa.com'+path+'&amp;title='+title+'">digg</a></li>' +
		'<li class="reddit"><a href="http://reddit.com/submit?url=http://www.theaa.com'+path+'&amp;title='+title+'">Reddit</a></li>' +
		'<li class="facebook"><a href="http://www.facebook.com/sharer.php?u=http://www.theaa.com'+path+'&amp;title='+title+'">facebook</a></li>' +
		'<li class="stumbleupon"><a href="http://www.stumbleupon.com/submit?url=http://www.theaa.com'+path+'&amp;title='+title+'">StumbleUpon</a></li>' +
		'<li class="twitter"><a href="http://twitter.com/home?status= %23TheAA '+title+' http://www.theaa.com'+path+'">Twitter</a></li>' +
		'</ul>';
	}
	else {
		return false;
	}
}

function aaLocalAdvertising() {
	var ref_url = encodeURIComponent("http://www.theaa.com/");
	var aaLocalAdvertising_div = document.getElementById("aaLocalAdvertising");
	if(aaLocalAdvertising_div) {
		aaLocalAdvertising_div.innerHTML = '<iframe src="http://standard.servedby.yell.com/netreachtextads/ad.html?pid=9000&url=' + ref_url + travel_section + '&placeid=' + travel_section + '&lnm=' + escape(local_advert_location) + '" width="168" height="138" style="border-style: none;" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" allowtransparency="true" id="frame1"></iframe>';
	}
	else {
		return false;
	}
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

function validateFirstTimeBuyer(){
	if(document.fbForm.FIRSTTIMEBUYER[0].checked){
		document.getElementById("ciDiv").className = "collectInsurersInfoHide";
		document.fbForm.action = "first-time-buyer_redirect.jsp";
	}

	if(document.fbForm.FIRSTTIMEBUYER[1].checked){
		document.getElementById("ciDiv").className = "collectInsurersInfoShow";
		document.fbForm.action = "current-insurer_redirect.jsp";
	}else{
		document.getElementById("ciDiv").className = "collectInsurersInfoHide";
		document.fbForm.action = "first-time-buyer_redirect.jsp";
	}

}

addLoadEvent(aaPopups);
addLoadEvent(aaBookmarks);
addLoadEvent(aaLocalAdvertising);

function writeDart(sz, pos,adType) {}
