var Sears = {
/*
* Obtains the page html and window information
*/
getWindowSize : function(){
var xScroll, yScroll, windowWidth, windowHeight;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth + window.scrollMaxX;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else {
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
if (self.innerHeight) {
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) {
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
return {'pageWidth':pageWidth, 'pageHeight':pageHeight, 'windowWidth':windowWidth, 'windowHeight':windowHeight};
},
/**
*
*/
showHideRecentlyView: function(e){
if(e)
$("#recentlyView").fadeIn("slow");
else
$("#recentlyView").fadeOut("slow");
},
preloadImages : function(){
if(document.images){
document.myImages = new Array();
for (var i = 0; i < preloadImages.arguments.length; i++){
document.myImages[i] = new Image;
document.myImages[i].src = preloadImages.arguments[i];
}
}
}
};
$(window).resize(function(){
var windowWidth = Sears.getWindowSize().windowWidth;
if (!window.XMLHttpRequest){
if(windowWidth < 1000){
$("#content").css("width", "980px");
$("#footer").css("width", "1000px");
$("#header").css("width", "1000px");
} else {
$("#content").css("width", "auto");
$("#footer").css("width", "auto");
$("#header").css("width", "auto");
}
}
});
//Ajax call
var httpRequestSupported = true;
function _liquid_ajaxCall(url,callbackFunction,returnData,linkId)
{
var httpRequest = false;
// Exit if this function is not supported
if (!httpRequestSupported) {
return;
}
// check if supported
httpRequest = _liquid_isHttpRequestSupported();
if (!httpRequest) {
httpRequestSupported = false;
return false;
}
// Map the response to the callback function
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState == 4) {
if (httpRequest.status == 200) {
if (returnData) {
eval(callbackFunction + '(httpRequest.responseXML,linkId)');
} else {
eval(callbackFunction + '(httpRequest.responseText,linkId)');
}
} else {
// TODO: Keep this line commented in production. The user will have no idea what this means.
//('The AJAX request was made to our backend server and the following error occurred: ' + httpRequest.status);
eval(callbackFunction + '(httpRequest.responseText)');
}
}
else{
if(callbackFunction == 'displayTabContent'){
htmlValue = "
";
document.getElementById(linkId).innerHTML = htmlValue;
}
if(callbackFunction == 'browseSpecialOffer'){
htmlValue = "
";
linkId.innerHTML = htmlValue;
}
}
}
httpRequest.open('GET', url, true);
httpRequest.send(null);
}
function _liquid_isHttpRequestSupported() {
if (window.XMLHttpRequest) {
// Test if the Gecko engine is running. Gecko supports AJAX
httpRequest = new XMLHttpRequest();
if (httpRequest.overrideMimeType) {
httpRequest.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) {
// Test if an IE engine is running
try {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!httpRequest) {
httpRequestSupported = false;
}
return httpRequest;
}
function RecentlyViewedWide(value){
var DivRef = document.getElementById('recentlyView');
DivRef.style.display = "block";
DivRef.innerHTML = value;
Sears.showHideRecentlyView(true);
}
function showHideContainer(element){
if (document.all) {
if (element.style.display == "none")
$("#" + element.id).fadeIn("slow");
else
$("#" + element.id).fadeOut("slow");
}
}
/**
* For Testing Purposes, this should be changed on production... :)
*/
window.onload = function(){
//var menu = new Menu(document.getElementById("ul_menu"));
$("#a_recentlyView").click(function(){
_liquid_ajaxCall("popups/recently_viewed.html","RecentlyViewedWide",true);
});
try {
//
SubCategory.addEventsToCompareCheckBox();
} catch(e){
}
try{
var carusel = new Carusel("./data/home_page.json", document.getElementById("carousel_home"), false, false);
window.onresize = function(){
if (Carusel)
{
carusel.onCarouselResize();
}
};
} catch(e){}
}
if (document.all)
{
if (window.XMLHttpRequest) //IE7
{
document.write("");
}
else //IE6
{
document.write("");
}
}