function NewWindow(mypage, myname, w, h, wantScrollbars) {
	var scrollBarsOption = ', scrollbars=yes';
		
	if (typeof (wantScrollbars) != "undefined") {
		if (!wantScrollbars) {
			scrollBarsOption = ', scrollbars=no';		
		}
	}
		
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+scrollBarsOption;

	postDownload('', mypage);

	var rExp = / /gi;
	myname = myname.replace(rExp, '_');

	if (myname == '')
	{
		myname = '_blank';
	}

	var win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function postNavigation( eventName ){postFlashEvent( eventName );}
function postFlashEvent( eventName ){postEvent( 'Pageview', 'Flash', eventName, '', '' );}
function postPageview( eventName ){postEvent( 'Pageview', '', eventName, '', '' );}
function postDownload( eventName, link ){postEvent( 'Download', 'MouseLeft', eventName, link, '' );}
function postExit( eventName, link ){postEvent( 'Exit', 'SameWindow', eventName, link, '' );}
function postExitSameWindow( eventName, link ){postEvent( 'Exit', 'SameWindow', eventName, link, '' );}
function postExitNewWindow( eventName, link ){postEvent( 'Exit', 'NewWindow', eventName, link, '' );}
 
function postEvent( type, subType, name, text, number ){
try{var loc = new String(window.document.location);if(loc.length>800)loc=loc.slice(0,796)+'...';var post = document.createElement('script');
post.src = 'http'+(document.location.protocol=='https:'?'s':'')+'://'+document.nmCustomerId+'.netminers.dk/tracker/dispatch.aspx?action='+type+'&n='+Math.random()+'&nav='+encodeURIComponent(loc)+'&cid='+document.nmCustomerId+'&sub='+subType+'&ti1='+encodeURIComponent(name)+'&tva='+encodeURIComponent(text)+'&num='+encodeURIComponent(''+number);
var parent = document.getElementsByTagName('body');if( parent.length == 0 )parent = document.getElementsByTagName('head');parent[0].appendChild(post)}catch(e){}
}

function getId ( element ) { // return object reference
 if ( document.all ) return document.all [ element ];
 else return document.getElementById ( element );
}

function getStyle ( element ) { // return style property access syntax
 return document.layers ? getId ( element ) : getId (element).style;
}

window.onload = function (){ // perform onLoad actions
 for ( i=0; i < initCalls.length; i++ ) eval ( initCalls [i] );
}
window.onresize = function () { // perform resize actions
 for ( i=0; i < resizeCalls.length; i++ ) eval ( resizeCalls [i] );
}

var initCalls = new Array();
var resizeCalls = new Array();

initCalls [ initCalls.length ] = " checkToTop()"; // insert backtotop if needed
resizeCalls [ resizeCalls.length ] = " checkToTop()"; 

function checkToTop() {
var lBodyHeight;
var lHeight;
var windowheight;
   if (self.innerHeight) // all except Explorer
   {
    windowheight = self.innerHeight - 1;
   }
   else if (document.documentElement && document.documentElement.clientHeight)
    // Explorer 6 Strict Mode
   {
    windowheight = document.documentElement.clientHeight;
   }
   else if (document.body) // other Explorers
   {
    windowheight = document.body.clientHeight;
   }

if (document.getElementById("content") && document.getElementById("ToTopLink")) {
    if (navigator.platform.indexOf("Mac")>=0){
        lBodyHeight = document.body.scrollHeight;
        lHeight = document.getElementById("content").offsetHeight;
    }else{
        lBodyHeight = (navigator.userAgent.indexOf("scape") <= 0) ? document.body.offsetHeight : window.innerHeight;
        lHeight = (navigator.appVersion > 6 ) ? document.getElementById("content").scrollHeight : document.getElementById("content").offsetHeight;
    }
    
 getStyle ( "ToTopLink" ).display = ( lHeight > windowheight ? "block" : "none");
}
}

dc={
	triggerElements:'*', 	// elements to trigger the effect
	parentElementId:null,	// ID of the parent element (keep null if none)
	uniqueCollapse:false,	// is set to true only one element can be open at a time

	// CSS class names
	trigger:'trigger',
	triggeropen:'expanded',
	hideClass:'hide',
	showClass:'show',
	
	// pictures and text alternatives
	closedPic:'',
	closedAlt:'',
	openPic:'',
	openAlt:'',
	/* Doesn't work with Safari
		hoverClass:'hover',
	*/

	init:function(e){
		var temp;
		if(!document.getElementById || !document.createTextNode){return;}
		if(!dc.parentElementId){
			temp=document.getElementsByTagName(dc.triggerElements);
		} else if(document.getElementById(dc.parentElementId)){
			temp=document.getElementById(dc.parentElementId).getElementsByTagName(dc.triggerElements);
		}else{
			return;
		}
		dc.tempLink=document.createElement('a');
		dc.tempLink.setAttribute('href','#');
		dc.tempLink.appendChild(document.createElement('img'));
		for(var i=0;i<temp.length;i++){
			if(dc.cssjs('check',temp[i],dc.trigger) || dc.cssjs('check',temp[i],dc.triggeropen)){
				dc.makeTrigger(temp[i],e);
			}
		}
	},
	makeTrigger:function(o,e){
		var tl=dc.tempLink.cloneNode(true);
		var tohide=o.nextSibling;
		while(tohide.nodeType!=1)
		{
			tohide=tohide.nextSibling;
		}
		o.tohide=tohide;
		if(!dc.cssjs('check',o,dc.triggeropen)){
			dc.cssjs('add',tohide,dc.hideClass);
			tl.getElementsByTagName('img')[0].setAttribute('src',dc.closedPic);
			tl.getElementsByTagName('img')[0].setAttribute('alt',dc.closedAlt);
			o.setAttribute('title',dc.closedAlt);
		}else{
			dc.cssjs('add',tohide,dc.showClass);
			tl.getElementsByTagName('img')[0].setAttribute('src',dc.openPic);
			tl.getElementsByTagName('img')[0].setAttribute('alt',dc.openAlt);
			o.setAttribute('title',dc.openAlt);
			dc.currentOpen=o;
		}
		dc.addEvent(o,'click',dc.addCollapse,false);
		/* Doesn't work with Safari
		dc.addEvent(o,'mouseover',dc.hover,false);
		dc.addEvent(o,'mouseout',dc.hover,false);
		*/
		o.insertBefore(tl,o.firstChild);
		dc.addEvent(tl,'click',dc.addCollapse,false);
		// Safari hacks 
		tl.onclick=function(){return false;}
		o.onclick=function(){return false;}
	},
	/* Doesn't work with Safari
	hover:function(e){
		var o=dc.getTarget(e);
		var action=dc.cssjs('check',o,dc.hoverClass)?'remove':'add';
		dc.cssjs(action,o,dc.hoverClass)
	},
	*/
	addCollapse:function(e){
		var action,pic;
		// hack to fix safari's redraw bug 
		// as mentioned on http://en.wikipedia.org/wiki/Wikipedia:Browser_notes#Mac_OS_X
		if (self.screenTop && self.screenX){
			window.resizeTo(self.outerWidth + 1, self.outerHeight);    
			window.resizeTo(self.outerWidth - 1, self.outerHeight);   
		}
		if(dc.uniqueCollapse && dc.currentOpen){
			dc.currentOpen.getElementsByTagName('img')[0].setAttribute('src',dc.closedPic);
			dc.currentOpen.getElementsByTagName('img')[0].setAttribute('alt',dc.closedAlt);
			dc.currentOpen.setAttribute('title',dc.closedAlt);
			dc.cssjs('swap',dc.currentOpen.tohide,dc.showClass,dc.hideClass);
			dc.cssjs('remove',dc.currentOpen,dc.triggeropen);
			dc.cssjs('add',dc.currentOpen,dc.trigger);
		}
		var o=dc.getTarget(e);
		if(o.tohide){
			if(dc.cssjs('check',o.tohide,dc.hideClass)){
				o.getElementsByTagName('img')[0].setAttribute('src',dc.openPic);
				o.getElementsByTagName('img')[0].setAttribute('alt',dc.openAlt);
				o.setAttribute('title',dc.openAlt);
				dc.cssjs('swap',o.tohide,dc.hideClass,dc.showClass);
				dc.cssjs('add',o,dc.triggeropen);
				dc.cssjs('remove',o,dc.trigger);
			}else{
				o.getElementsByTagName('img')[0].setAttribute('src',dc.closedPic);
				o.getElementsByTagName('img')[0].setAttribute('alt',dc.closedAlt);
				o.setAttribute('title',dc.closedAlt);
				dc.cssjs('swap',o.tohide,dc.showClass,dc.hideClass);
				dc.cssjs('remove',o,dc.triggeropen);
				dc.cssjs('add',o,dc.trigger);
			}
			dc.currentOpen=o;
			dc.cancelClick(e);
			//document.getElementById('debug').innerHTML=o.tohide.className;
		}
		else{
			dc.cancelClick(e);
		}
	},
	/* helper methods */
	getTarget:function(e){
		var target = window.event ? window.event.srcElement : e ? e.target : null;
		if (!target){return false;}
		while(!target.tohide && target.nodeName.toLowerCase()!='body')
		{
			target=target.parentNode;
		}
		// if (target.nodeName.toLowerCase() != 'a'){target = target.parentNode;} Safari fix not needed here
		return target;
	},
	cancelClick:function(e){
		if (window.event){
			window.event.cancelBubble = true;
			window.event.returnValue = false;
			return;
		}
		if (e){
			e.stopPropagation();
			e.preventDefault();
		}
	},
	addEvent: function(elm, evType, fn, useCapture){
		if (elm.addEventListener) 
		{
			elm.addEventListener(evType, fn, useCapture);
			return true;
		} else if (elm.attachEvent) {
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		} else {
			elm['on' + evType] = fn;
		}
	},
	cssjs:function(a,o,c1,c2){
		switch (a){
			case 'swap':
				o.className=!dc.cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
			break;
			case 'add':
				if(!dc.cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
			break;
			case 'remove':
				var rep=o.className.match(' '+c1)?' '+c1:c1;
				o.className=o.className.replace(rep,'');
			break;
			case 'check':
				return new RegExp("(^|\\s)" + c1 + "(\\s|$)").test(o.className)
			break;
		}
	}
}
dc.addEvent(window, 'load', dc.init, false);

$.validator.setDefaults({
	//submitHandler: function() { alert("submitted!"); }
});

$().ready(function() {
	// validate signup form on keyup and submit
	$("#formhcplogin").validate({
		rules: {
			username: "required",
			password: {
				required: true,
				minlength: 5
			},
			//password2: {
				//required: true,
				//minlength: 5,
				//equalTo: "#password1"
			//},
			email: {
				required: true,
				email: true
			},
			confirm: "required",
			accept: "required"
		},
		messages: {
			username: "Please enter a prefered username",
			password1: {
				required: "Please provide a password",
				minlength: "Your password must be at least 5 characters long"
			},
			password2: {
				required: "Please provide a password",
				minlength: "Your password must be at least 5 characters long",
				equalTo: "Please enter the same password as above"
			},
			confirm: "Please confirm that you are a HCP",
			accept: "Please accept that Novo Nordisk is allowed to store your data"
		}
	});
	
	$("#formhcpnewuser").validate({
		rules: {
			loginusername: "required",
			loginpassword: "required"
		},
		messages: {
			loginusername: "Please enter your username",
			loginpassword: "Please enter your password"
		}
	});

$(function()
{

$("#forgothcp").click(function(event) {
event.preventDefault();
$("#forgotteninput").slideToggle();
});

$("#forgotteninput a").click(function(event) {
event.preventDefault();
$("#forgotteninput").slideUp();
});
});


});


// various IE quirks
$(document).ready(function(){
	$("#frontpage #dawnform").parent().addClass('nobg');
	
});


$(document).ready(function() {
	$(".labelinline input:[type=text], .labelinline input:[type=password]").focus(function () {
		$(this).addClass("hidelabel");	
	});
	$(".labelinline input:[type=text], .labelinline input:[type=password]").blur(function () {
		if (this.value == '') {
			$(this).removeClass("hidelabel");
		}
	});
	$(".labelinline input:[type=text], .labelinline input:[type=password]").each(function () {
		if (this.value != '') {
			$(this).addClass("hidelabel");
		}
	});
});


var dawndialogue = dawndialogue || {};

dawndialogue.survey = ( function () {

	//	config

	var wait = 10, //	seconds

	surveyID = 2;	//	unique survey id to allow later surveys to show when NO was clicked for previous

	

	//	internal vars
	var dialog,
		dialogTemplate = '<div id="survey-dialog">'
					+'<h6>Signup for Newsletter?</h6>'
					+'<p>&nbsp;</p> '
					+'<a class="option-yes" href="/news_and_activities/news_subscription.asp">yes</a> <a class="option-later" href="#">next time</a> <a class="option-no" href="#">no</a>'
					+'</div>';

		// using Date.now() to simply get time in ms in modern browsers
		now = (!!Date.now) ? Date.now() : ( new Date() ).getTime();

	var init = function () {
		var viewed = (( 'localStorage' in window ) && window.localStorage !== null )
			? localStorage['survey' + surveyID]
			: $.cookie( 'survey' + surveyID );

		if ( !viewed ) {
			//	make sure fallback is available for older browsers
			if ( typeof $.cookie != 'function' ) return;
			//	read creation time of session
			var st = readST();

			//	check if survey has been silenced for this session ( setting '-' )
			if ( st != '-' ) {
				var remaining = wait * 1000 - now + parseInt( st );
				setTimeout( show, remaining );
			}
		}
	}
	

	var show = function () {
		dialog = $( dialogTemplate ).appendTo( 'body' );
		dialog.show()
			//	center dialog in window
			.css({
				left: ( $( window ).width() - dialog.width() ) / 2,
				top: ( $( window ).height() - dialog.height() ) / 2
			})
			//	attach event listeners to buttons
			.find( '.option-no' )
				.click( no )
				.end()
			.find( '.option-yes' )
				.click( yes )
				.focus()
				.end()
			.find( '.option-later' )
				.click( later );
	}
	

	var no = function ( e ) {
		e.preventDefault();
		setDone();
		dialog.hide();
	}
	

	var later = function ( e ) {
		e.preventDefault();
		setST ( '-' );
		dialog.hide();
	}
	

	var yes = function ( e ) {
		e.preventDefault();
		setDone();
		location = this.href;
	}
	

	var setDone = function () {
		if (( 'localStorage' in window ) && window.localStorage !== null ) localStorage['survey' + surveyID] = '-';
		else $.cookie( 'survey' + surveyID, '-', { path: '/', expires: 365 } );
	}
	

	var readST = function () {
		var st = (( 'sessionStorage' in window ) && window.sessionStorage !== null )
			? sessionStorage.st
			: $.cookie( 'st' );
		if ( !st ) setST( now );
		return st || now;

	}
	var setST = function ( val ) {
		if (( 'sessionStorage' in window ) && window.sessionStorage !== null ) sessionStorage.st = val;
		else $.cookie( 'st', val, { path: '/' } );
	}

	return {
		init: init
	}

})();

//dawndialogue.survey.init();










