/*******************************************************************************
____________________________ API DOCUMENTATION BEGIN ___________________________
````````````````````````````````````````````````````````````````````````````````
Variables and functions used throughout website.

````````````````````````````````````````````````````````````````````````````````
_____________________________ API DOCUMENTATION END ____________________________
*******************************************************************************/

//------------------------------------------------------------------------------
// VARIABLES BEGIN
//------------------------------------------------------------------------------

/*Preloads images */
var preloadlist = [
	'images/qi_button_arrow.gif',
	'images/qi_checkbox.gif',
	'images/qi_getadobereader.gif',
	'images/qi_wrapper_bg.gif',
	'images/qi_dialog_bg.gif'
];

var bayermsg = '<div id="leavingSiteSavingsCardDiv" class="qi_msg"><div class="content"><span>You are leaving a Bayer HealthCare Pharmaceuticals, Inc. web site...</span><p>and going to a third party site to activate or download the Bayer Savings Card. That site may have a privacy policy different from Bayer HealthCare Pharmaceuticals, Inc.</p><img src="images/qi_dialog_bg.gif" alt="" width="468" height="15" border="0"/><br /><p>Do you want to go to the third party site to activate or download a Bayer Savings Card?</p><a class="arrow_button qi_targeturl" href="#">Yes I want to activate/download my Bayer Saving Card</a><a class="arrow_button qi_cancel" href="#">Cancel</a><br/><br/></div></div>';

var msg_ext = '<div id="leavingSiteSavingsCardDiv" class="qi_msg qi_msg_pdf"><div class="content"><span>You are now leaving the www.yasmin-us.com website.</span><p class="first">Bayer HealthCare Pharmaceuticals Inc. is not responsible for the content presented by any independent website, including any advertising claims, special offers, illustrations, names or endorsements.</p><p class="last">Thank you for visiting www.yasmin-us.com.</p><a class="arrow_button qi_targeturl" href="#">OK</a><a class="arrow_button qi_cancel" href="#">Cancel</a><br clear="all"></div></div>';

var msg_pdf = '<div id="leavingSiteSavingsCardDiv" class="qi_msg qi_msg_pdf"><div class="content"><p><a href="http://www.adobe.com/products/acrobat/readstep2.html" class="qi_adobe"><img class="pdfIcon" src="images/qi_getadobereader.gif" width="88" height="31" border="0" align="right" hspace="0" vspace="0"/></a>The requested information is provided in<br/>Portable Document Format (PDF).</p><p>To view and print this document you\'ll need to install a copy of the free Adobe<sup>&reg;</sup> Reader<sup>&reg;</sup>. If you already have Adobe Reader installed click VIEW PDF below.</p><p>If you need the Adobe Reader you can download it from the <a href="http://www.adobe.com/products/acrobat/readstep2.html" class="qi_adobe">Adobe Reader Download page</a>.</p><p><a class="arrow_button qi_targeturl" href="#">View PDF</a><a class="arrow_button qi_cancel" href="#">Cancel</a></p><br><p><a class="qi_checkbox" href="#">&nbsp;</a> Don\'t show me this message again.</p></div></div>';

var msg_pdf_adobe = '<div class="content"><p>You are now leaving this website.</p><p>We are not responsible for the content presented by any independent website, including any advertising claims, special offers, illustrations, names, or endorsements.</p><p>Thank you for visiting with us.</p><p><a href="http://www.adobe.com/products/acrobat/readstep2.html" class="arrow_button qi_targeturl">OK</a><a class="arrow_button qi_cancel" href="#">Cancel</a></p><p> </p></div>'

$(document).ready(function(){
	$('#bayerleave').qi_dialog({type: 'ext', msg: bayermsg});
	//$('.pdf').qi_dialog({type: 'pdf', msg: msg_pdf, msg_exit: msg_pdf_adobe});
	$('.ext').qi_dialog({type: 'ext', msg: msg_ext});
	$('.go').qi_dialog({call: 'click', type:'ext'});
	
	for (var i = 0; i < preloadlist.length; i++){
		$('body').append('<img alt="" border="0" src="' + preloadlist[i] + '" id="preloadr' + i + '"/>');
		$('#preloadr' + i).css({
			position: 'absolute',
			top: -2000,
			left: -2000,
			height: 1,
			width: 1
		});
	}
});

//------------------------------------------------------------------------------
// VARIABLES END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// METRICS BEGIN
//------------------------------------------------------------------------------

//FUNCTION-- metrics logic
function metricsManager(argAction){
	switch(parseInt(argAction)){
		case 1:
			//tracks yaz_website_coupon.pdf
			tagAction("http://switch.atdmt.com/action/denbxs_YasminPatientPrescribingInfoPDF_9/");
			break;
		case 2:
			//tracks submit clicks on tools_support/e_reminders.jsp
			tagAction("http://switch.atdmt.com/action/denbxs_YasminPhysicianPrescribingInfoPDF_9/");
			break;
		default:
			alert("metricsManager: NO MATCHES FOUND");
	}
}

metricsArr = new Array(); //create array to hold image objects

//FUNCTION-- tags action
function tagAction(argSrc) {
 var dateObj = Date().replace(/\:/g, ""); //create date and remove colons
 dateObj = dateObj.replace(/\s/g, ""); //remove white space from date
 var imageObj = new Image(); //create image object
 imageObj.src = argSrc + "&date=" + dateObj; //append time stamp to image src as parameter to avoid image caching
 metricsArr.push(imageObj); //store the image object in an array
}

//------------------------------------------------------------------------------
// METRICS END
//------------------------------------------------------------------------------
