// POPUP functions --------------------------------------------------------------
	var CWind = new Array();
  	var no_of_children = 0;
  	var current_child = 0;

function playCurrentPopupSound(window_id) {
	for (var ndx = 1; ndx <= no_of_children; ndx++) {
		if (CWind[ndx].play_sound && ndx != window_id) {
			CWind[ndx].toggleSound('background_music');
		}	
	}
}
  				
function CouponPopup(page, name) {
		var	w = window.screen.width;
   		var	h = window.screen.height;
   					
		var popW = 404; 
		var popH = 629;
		var leftPos = ((w-popW)/2);
		var topPos = ((h-popH)/2);
					
		no_of_children++;
		current_child = no_of_children;

		CWind[current_child] = window.open(page, name + current_child, 'width=' + popW + ', height=' + popH + ' ,top=' + topPos + ', left=' + leftPos + 'resizable=0, scrollbars=0');
		CWind[current_child].my_window_id = current_child;
		CWind[current_child].focus();
					
	if (no_of_children > 1) {	
		if (play_sound) {
			toggleSound('background_music');
		}
						
		playCurrentPopupSound(current_child);
	} else if (no_of_children == 1) {
		if (play_sound) {
			toggleSound('background_music');
		}
	}	
}	

function closePopup(window_id) {
	if (CWind[window_id]) {
		if (CWind[window_id].play_sound) {
			CWind[window_id].toggleSound('background_music');
		}

		if (window_id != no_of_children) {
			for (var ndx = window_id; ndx == no_of_children - 1; ndx++) {
					CWind[ndx] = CWind[ndx + 1];
				 	CWind[ndx].my_window_id = ndx;
			}

				CWind.splice(no_of_children, 1);
		} else {
				CWind.splice(no_of_children, 1);
		}
									
			no_of_children--;
					
		if (!no_of_children) {
			toggleSound('background_music');	
		}			
	}
}