YAHOO.namespace("lawnlad.services");
var s_curr_dd = ""
var i_interval;
var oCurrTopNav = null;
function errFunc(t) {
    alert('Error ' + t.status + ' -- ' + t.statusText);
	alert(t.responseText);
}

function hidedd() {
	cleartimerdd();
	if ($(s_curr_dd)) {
		$(s_curr_dd).style.visibility = "hidden";
		s_curr_dd = "";
	}
}

function showdd(s_ObjName) {
	hidedd();
	if ($(s_ObjName)) {
		s_curr_dd = s_ObjName;
		$(s_curr_dd).style.visibility = "visible";
	}
}

function settimerdd() {
	cleartimerdd();
	i_interval = setInterval(hidedd,900);
}

function cleartimerdd() {
	clearInterval(i_interval);
}

function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}

function setTopNav(imgName, imgSrc) {
	try {
		oCurrTopNav = $(imgName);	
		$(imgName).src = imgSrc;
	} catch(e) {
		oCurrTopNav = null;
	}
}

function rollTopNav(imgName, imgSrc) {
	if ($(imgName)!=oCurrTopNav) {
		$(imgName).src = imgSrc;
	}
}

function addService(sName,sRef) {
	init();
	var url = "/scripts/serverside/add_service.asp";
	var data="servicename="+sName;
	data+="&servicereference="+sRef;
	data+="&action=add"
	data+="&sid="+Math.random();
	var myAjax = new Ajax.Request(url,{asynchronous:true, method:'post',parameters:data, onSuccess:addServiceSC, onFailure:errFunc});
}

function addPackage(sName,sType,sRef) {
	init();
	var url = "/scripts/serverside/add_package.asp";
	var data="packagename="+sName;
	data+="&packagetype="+sType;
	data+="&packagereference="+sRef;
	data+="&action=add"
	data+="&sid="+Math.random();
	var myAjax = new Ajax.Request(url,{asynchronous:true, method:'post',parameters:data, onSuccess:addServiceSC, onFailure:errFunc});
}

function removePackage(sRef) {
	var url = "/scripts/serverside/remove_package.asp?ref="+sRef;
	window.location = url;
}

function init() {
	if (!YAHOO.lawnlad.services.update) {
		YAHOO.lawnlad.services.update = new YAHOO.widget.Panel("update", { width: "539px", fixedcenter: true, close: true, draggable: false, zindex:1000, modal: true, visible: false });
		YAHOO.lawnlad.services.update.setHeader("Loading, please wait...");
		YAHOO.lawnlad.services.update.setBody('<img src="http://us.i1.yimg.com/us.yimg.com/i/us/per/gr/gp/rel_interstitial_loading.gif" />');
		YAHOO.lawnlad.services.update.render(document.body);
	}
	YAHOO.lawnlad.services.update.show();
}

function addServiceSC(t) {
	var txt = t.responseText;
	txt = txt.replace("_", " ");
	YAHOO.lawnlad.services.update.hide();
		YAHOO.lawnlad.services.update.setHeader("&nbsp;");
	YAHOO.lawnlad.services.update.setBody("<h2>"+txt+" has successfully been added to MyYARD</h2><div id=\"cntLinks\"><p id=\"txtContinue\" class=\"updateLink\"><span onclick=\"hideupdate()\">Continue browsing</span></p><p id=\"txtVisit\" class=\"updateLink\"><a href=\"/myyard/\">Visit MyYARD</a></p><p class=\"clearsmall\">&nbsp;</p></div><a href=\"/myyard/\"><img src=\"/IMAGES/common/picUpdatingLogo.gif\" alt=\"MyYARD\" class=\"imgLogo\" /></a>");
	YAHOO.lawnlad.services.update.render(document.body);
	YAHOO.lawnlad.services.update.show();
}

function hideupdate() {
	if (YAHOO.lawnlad.services.update) {
		YAHOO.lawnlad.services.update.hide();
	}
}

function visitMyYARD() {
	window.location = "/myyard/";
}