﻿/// <reference path="jquery-1.2.6-vsdoc.js">

//Create a cookie to store the preferred style sheet.
function createCookie(name, value) {
    expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

//Read the cookie to return the prefered style sheet.
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function printPage() {
    var curURL = window.location.toString();
    if(curURL.indexOf("?") > 0)
        curURL = curURL + "&type=print";
    else
        curURL = curURL + "?type=print";
    window.open(curURL, "_blank");

    return false;
    
}
function TrackLink() {
    if (arguments.length < 2) {
        alert("Error: Not enough arguments to TrackLink()");
        return;
    }

    var linkTest = arguments[0];

    var link;

    if (linkTest.href == undefined) {
        link = document.createElement('a');
        link.href = linkTest;
    }

    else {
        link = linkTest;
    }

    var name = arguments[1];

    var options;

    if (arguments.length > 2) {
        options = arguments[2];
    }

    var linkTrackVars = '';
    var linkTrackEvents = '';

    var suppressTracking = false;

    if (options != undefined) {
        if (options.prop != undefined) {
            linkTrackVars += options.prop;

            s[options.prop] = options.prop;
        }

        if (options.event != undefined) {
            if (linkTrackVars.length > 0) {
                linkTrackVars += ",events";
            }

            else {
                linkTrackVars += "events";
            }

            linkTrackEvents += options.event;

            s.events = options.event;
        }

        if (options.supress != undefined) {
            suppressTracking = options.supress;
        }

        s.linkTrackVars = linkTrackVars;
        s.linkTrackEvents = linkTrackEvents;
    }

    if (!suppressTracking) {
        s.tl(link, 'o', name);
    }
   }

function openReferences() {
   	window.open('../popup/references-hcp.aspx', '', 'menubar=no,width=650,height=700,resizable=no,toolbar=no, scrollbars=yes');
   }

function newWin(link) {
   	window.open(link, 'newWin', 'width=780,height=580,resizable=1,scrollbars=1,toolbar=1,menubar=1');
   	return false;
   }

//This is for getting out of the lightbox functionality
function gotoLink(linkName) {
   	self.parent.location = linkName;
   	self.parent.tb_remove();
}



// Tout animation popup
var popPage = function(source, width, height) {
    if (width == null)
        width = 600;
    if (height == null)
        height = 400;
    modalWindow.windowId = "Modal";
    modalWindow.width = width;
    modalWindow.height = height;
    modalWindow.content = "<iframe width='" + width + "' height='" + height + "' frameborder='0' scrolling='no' src='" + source + "'></iframe>";
    modalWindow.open();
};

var modalWindow = {
    parent: "body",
    windowId: null,
    content: null,
    width: null,
    height: null,
    close: function() {
        $(".modal-window").remove();
        $(".modal-overlay").remove();
    },
    open: function() {
        var modal = "";
        modal += "<div class=\"modal-overlay\"></div>";
        modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"position:absolute;width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
        modal += this.content;
        modal += "</div>";

        $(this.parent).append(modal);


        //$(".modal-window").append("<div style=\"position:absolute;top:10px;right:10px;\"><img class=\"close-window\" src=\"[INSERT CLOSE BUTTON HERE]\" alt=\"Close\" border=\"0\"  /></div>");
        $(".modal-window").append("<div style=\"position:absolute;top:10px;right:10px;\">Close</div>");
        $(".close-window").click(function() { modalWindow.close(); });
        $(".modal-overlay").click(function() { modalWindow.close(); });
    }
};