/*
 * SimpleModal Confirm Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2008 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: confirm.js 132 2008-05-23 16:05:17Z emartin24 $
 *
 */

/// <reference path="jquery-1.2.6-vsdoc.js">



$(document).ready(function() {
    var cookie = readCookie("isHCP");
    if (cookie == null) {
        confirm("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.", function() {
            //window.location.href = 'http://www.ericmmartin.com/projects/simplemodal/';
            $.modal.close();
        });
        
    }
});

function confirm(message, callback) {
    $('#confirm').modal({
        close: false,
        overlayId: 'confirmModalOverlay',
        containerId: 'confirmModalContainer',
        onShow: function(dialog) {
            dialog.data.find('.message').append(message);

            // if the user clicks "yes"
            dialog.data.find('.yes').click(function() {
                // call the callback
                if ($.isFunction(callback)) {
                    callback.apply();
                }
                // close the dialog
                createCookie("isHCP", true);
                $.modal.close();
            });

            dialog.data.find('.no').click(function() {
                window.location.href = 'http://www.cephalon.com/';

            });

        }
    });
}

var openMyModal = function(source, width, heigth)
{
	if (width == null)
		width = 600;
	if (heigth == null)
		heigth = 400;
	modalWindow.windowId = "Modal";
	modalWindow.width = width;
	modalWindow.height = heigth;
	modalWindow.content = "<iframe width='" + width + "' height='" + heigth + "' frameborder='0' scrolling='no' allowtransparency='true' 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=\"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("<a class=\"close-window\"></a>");
		$(".close-window").click(function() { modalWindow.close(); });
		$(".modal-overlay").click(function() { modalWindow.close(); });
	}
};


function set_interval()
{
	timer = setInterval("auto_redirect()", 300000);
}
function reset_interval()
{
	//alert($(window).height());
	if (timer != null)
	{
		clearInterval(timer);
		timer = setInterval("auto_redirect()", 300000);
	}
}
function auto_redirect()
{
	window.location = "default.aspx";
}

    