﻿﻿﻿/* content modal window */
function modal_content(obj, modalwidth) {
	var w = 780;
	var saveOmniPageName = s.pageName;
	if (modalwidth) {w = modalwidth;}
	// Reset scroll position
	window.scrollTo(0,0);
	
	$("#dialog-content").dialog("destroy");
	$("#dialog-content").dialog({
		position: ['auto',80],
		resizable: false,
		modal: true,
		width: w,
		height: 'auto',
		buttons: {
			"Back": function() {
				s.pageName = saveOmniPageName;
				$(this).dialog("destroy");
				$(this).html('');
				// Reset scroll position
				window.scrollTo(0,0);
			}	
		},
		open: function() {
			$.ajax({
				url: "/coupons/d/overlay.jsp?page=" + obj,
				cache: false,
				success: function(data) {
					$("#dialog-content").html(data);
				}
			});
		},
		overlay: {
			backgroundColor: "#000",
			opacity: 0.5
		},
		draggable: false
	}).dialog("widget")
	
	.find(".ui-dialog-buttonpane button")
	.eq(0).addClass("btn-back-browsing2").end();
}

/* text modal window */
function modal_message(data, modalwidth, reload, url) {
	var w = 780;
	var saveOmniPageName = s.pageName;
	if (modalwidth) {w = modalwidth;}
	// Reset scroll position
	window.scrollTo(0,0);
	
	$("#dialog-content").dialog("destroy");
	$("#dialog-content").dialog({
		position: ['auto',80],
		resizable: false,
		modal: true,
		width: w,
		height: 'auto',
		buttons: {
			"Back": function() {
				if (reload) {
					if (url) {
						document.location = url;
					}
					else {
						document.location = "/coupons";
					}
				}
				else {
					s.pageName = saveOmniPageName;
					$(this).dialog("destroy");
					$(this).html('');
					// Reset scroll position
					window.scrollTo(0,0);
				}
			}	
		},
		open: function() {
			$(this).html(data);
		},
		overlay: {
			backgroundColor: "#000",
			opacity: 0.5
		},
		draggable: false
	}).dialog("widget")
	
	.find(".ui-dialog-buttonpane button")
	.eq(0).addClass("btn-back-browsing2").end();
}

/* contact modal window */
function modal_contact(url, modalwidth) {
	var w = 780;
	var saveOmniPageName = s.pageName;
	if (modalwidth) {w = modalwidth;}
	// Reset scroll position
	window.scrollTo(0,0);
	
	$("#dialog-content").dialog("destroy");
	$("#dialog-content").dialog({
		position: ['auto',80],
		resizable: false,
		modal: true,
		width: w,
		height: 'auto',
		buttons: {
			"Back": function() {
				s.pageName = saveOmniPageName;
				$(this).dialog("destroy");
				$(this).html('');
				// Reset scroll position
				window.scrollTo(0,0);
			},
			"Send": function() {
				s.pageName = saveOmniPageName;
				submitContact();
			}
		},
		open: function() {
			// ajax load
			$(this).load(url);
		},
		overlay: {
			backgroundColor: "#000",
			opacity: 0.5
		},
		draggable: false
	}).dialog("widget")
	
	.find(".ui-dialog-buttonpane button")
	.eq(0).addClass("btn-back-browsing2").end()
	.eq(1).addClass("btn-send").end();
}

/* print modal window */
function modal_print(html, modalwidth) {
    var w = 620;
    var saveOmniPageName = s.pageName;
    if (modalwidth) {w = modalwidth;}
    // Reset scroll position
	window.scrollTo(0,0);
    
	$("#dialog-content").dialog("destroy");
	$("#dialog-content").dialog({
		position: ['auto',80],
		resizable: false,
		modal: true,
		width: w,
		height: 'auto',
		buttons: {
			"Back to Browsing": function() {
				s.pageName = saveOmniPageName;
				$(this).dialog("destroy");
				$(this).html('');
				// Reset scroll position
				window.scrollTo(0,0);
			},
			"Print All Coupons": function() {
				s.pageName = saveOmniPageName;
				vp_printPrintList('printList');
			}
		},
		open: function() {
			$(this).html(html);
		},
		overlay: {
			backgroundColor: "#000",
			opacity: 0.5
		},
		draggable: false
	}).dialog("widget")
	
    .find(".ui-dialog-buttonpane button")
    .eq(0).addClass("btn-back-browsing2").end()
    .eq(1).addClass("btn-print-coupons").end();
}

/* print mailer modal window */
function modal_printMailer(url, slugId, zoneMapId, pageName, modalwidth) {
	var w = 850;
	var saveOmniPageName = s.pageName;
    if (modalwidth) {w = modalwidth;}
    // Reset scroll position
	window.scrollTo(0,0);
    
	$("#dialog-content").dialog("destroy");
	$("#dialog-content").dialog({
		position: ['auto',80],
		resizable: false,
		modal: true,
		width: w,
		height: 'auto',
		buttons: {
			"Back to Browsing": function() {
				s.pageName = saveOmniPageName;
				$(this).dialog("destroy");
				$(this).html('');
				// Reset scroll position
				window.scrollTo(0,0);
			},
			"Print": function() {
				s.pageName = saveOmniPageName;
				vp_logContentPrint('E', pageName, zoneMapId, slugId);
				vp_printMailer();
			}
		},
		open: function() {
			// Loader message
			vp_loader();
			// ajax load
			$(this).load(url);
		},
		overlay: {
			backgroundColor: "#000",
			opacity: 0.5
		},
		draggable: false
	}).dialog("widget").hide()
	
	.find(".ui-dialog-buttonpane button")
	.eq(0).addClass("btn-back-browsing2").end()
	.eq(1).addClass("btn-print-coupons").end();
}

﻿/* SDC get code modal window */
function modal_getCode(url, id, bname, code, modalwidth) {
	var w = 460;
	if (modalwidth) {w = modalwidth;}
	
	$("#dialog-content").dialog("destroy");
	$("#dialog-content").dialog({
		position: ['center'],
		resizable: false,
		modal: true,
		width: w,
		height: 'auto',
		buttons: {
			"Back": function() {
				$(this).dialog("destroy");
				$(this).html('');
			},
			"Continue": function(){
				// Omniture
				vp_omniLogClick('event45', 'Savings.com Link', '', null, null, {eVar60:bname,eVar61:code});
				//link to merchant URL Add Var
				vp_openWindow(url, 'SDC', 1000, 700);
				$(this).dialog("destroy");
				$(this).html('');
			}	
		},
		open: function() {
			// ajax load
			$(this).html($('#sdcModal' + id).html());
		},
		overlay: {
			backgroundColor: "#000",
			opacity: 0.5
		},
		draggable: false
	}).dialog("widget")
	
	.find(".ui-dialog-buttonpane button")
	.eq(0).addClass("btn-back-browsing2").end()
	.eq(1).addClass("btn-send").end();
}

/* survey modal window */
function modal_survey(url, modalwidth) {
	var w = 700;
	if (modalwidth) {w = modalwidth;}
	// Reset scroll position
	window.scrollTo(0,0);
	
	$("#dialog-content").dialog("destroy");
	$("#dialog-content").dialog({
		position: ['auto',80],
		resizable: false,
		modal: true,
		width: w,
		height: 'auto',
		buttons: {
			"No Thanks": function() {
				// Set user cookie
				$.cookie('survey',true,{expires:90, path:'/'});
				
				$(this).dialog("destroy");
				$(this).html('');
				// Reset scroll position
				window.scrollTo(0,0);
			},
			"Continue": function() {
				// Set user cookie
				$.cookie('survey',true,{expires:365, path:'/'});
				
				// Open survey window
				vp_openWindow(url, 'surveyWin', 1200, 600);
				
				$(this).dialog("destroy");
				$(this).html('');
				// Reset scroll position
				window.scrollTo(0,0);
			}
		},
		open: function() {
			$(this).html('<div style="padding:20px 20px 60px 20px"><h1 style="font-size:22px !important;text-align:center;margin-bottom:30px">Would you like to participate in our brief 5-minute survey?</h1><h2 style="font-size:16px !important;text-align:center">It\'s designed to learn about your Valpak.com experience so that we can continuously improve our site and give you the best experience possible.<br /><br />Your feedback and candid response would be greatly appreciated.</h2></div>');
		},
		overlay: {
			backgroundColor: "#000",
			opacity: 0.5
		},
		draggable: false
	}).dialog("widget")
	
	.find(".ui-dialog-buttonpane button")
	.eq(0).addClass("btn-back-browsing2").end()
	.eq(1).addClass("btn-send").end();
}
