var contextPath;

// text zoom control

textzoom = {};
textzoom.LEVELS = [62.5, 77, 85, 93];
textzoom.DEFAULT_INDEX = 1;
textzoom.index = Number(getCookie('zoom') || textzoom.DEFAULT_INDEX);
textzoom.zoom = function(n) {
    switch (n) {
        case +1: textzoom.index = Math.min(textzoom.index+1, textzoom.LEVELS.length-1); break;
        case -1: textzoom.index = Math.max(textzoom.index-1, 0); break;
        default: textzoom.index = textzoom.DEFAULT_INDEX; break;
    }
    document.body.style.fontSize = textzoom.LEVELS[textzoom.index] + '%';
    setCookie('zoom', textzoom.index, 365, '/');
};
document.write('<style type="text/css" media="screen">body { font-size: ' + textzoom.LEVELS[textzoom.index] + '%; }</style>');

/* css browser specific targeting */

var css_browser_selector = function() {
  var 
    ua=navigator.userAgent.toLowerCase(),
    is=function(t){ return ua.indexOf(t) != -1; },
    h=document.getElementsByTagName('html')[0],
    b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
    os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
  var c=b+os+' js';
  h.className += h.className?' '+c:c;
}();

// special case link initialization

HERPathways_WARNING = '<div class="warning">The information contained in this section of the site is intended for U.S. healthcare professionals only. Click "OK" if you are a healthcare professional.</div>';
LINK_DISCLAIMER = '<div class="warning">The link you have selected will take you away from this site to one that is not owned or controlled by Genentech, Inc. Genentech, Inc. makes no representation as to the accuracy of the information contained on sites we do not own or control.\n\n Genentech does not recommend and does not endorse the content on any third-party websites. Your use of third-party websites is at your own risk and subject to the terms and conditions of use for such sites.</div>';

function initializeLinks() {
    var anchor, i = 0;
    while ((anchor = document.getElementsByTagName('a')[i++]) != null) {
        if (hasClass(anchor, 'external'))
            anchor.setAttribute('target', '_blank');
        if (hasClass(anchor, 'third-party'))
            addEvent(anchor, 'click', disclaimLink);
        if (hasClass(anchor.parentNode, 'apop-link'))
            addEvent(anchor, 'click', warnApop);
    }
}

function disclaimLink(e) {
    confirmRedirect(e, LINK_DISCLAIMER);
}

function warnApop(e) {
    if (!location.pathname.match(/\/apop\//)) {
        var target = getTarget(e);
        target.href = rewriteHref(target.href);
        confirmRedirect(e, HERPathways_WARNING);
    }
}

function goPat(e) {
    var target = getTarget(e);
    location = rewriteHref(target.href);
    cancelEvent(e);
}

function rewriteHref(href) {
    var m;
    if (m = location.href.match(/\/(apop)\/([^\/]+)\//)) {
        href = href.replace(/\/(apop)\/.*/, '/' + '$1' + '/' + m[2] + '/');
    }
    return href;
}

function confirmRedirect(e, disclaimer) {
    var target = getTarget(e);
    if(target.tagName == "IMG") target = target.parentNode;
    var href = target.href;
    cancelEvent(e);

    function handleOK() {
        dialog.hide();
        if (hasClass(target, 'external'))
            window.open(href);
        else
            location = href;
    }

    function handleCancel() {
        dialog.hide();
        dialog.destroy();
    }

    var dialog = new YAHOO.widget.SimpleDialog('dialog',
                                              {
                                                  buttons: [ { text: 'OK', handler: handleOK },
                                                             { text: 'Cancel',  handler: handleCancel } ],
                                                  close: false,
                                                  constraintoviewport: true,
                                                  draggable: false,
                                                  fixedcenter: true,
                                                  modal: true,
                                                  icon: YAHOO.widget.SimpleDialog.ICON_WARN,
                                                  text: disclaimer,
                                                  underlay: 'none',
                                                  visible: false,
                                                  width: '315px'
                                              });
    dialog.setHeader('ResearchHERPathways.com');
    dialog.render(document.body);
    dialog.show();
}

addEvent(window, 'load', initializeLinks);

// utility functions

function getCookie(name) {
    var pattern = new RegExp('(^|; )' + name + '=([^;]*)');
    var m = document.cookie.match(pattern);
    return m && unescape(m[2]);
}

function setCookie(name, value, days, path, domain, secure) {
    var c = name + '=' + escape(value);
    var expires = null;
    if (days)
        expires = new Date(new Date().getTime() + (days * 24 * 60 * 60 * 1000));
    if (expires)
        c += '; expires=' + expires.toUTCString();
    if (path)
        c += '; path=' + path;
    if (domain)
        c += '; domain=' + domain;
    if (secure)
        c += '; secure';
    document.cookie = c;
}

function getClasses(element) {
    return element.className.trim().split(/\s+/);
}

function hasClass(element, c) {
    return getClasses(element).indexOf(c) != -1;
}

function addEvent(obj, type, fn) {
    if (obj.addEventListener)
        obj.addEventListener(type, fn, false);
    else if (obj.attachEvent) {
        obj['e' + type + fn] = fn;
        obj[type + fn] = function() { obj['e' + type + fn](window.event); }
        obj.attachEvent('on' + type, obj[type + fn]);
    }
}

function removeEvent(obj, type, fn) {
    if (obj.removeEventListener)
        obj.removeEventListener(type, fn, false);
    else if (obj.detachEvent) {
        obj.detachEvent('on' + type, obj[type + fn]);
        obj[type + fn] = null;
        obj['e' + type + fn] = null;
    }
}

function cancelEvent(e) {
    var e = e || window.event;
    e.cancelBubble = true;
    if (typeof e.stopPropagation == 'function')
        e.stopPropagation();
    e.returnValue = false;
    if (typeof e.preventDefault == 'function')
        e.preventDefault();
}

function getTarget(e) {
    var e = e || window.event;
    return e.target || e.srcElement;
}

function getTransport() {
    if (typeof window.XMLHttpRequest != 'undefined')
        return new XMLHttpRequest();
    try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch (ex) {}
    try { return new ActiveXObject('MSXML2.XMLHTTP'); } catch (ex) {}
    return null;
}

function getMatchingTextNodes(node, pattern) {
    if (node == null || node.nodeType != 1)
        return;
    var nodes = [];
    var root = node;
    while (node != null) {
        if (node.hasChildNodes())
            node = node.firstChild;
        else if (node != root && null != (next = node.nextSibling))
            node = next;
        else {
            next = null;
            for ( ; node != root; node = node.parentNode) {
                next = node.nextSibling;
                if (next != null) break;
            }
            node = next;
        }
        if (node != null && node.nodeType == 3) {
            while ((match = pattern.exec(node.data)) != null)
                nodes.push([node, match]);
        }
    }
    return nodes;
}

function urlencode(str) {
    var encode = (typeof encodeURIComponent == 'function')
        ? encodeURIComponent
        : escape;
    return encode(str).replace(/%20/g,'+');
}

Array.prototype.indexOf = function(item, start) {
    for (var i = (start || 0); i < this.length; i++) {
        if (this[i] == item) return i;
    }
    return -1;
}

String.prototype.trim = function() {
    return this.replace(/^\s+/,'').replace(/\s+$/,'');
}


function clearText(thefield){
    if (thefield.defaultValue==thefield.value)
    thefield.value = "";
}

function setContextPath(path) {
  contextPath = path;
}

function createSlidedecks() {
    init_slidedeck();
    init_slidedeck2();
    init_slidedeck3();
    init_slidedeck4();
    init_slidedeck5();
}

function init_slidedeck() {
    meltmedia.example.slidedeck = new meltmedia.widget.SlideDeck("slidedeck",
    {
        fixedcenter:true,
        constraintoviewport:true,
        underlay:"none",
        close:true,
        visible:false,
        draggable:false,
        modal:true,
        slides:[{src:contextPath+"/images/slides/slidedeck1/Slide1.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide2.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide3.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide4.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide5.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide6.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide7.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide8.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide9.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide10.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide11.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide12.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide13.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide14.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide15.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide16.jpg",title:"HER Pathways Overview Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck1/Slide17.jpg",title:"HER Pathways Overview Slide Deck",description:""}],
        fulldeck:contextPath+"/content/HERPathways-Overview-Slide-Kit.ppt",
        count:true,
        width:"442px",
        height:"332px"
    } );
    meltmedia.example.slidedeck.render();
}

function init_slidedeck2() {
    meltmedia.example.slidedeck2 = new meltmedia.widget.SlideDeck("slidedeck2",
    {
        fixedcenter:true,
        constraintoviewport:true,
        underlay:"none",
        close:true,
        visible:false,
        draggable:false,
        modal:true,
        slides:[{src:contextPath+"/images/slides/slidedeck2/Slide1.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide2.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide3.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide4.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide5.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide6.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide7.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide8.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide9.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide10.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide11.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide12.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide13.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide14.jpg",title:"HER Pathways HER1 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck2/Slide15.jpg",title:"HER Pathways HER1 Slide Deck",description:""}],
        fulldeck:contextPath+"/content/HERPathways-HER1-Slide-Kit.ppt",
        count:true,
        width:"442px",
        height:"332px"
    } );
    meltmedia.example.slidedeck2.render();
}

function init_slidedeck3() {
    meltmedia.example.slidedeck3 = new meltmedia.widget.SlideDeck("slidedeck3",
    {
        fixedcenter:true,
        constraintoviewport:true,
        underlay:"none",
        close:true,
        visible:false,
        draggable:false,
        modal:true,
        slides:[{src:contextPath+"/images/slides/slidedeck3/Slide1.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide2.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide3.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide4.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide5.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide6.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide7.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide8.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide9.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide10.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide11.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide12.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide13.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide14.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide15.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide16.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide17.jpg",title:"HER Pathways HER2 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck3/Slide18.jpg",title:"HER Pathways HER2 Slide Deck",description:""}],
        fulldeck:contextPath+"/content/HERPathways-HER2-Slide-Kit.ppt",
        count:true,
        width:"442px",
        height:"332px"
    } );
    meltmedia.example.slidedeck3.render();
}

function init_slidedeck4() {
    meltmedia.example.slidedeck4 = new meltmedia.widget.SlideDeck("slidedeck4",
    {
        fixedcenter:true,
        constraintoviewport:true,
        underlay:"none",
        close:true,
        visible:false,
        draggable:false,
        modal:true,
        slides:[{src:contextPath+"/images/slides/slidedeck4/Slide1.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide2.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide3.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide4.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide5.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide6.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide7.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide8.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide9.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide10.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide11.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide12.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide13.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide14.jpg",title:"HER Pathways HER3 Slide Deck",description:""},
                {src:contextPath+"/images/slides/slidedeck4/Slide15.jpg",title:"HER Pathways HER3 Slide Deck",description:""}],
        fulldeck:contextPath+"/content/HERPathways-HER3-Slide-Kit.ppt",
        count:true,
        width:"442px",
        height:"332px"
    } );
    meltmedia.example.slidedeck4.render();
}

function init_slidedeck5() {
    meltmedia.example.slidedeck5 = new meltmedia.widget.SlideDeck("slidedeck5",
    {
        fixedcenter:true,
        constraintoviewport:true,
        underlay:"none",
        close:true,
        visible:false,
        draggable:false,
        modal:true,
        slides:[{src:contextPath+"/images/slides/slidedeck5/Slide1.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide2.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide3.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide4.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide5.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide6.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide7.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide8.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide9.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide10.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide11.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide12.jpg",title:"HER2:HER3 Partnership in HER2+",description:""},
                {src:contextPath+"/images/slides/slidedeck5/Slide13.jpg",title:"HER2:HER3 Partnership in HER2+",description:""}],
        fulldeck:contextPath+"/content/HERPathways-HER4-Slide-Kit.ppt",
        count:true,
        width:"442px",
        height:"332px"
    } );
    meltmedia.example.slidedeck5.render();
}

function showSlideDeck() {
//	survey.create();
    meltmedia.example.slidedeck.show();
}

function download(deckId) {
	survey.dId=Number(deckId);
    if (!YAHOO.util.Cookie.get("surveyId") && YAHOO.util.Cookie.get("surveyId") !="") {
		survey.create(survey.dId);	
    } else {
		trackDownload(survey.dId);
    }
}

function trackDownload(dId){
		YAHOO.util.Connect.asyncRequest("get",contextPath+"/ajax/survey/slide-download-count.m?slideName="+getFileName(dId),{
			success: function(o){
				//not working in firefox
//				YAHOO.util.Cookie.remove("surveyId");
        s.tl(this,'o', s.getPageName()+':'+getFileName(dId));
				window.location = contextPath + "/content/" + getFileName(dId);
			},
			failure:{}
			});
	
}

function showSlideDeck2() {
    meltmedia.example.slidedeck2.show();
}

function showSlideDeck3() {
    meltmedia.example.slidedeck3.show();
}

function showSlideDeck4() {
    meltmedia.example.slidedeck4.show();
}

function showSlideDeck5() {
    meltmedia.example.slidedeck5.show();
}

var xhrcommon = {
    get: function(userConfig) {
	this.uri = userConfig.uri;
	this.method = (userConfig.method) ? userConfig.method : "GET";
	if(userConfig.callback) this.callback = userConfig.callback;
	this.postMessage = (userConfig.postMessage && this.method == "POST") ? userConfig.postMessage : null;
	this.transaction = YAHOO.util.Connect.asyncRequest(this.method, this.uri, this.callback, this.postMessage);
	//ajaxLoader.show();
    },

    callback: {
	success: function(o) {
	    //ajaxLoader.hide();
	},
	failure: function(o) {
	    //ajaxLoader.hide();
	},
	argument: [ /* empty array */ ]
    },

    cleanResponse: function(response) {
	/** To add additional tags to clean from a response add a pipe after the previous tag name in list
	 *  i.e. response.replace(/<(textarea|select|fieldset)([^>]*)\/>/gi,'<$1$2></$1>');
	 **/
	return response.replace(/<(textarea|div|select)([^>]*)\/>/gi,'<$1$2></$1>');
    }
};

var survey = {
    create: function(deckId) {
	YAHOO.util.Connect.asyncRequest("get", contextPath+"/ajax/survey/slide-survey-index.m",{
		success: function(o) {
		    //ajaxLoader.hide();
		    if(!survey.dialog) {
			survey.dialog = new YAHOO.widget.Dialog("survey", {
				postmethod: "async",
				visible: false,
				fixedcenter: true,
				width: "400px",
				constraintoviewport: true,
				modal: true,
				close: true,
				draggable: false,
				underlay: "none"
			    });
		    }

		    survey.dialog.setHeader("<div id='ajax-loader' style='display:none'><img src='"+contextPath+"/images/ajax-loader.gif'/></div><div style='padding: 3px 0 0 10px;'>Download Survey &#150; ResearchHERPathways.com</div>");
		    survey.dialog.setBody(xhrcommon.cleanResponse(o.responseText));
		    survey.dialog.render(document.body);

		    // Check for and activate cancel and submit buttons
			var cancel = document.getElementById("form-cancel");
			var submit = document.getElementById("form-submit");

		    YAHOO.util.Event.addListener(cancel, "click", survey.cancel);
		    YAHOO.util.Event.addListener(submit, "click", survey.submit);
		    survey.dialog.show();
		},
		failure: function(o) {
		    alert("Survey Failed.\n"+
			  "Please Try Again Later.");
		}
	    });
    },
    cancel: function(ev) {
	survey.dialog.cancel();
    },
    submit: function(ev) {
	//survey.dialog.hide();
	document.getElementById("ajax-loader").style.display = "block";
		
	var f = document.getElementById("surveyForm");
	YAHOO.util.Connect.setForm(f);
	YAHOO.util.Connect.asyncRequest("post", contextPath+"/ajax/survey/slide-survey-submit.m", {
		success: function(o){
		    document.getElementById("ajax-loader").style.display = "none";
		    var root = o.responseXML.documentElement;
		    var divs = root.getElementsByTagName("div");

		    for(var i=0;i<divs.length;i++){
			if(divs[i].getAttribute("class")=="error"){
			    survey.dialog.setBody(xhrcommon.cleanResponse(o.responseText));
			    // Check for and activate cancel and submit buttons
				var cancel = document.getElementById("form-cancel");
				var submit = document.getElementById("form-submit");

			    YAHOO.util.Event.addListener(cancel, "click", survey.cancel);
			    YAHOO.util.Event.addListener(submit, "click", survey.submit);
			    //survey.dialog.render(document.body);
			    //survey.dialog.show();
			    return;
			}
		    }
		    survey.dialog.hide();
			trackDownload(survey.dId);
//			YAHOO.util.Connect.asyncRequest("get",contextPath+"/ajax/survey/slide-download-count.m?slideName="+getFileName(survey.dId));
//		    window.location = contextPath+"/content/"+getFileName(survey.dId);
		},
		failure: function(o){
		    document.getElementById("ajax-loader").style.display = "none";
		    alert("Submission Failed");
		}
	    });
    }
};

function getFileName(sId){
	var url;
	switch(sId){
	case 1:url="HERPathways-Overview-Slide-Kit.ppt";
	    break;
	case 2:url="HERPathways-HER1-Slide-Kit.ppt";
	    break;
	case 3:url="HERPathways-HER2-Slide-Kit.ppt";
	    break;
	case 4:url="HERPathways-HER3-Slide-Kit.ppt";
	    break;
	case 5:url="HERPathways-HER4-Slide-Kit.ppt";
	    break;
	
	}
	return url;
}
