function writeSEOCookie () {
 if(document.cookie.indexOf("seo_referrer_url=") < 0) {
   document.cookie = 'seo_referrer_url=' + escape(document.referrer) + "; path=/";
 }
 if(location.href.indexOf("_ADC_SOURCE=y_jali") > 0) {
   document.cookie = "seo_source=y_jali; path=/";
 } else if(location.href.indexOf("_ADC_SOURCE=y_datapop") > 0) {
   document.cookie = "seo_source=y_datapop; path=/";
 }
}

function loadSEOTrackingPixel() {
    var seoTrackingPixel = new Image;
    seoTrackingPixel.src = "/forms/seotracking/pixel.jpg";
}

writeSEOCookie();
loadSEOTrackingPixel();

function initMail(form) {
text = "Check out this page:  " + window.location;
form.message.value = "Hi " + form.sendto.value + " (" + form.to.value + "):\n\n"
 + text + "\n\nYour Friend,\n" + form.sendername.value + "(" + form.senderemail.value + ")";
return (form.to.value != "");
}

function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

function facebook()
{u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436')
}

function share_article(service) {
    var url = location.href;
    url = url.replace(/^http:\/\/[a-z]+\.u\./i,'http://www.');
    encodedurl = encodeURIComponent(url);
    var encodedtitle = encodeURIComponent(document.title);

    var serviceUrl = null;
    if (service == 'delicious') {
        serviceURL = 'http://del.icio.us/post?v=4&noui&jump=close'
            + '&url='      + encodedurl
            + '&title='    + encodedtitle;
    } else if (service == 'digg') {
        serviceURL = 'http://digg.com/submit?phase=2'
            + '&url='      + encodedurl
            + '&title='    + encodedtitle;
    } else if (service == 'stumbleupon') {
        serviceURL = 'http://www.stumbleupon.com/submit?'
            + '&url='      + encodedurl
            + '&title='    + encodedtitle;
    } else if (service == 'reddit') {
        serviceURL = 'http://reddit.com/submit'
            + '?url='      + encodedurl
            + '&title='    + encodedtitle;
    } else if (service == 'technorati') {
        serviceURL = 'http://technorati.com/faves?sub=favthis'
            + '&add=' + encodedurl;
    }
    if ( serviceURL != null ) {
        var theNewWin = window.open(serviceURL,'ddishare','full,resizable=yes,toolbar=yes,location=yes,scrollbars=yes');
        if ( typeof theNewWin != "undefined" &&
             theNewWin != null ) {
            theNewWin.focus();
        }
    }
    // remove the layer.
    document.getElementById('sharepop1').style.display='none';
    document.getElementById('sharepop1mask').style.display='none';
}

function gotoBeanStalk(degree,aos,onOffCampus,state) {
    if ( degree == "" )
        alert('Please select a Degree Level');
    else if ( aos == "" )
        alert('Please select a Degree Program');
    else if ( onOffCampus == "campus-degrees" ) {
        if ( state == "" )
            alert('Please Select the State to Search in');
        else
            location.href="http://www.degrees.info/" + onOffCampus + "/" + state + "/" + aos + "/" + aos + "-" + degree + ".html";
    }
    else
        location.href="http://www.degrees.info/" + onOffCampus + "/" + aos + "/" + aos + "-" + degree + ".html";
}

function checkStateVisibility(elem1,elem2,value) {
    if ( value == "campus-degrees" ) {
        elem1.style.visibility = "visible";
        elem2.style.visibility = "visible";
    }
    else {
        elem1.style.visibility = "hidden";
        elem2.style.visibility = "hidden";
    }
}
