
/*	ColorBox options for the French Check Availability popup */

$(document).ready(function(){
	var options = {
		width:"500px", 
		height:"355px", 
		transition:"none",
		iframe:true, 
		opacity:"0.5", 
		title:"V&eacute;rifier la disponibilit&eacute;"
	}
	
	if (jQuery.browser.msie && jQuery.browser.version < 7) {
		options = $.extend(options, {onLoad:function(){	$("#cboxWrapper").pngFix(); } });
	}
	
	var match = document.cookie.match(/bundleUrl=([^\;]*)/);
	var region = (location.href.indexOf("/qc/") > -1 || location.href.indexOf("_qc") > -1 ? "qc" : "on");
	var lang = (location.href.indexOf("/fr/") > -1 || location.href.indexOf("_fr") > -1 ? "fr" : "en");
	
	var bundleUrl = (match != undefined && match[1] != undefined ? decodeURIComponent(match[1]) : undefined);
	
	// Validates :
	// Redirection to previous bundle page does not apply when user is on a bundle calculator page
	// Apply redirection if same region/language
	
	if (location.href.indexOf("bundle_calculator") == -1 
			&& bundleUrl != undefined 
			&& bundleUrl.indexOf("_" + region) > -1
			&& bundleUrl.indexOf("/" + lang + "/") > -1) {
		
		$('.popCheckAvailability').unbind('click');
		$(".popCheckAvailability").click(function(event){
			location.href = decodeURIComponent(match[1]) + "&shop_red=1";
			event.preventDefault();
		});
		
	} else {
		$(".popCheckAvailability").colorbox(options);
	}
	
});

