window.onload = function() {
    if ($('reference1')) { var newZoom; prodInfoZoom(); }
}

function $ (id) {return document.getElementById(id);}

function TellaFriend(url) {
friendWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=1,resizable=0,width=390,height=540');
self.name = "friendWin"; }

function CCard(url) {
friendWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=1,resizable=0,width=820,height=600');
self.name = "CCardWin"; }

function BigPic(url) {
friendWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=1,resizable=1,width=600,height=600');
self.name = "BigPicWin"; }

function Brands(url) {
brandWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=1,resizable=0,width=750,height=600');
self.name = "brandWin"; }

function Chatroom(url) {
ChatroomWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=1,resizable=0,width=500,height=400');
self.name = "chatroomWin"; }

function Buyers(url) {
friendWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=1,resizable=0,width=600,height=500');
self.name = "BuyersWin"; }

function Buyers(url) {
BuyersWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=1,resizable=0,width=600,height=500');
self.name = "BuyersWin"; }

function ProdThumb(url) {
ProdThumbWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=1,resizable=0,width=500,height=600');
self.name = "ProdThumbWin"; }

function ApplicationForm(url) {
ApplicationFormWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=1,resizable=0,width=620,height=1000');
self.name = "ProdThumbWin"; }

function ProductImages(url) {
ProductImagesWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=1,resizable=1,width=850,height=600');
self.name = "ProductImagesWin"; }

<!--

if (document.images) {
img1a_on = new Image;img1a_on.src = "store/images/TMenu_Home_On.jpg"
img1a_off = new Image;img1a_off.src = "store/images/TMenu_Home_Off.jpg"
img2a_on = new Image;img2a_on.src = "store/images/TMenu_Account_On.jpg"
img2a_off = new Image;img2a_off.src = "store/images/TMenu_Home_Off.jpg"
img3a_on = new Image;img3a_on.src = "store/images/TMenu_Info_On.jpg"
img3a_off = new Image;img3a_off.src = "store/images/TMenu_Home_Off.jpg"
img4a_on = new Image;img4a_on.src = "store/images/TMenu_Contact_On.jpg"
img4a_off = new Image;img4a_off.src = "store/images/TMenu_Home_Off.jpg"
img5a_on = new Image;img5a_on.src = "store/images/TMenu_Offer_On.jpg"
img5a_off = new Image;img5a_off.src = "store/images/TMenu_Home_Off.jpg"
img6a_on = new Image;img6a_on.src = "store/images/TMenu_Basket_On.jpg"
img6a_off = new Image;img6a_off.src = "store/images/TMenu_Home_Off.jpg"
img7a_on = new Image;img7a_on.src = "store/images/TMenu_Checkout_On.jpg"
img7a_off = new Image;img7a_off.src = "store/images/TMenu_Home_Off.jpg"
}

function sswap1_on(){
document.nav.src = img1a_on.src
return true;
}
function sswap1_off(){
document.nav.src = img1a_off.src
return true;
}
function sswap2_on(){
document.nav.src = img2a_on.src
return true;
}
function sswap2_off(){
document.nav.src = img2a_off.src
return true;
}
function sswap3_on(){
document.nav.src = img3a_on.src
return true;
}
function sswap3_off(){
document.nav.src = img3a_off.src
}
function sswap4_on(){
document.nav.src = img4a_on.src
return true;
}
function sswap4_off(){
document.nav.src = img4a_off.src
}
function sswap5_on(){
document.nav.src = img5a_on.src
return true;
}
function sswap5_off(){
document.nav.src = img5a_off.src
}
function sswap6_on(){
document.nav.src = img6a_on.src
return true;
}
function sswap6_off(){
document.nav.src = img6a_off.src
return true;
}
function sswap7_on(){
document.nav.src = img7a_on.src
return true;
}
function sswap7_off(){
document.nav.src = img7a_off.src
return true;
}

// image swap
function move_in(img_name,img_src) {
	document[img_name].src=img_src;
	}

	function move_out(img_name,img_src) {
	document[img_name].src=img_src;
	}
	
//clear text from search box 
function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}

function QuickSearch(){
    		document.QS.submit();
}

// --> 



function infoZoom(ref, obj1, obj2, aObj, zIn) {
    //this.fade1=new opacity(aObj,0,0,100,0,100,10);
    //this.fade2=new opacity(obj1,0,0,50,0,50,10);
    this.timer = new t();
    this.zoomOffset = zIn;
    this.pos = { x: 0, y: 0 };
    this.ref = ref;
    this.obj1 = obj1;
    this.obj2 = obj2;
    this.aObj = aObj;

    try { this.bounds = { x: ref.offsetWidth, y: ref.offsetHeight, xo: ref.offsetLeft, yo: ref.offsetTop }; } catch (err) { }
}
infoZoom.prototype = {
    mouseOut: function () {
        //this.doMouseOut();
        this.aboutToClose = true;
        this.timer.timer(
                c$(this, 'doMouseOut'),
                100
            );
    },
    doMouseOut: function () {
        document.onclick = document.onmousemove = null;
        this.setZoom(this.obj2, 'none');
        this.setZoom(this.aObj, 'none');
        //clearInterval(this.timeout);               
    },
    mouseOver: function () { this.aboutToClose = false; this.timer.endTimer(); document.onclick = document.onmousemove = c$(this, 'doMouseOver'); },
    doMouseOver: function (event) {
        var check = getTarget(event);
        if (check !== this.obj2 && check != this.ref && this.aboutToClose == true) { this.mouseOut(); return false; }
        this.setZoom(this.obj2, 'block');
        this.setZoom(this.aObj, 'block');
        this.doZoom(getRelPos(event, this.ref));
        this.mainImage(this.obj1);
    },
    doZoom: function (coords) {
        this.obj2.style.left = coords.x - this.obj2.offsetWidth / 2 + 'px';
        this.obj2.style.top = coords.y - this.obj2.offsetHeight / 2 + 'px';
        if (this.obj2.offsetLeft < this.bounds.xo) { this.obj2.style.left = this.bounds.xo + 'px'; }
        if (this.obj2.offsetTop < this.bounds.yo) { this.obj2.style.top = this.bounds.yo + 'px'; }
        if (this.obj2.offsetLeft + this.obj2.offsetWidth > this.bounds.x + this.bounds.xo) { this.obj2.style.left = this.bounds.x + this.bounds.xo - this.obj2.offsetWidth + 'px'; }
        if (this.obj2.offsetTop + this.obj2.offsetHeight > this.bounds.y + this.bounds.yo) { this.obj2.style.top = this.bounds.y + this.bounds.yo - this.obj2.offsetHeight + 'px'; }
        this.pos.x = this.obj2.offsetLeft;
        this.pos.y = this.obj2.offsetTop;
    },
    getTarget: function (event) {
        var targ;
        if (!event) { var event = window.event; }
        if (event.target) { targ = event.target; }
        else if (event.srcElement) { targ = event.srcElement; }
        if (targ.nodeType == 3) { targ = targ.parentNode; } return targ;
    },
    mainImage: function (obj) {
        obj.style.left = -(this.pos.x * this.zoomOffset) + 'px';
        obj.style.top = -(this.pos.y * this.zoomOffset) + 'px';
    },
    setZoom: function (obj, instr) {
        obj.style.display = instr;
    }
}

function getAbsPos(element) {
                var r = { x: element.offsetLeft, y: element.offsetTop };
                if (element.offsetParent) { var tmp = getAbsPos(element.offsetParent); r.x += tmp.x; r.y += tmp.y; } return r;
            }
            function getRelPos(event, reference) {
                var x, y; event = event || window.event; var el = event.target || event.srcElement;
                if (!window.opera && typeof event.offsetX != 'undefined') {
                    var pos = { x: event.offsetX, y: event.offsetY }; var e = el;
                    while (e) {
                        e.mouseX = pos.x; e.mouseY = pos.y;
                        pos.x += e.offsetLeft; pos.y += e.offsetTop; e = e.offsetParent;
                    }
                    var e = reference; var offset = { x: 0, y: 0 }
                    while (e) {
                        if (typeof e.mouseX != 'undefined') {
                            x = e.mouseX - offset.x; y = e.mouseY - offset.y; break;
                        }
                        offset.x += e.offsetLeft; offset.y += e.offsetTop; e = e.offsetParent;
                    } e = el;
                    while (e) { e.mouseX = undefined; e.mouseY = undefined; e = e.offsetParent; } 
                }
                else { var pos = getAbsPos(reference); x = event.pageX - pos.x; y = event.pageY - pos.y; }
                return { x: x, y: y };
            } 
                function c$(a,b){
	                return(
		                function(e){
			                return a[b](e,this);
		                }
	                )
                }
                
                function t() { this.timeout = this.interval = null; }
t.prototype = { timer: function (todo, time) { clearTimeout(this.timeout); this.timeout = window.setTimeout(todo, time); }, intervaler: function (todo, time) { clearInterval(this.interval); this.interval = setInterval(todo, time); }, endInterval: function () { clearInterval(this.interval); this.interval = null; }, endTimer: function () { clearTimeout(this.timeout); this.timeout = null; } }

                function $(ref){return document.getElementById(ref);}

function prodInfoZoom() {
    var refImage = $('reference1'), wrapZoom = $('wrapMainZoom'), obj1 = $('reference2');
    var obj2 = $('zoomView');
    newZoom = new infoZoom(refImage, obj1, obj2, wrapZoom, 4);
    obj2.onmouseover = refImage.onclick = function () { newZoom.mouseOver(); }
    obj2.onclick = function () { newZoom.mouseOut(); }
    obj2.onmouseout = function () { newZoom.mouseOut(); };
}

function getTarget(event) {
    var targ; if (!event) { var event = window.event; }
    if (event.target) { targ = event.target; }
    else if (event.srcElement) { targ = event.srcElement; }
    if (targ.nodeType == 3) { targ = targ.parentNode; } return targ;
}

function $$(oElm, strTagName, strClassName) {
    var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); strClassName = strClassName.replace(/\-/g, "\\-"); var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); var oElement; for (var i = 0; i < arrElements.length; i++) { oElement = arrElements[i]; if (oRegExp.test(oElement.className)) { arrReturnElements.push(oElement); } }
    return (arrReturnElements)
}

function c$(a, b) { return (function (e) { return a[b](e, this); }) }

function d$(a, b, c) { return (function () { return a[b](c); }) }
