Wed Nov 22 2017
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
$(function(){





	// ***********************************************************************************
	// HOME PAGE PUSHDOWN CONTROLS
	//                       (images are in /lp/rtos/holiday_2017/homepage_dropdowns/img/)
	// ***********************************************************************************

	var when_to_run_pushdown = 'schedule'; // can be 'now', 'schedule', or 'custom'
		// ideally, use 'schedule'
		// only use 'custom' if you get a random request (such as "show pushdown when cid=whatever")


	if(when_to_run_pushdown==='now'){
		run_pushdown_now({
			image_base: 'bfmonthsaleaei', // example: "xyz" shows "xyz_desktop.jpg" and "xyz_mobile.jpg"
			link_url: 'https://www.rosettastone.com/lp/sbsr/bfmonthsaleaei/'
		});
	}
	if(when_to_run_pushdown==='schedule'){
		run_pushdown_on_schedule();
	}
	if(when_to_run_pushdown==='custom'){
		run_pushdown_custom();
	}





	// ---------------------------------------------
	// USE THIS TO RUN PUSHDOWN NOW
	// ---------------------------------------------
	function run_pushdown_now(pushdown){
		show_pushdown(pushdown.image_base, pushdown.link_url);
	}


	/*
	Schedule notes
	----

		Black Friday Dropdown:
		https://www.rosettastone.com/lp/sbsr/bfmonthsaleaei/

		Cyber Monday Dropdown:
		https://www.rosettastone.com/lp/sbsr/cms246dealadi/

		Cyber Week (Tuesday, Thursday, Saturday):
		https://www.rosettastone.com/lp/sbsr/cmetmonthdealadi/

		Cyber Week (Wednesday, Friday, Sunday):
		https://www.rosettastone.com/lp/sbsr/cmes246dealadi/
	*/


	// ---------------------------------------------
	// USE THIS TO RUN PUSHDOWN ON A SCHEDULE
	// ---------------------------------------------
	function run_pushdown_on_schedule(){

		var schedule = [
			// test for today
			{ start:'Nov 22, 2017 00:00', end:'Nov 22, 2017 20:00', pushdown:{
				image_base: 'cms246dealadi',
				link_url: 'https://www.rosettastone.com/lp/sbsr/cms246dealadi/'
			}},
			// Black Friday
			{ start:'Nov 22, 2017 22:00', end:'Nov 26, 2017 11:59', pushdown:{
				image_base: 'bfmonthsaleaei',
				link_url: 'https://www.rosettastone.com/lp/sbsr/bfmonthsaleaei/'
			}},
			// Cyber Monday
			{ start:'Nov 26, 2017 12:00', end:'Nov 27, 2017 23:59', pushdown:{
				image_base: 'cms246dealadi',
				link_url: 'https://www.rosettastone.com/lp/sbsr/cms246dealadi/'
			}},
			// Cyber Tuesday
			{ start:'Nov 28, 2017 00:00', end:'Nov 28, 2017 23:59', pushdown:{
				image_base: 'cmetmonthdealadi',
				link_url: 'https://www.rosettastone.com/lp/sbsr/cmetmonthdealadi/'
			}},
			// Cyber Wednesday
			{ start:'Nov 29, 2017 00:00', end:'Nov 29, 2017 23:59', pushdown:{
				image_base: 'cmes246dealadi',
				link_url: 'https://www.rosettastone.com/lp/sbsr/cmes246dealadi/'
			}},
			// Cyber Thursday
			{ start:'Nov 30, 2017 00:00', end:'Nov 30, 2017 23:59', pushdown:{
				image_base: 'cmetmonthdealadi',
				link_url: 'https://www.rosettastone.com/lp/sbsr/cmetmonthdealadi/'
			}},
			// Cyber Friday
			{ start:'Dec 1, 2017 00:00', end:'Dec 1, 2017 23:59', pushdown:{
				image_base: 'cmes246dealadi',
				link_url: 'https://www.rosettastone.com/lp/sbsr/cmes246dealadi/'
			}},
			// Cyber Saturday
			{ start:'Dec 2, 2017 00:00', end:'Dec 2, 2017 23:59', pushdown:{
				image_base: 'cmetmonthdealadi',
				link_url: 'https://www.rosettastone.com/lp/sbsr/cmetmonthdealadi/'
			}},
			// Cyber Sunday
			{ start:'Dec 3, 2017 00:00', end:'Dec 3, 2017 23:59', pushdown:{
				image_base: 'cmes246dealadi',
				link_url: 'https://www.rosettastone.com/lp/sbsr/cmes246dealadi/'
			}}
		];


		var pushdown = getPushdownFromSchedule(schedule);
		if(pushdown){
			show_pushdown(pushdown.image_base, pushdown.link_url);
		}
	}

	function getPushdownFromSchedule(schedule){
		var now = Date.now();
		for(var i=0; i<schedule.length; i++){
			if( Date.parse(schedule[i].start)<=now && now<=Date.parse(schedule[i].end) ){
				return schedule[i].pushdown;
			}
		}
		return null;
	}






	// ---------------------------------------------
	// USE THIS TO RUN PUSHDOWN UNDER CUSTOM CONDITIONS
	//     for example: if cid=whatever
	// ---------------------------------------------
	function run_pushdown_custom(){
		var whatever_condition = true;

		// if the custom condition is met (like a cid=whatever), run a custom pushdown
		if(whatever_condition){
			run_pushdown_now({
				image_base: 'home_pushdown_bf_7', // example: "xyz" shows "xyz_desktop.jpg" and "xyz_mobile.jpg"
				link_url: 'https://www.rosettastone.com/lp/sbsr/sitewide/'
			});
		}

		// otherwise, go back to the regularly scheduled pushdowns
		else{
			run_pushdown_on_schedule();
		}
	}




	// ---------------------------------------------
	// THIS SHOWS THE PUSHDOWN
	// ---------------------------------------------
	function show_pushdown(image_base, link_url){
		var css = '<style>.bfcm2017_home_pushdown{display:block;} .bfcm2017_home_pushdown img{width:100%;} .bfcm2017_home_pushdown_img_mobile{display:block;} .bfcm2017_home_pushdown_img_desktop{display:none;} @media(min-width:500px){.bfcm2017_home_pushdown_img_mobile{display:none;} .bfcm2017_home_pushdown_img_desktop{display:block;}}</style>';
		var mobile_img = '<img class="bfcm2017_home_pushdown_img_mobile" src="https://www.rosettastone.com/lp/rtos/holiday_2017/homepage_dropdowns/img/'+image_base+'_mobile.jpg" alt="Click here for special deal on Rosetta Stone">';
		var desktop_img = '<img class="bfcm2017_home_pushdown_img_desktop" src="https://www.rosettastone.com/lp/rtos/holiday_2017/homepage_dropdowns/img/'+image_base+'_desktop.jpg" alt="Click here for special deal on Rosetta Stone">';
		var html = '<a href="'+link_url+'" class="bfcm2017_home_pushdown">' + mobile_img + desktop_img + '</a>';
		$('head').append(css);
		$('body').prepend(html);
		$('.bfcm2017_home_pushdown').hide(); // needed to trick jquery into using block instead of inline-block for slideDown on <a>
		$('.bfcm2017_home_pushdown').slideDown();
	}


});