Shadowbox.init({
    // let's skip the automatic setup because we don't have any
    // properly configured link elements on the page
    //skipSetup: false,
    // include the html player because we want to display some html content
    players: [ 'html', 'iframe']
});

window.onload = function(){

    $('#sidebar_right_hcp li').hover(
                   function() {
                       $(this).addClass('hover');
                  }, function() {
                        $(this).removeClass('hover');
                  }
     );

     if(readCookie('benzefoam') == null)
     {
        // open a message as soon as the window loads
        Shadowbox.open({
            content:    '<div id="hcp-msg"><p class="bold">This information is intended for U.S. Healthcare Professionals.</p><p> If you are a Healthcare Professional, click Continue otherwise click Go back.</p> <div id="buttons"> <button id="continue" type="button" onclick="javascript:hcpConfirm()">Continue</button> <button id="goBack" type="button" onclick="javascript:history.go(-1)">Go back</button> </div></div>',
            player:     "html",
            title:      "Welcome",
            height:     175,
            width:      370
        });
     }
};

//http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=1&postId=1104
//IE6 Background image flickers on hover
if (document.all) {
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} 
	catch (e) {}
}

function hcpConfirm()
{
    createCookie('benzefoam','ishcp');

    Shadowbox.close();
}


function createCookie(name,value,days) {
//console.log('create cookie');
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
//console.log('read cookie');
	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 eraseCookie(name) {
	createCookie(name,"",-1);
}
