//<!-- 
var PageLoad = false;
var isgecko = (document.getElementById && !document.all) ? 1 : 0;
var ismac = (navigator.appVersion.indexOf("Mac") != -1);
var isie = (document.all) ? 1 : 0;
var isns4 = (document.layers) ? 1 : 0;
var isSafari = (navigator.userAgent.toLowerCase().indexOf("safari") != -1);

// ------[ OnLoad Init ]------------------------------------------------- //
AttachEvent(window,'load',init,false);
function init() {
	//SetSideBarHeight();
	
	//JQUERY:Activates the fancy Select Plugin(if exists):
	$("select.stylishSelect").sSelect();
	}

// ------[ Side Bar Height ]------------------------------------------------- //
function SetSideBarHeight() {
	objPageContent = document.getElementById("pageContent");
	objPageSideBar = document.getElementById("pageSideBar");
	if((objPageContent != null) && (objPageSideBar != null)) {
		if(objPageContent.offsetHeight > objPageSideBar.offsetHeight) {
			objPageSideBar.style.height = objPageContent.offsetHeight + "px";
			}
		}
	}

// ------[ Generic Popup Window ]------------------------------------------------- //
function popWin(url,w,h,scroll,tools,name,center) {
	var str = "height=" + h + ",innerHeight=" + h;
	str += ",width=" + w + ",innerWidth=" + w;
	if(!center) var center = false;
	if(!scroll) scroll = 0;
	if(!tools) tools = 0;
	if(!name) name = "pop";

	if((window.screen) && (center)) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - w) / 2;
		var yc = (ah - h) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		}
		
	pop = window.open(url,name,'toolbar=' + tools + ',location=0,directories=0,status=0,menubar=0,scrollbars=' + scroll + ',resizable=1,' + str).focus();
	}
	
// ------[ Cookie Handle ]------------------------------------------------- //
var now = new Date();
var expires = now.getTime() + 365 * 24 * 60 * 60 * 1000;
var expires = new Date(expires)
function WriteCookie(name, value) {
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString();
	}

function WriteCookieExp(name, value, Exp) {
	var expires = now.getTime() + Exp;
	var expires = new Date(expires)	
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString();
	}	

function ReadCookie(Name) {   
	var search = Name + "="   
	if (document.cookie.length > 0) { 					// if there are any cookies      
		offset = document.cookie.indexOf(search)       
		if (offset != -1) { 							// if cookie exists          
			offset += search.length  					// set index of beginning of value         
			end = document.cookie.indexOf(";", offset)	// set index of end of cookie value         
			if (end == -1) end = document.cookie.length         
			return unescape(document.cookie.substring(offset, end))      
			}    
		}
	}	

	

// ------[ Search ]------------------------------------------------- //
function doSearch(id) {
	value = eval("document.forms[0]." + id + ".value");
	if((value != 'Inscrivez votre mot clé') && (value != '')) document.location = "http://www.shoppingtva.ca/TVAShoppingPublic/Search/Default.aspx?search=" + value;
	}
	
	
function checkEnter(e, id){ //e is event object passed from function invocation
	var characterCode;
	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	} else {
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		doSearch(id); //submit the form
		return false;
	} else {
		return true;
	}
}	
//-->
