//Open popup
//window.addEvent('domready', function() {
//    box = new MultiBox('mb', {
//        descClassName: 'multiBoxDesc',
//        useOverlay: true,
//        showNumbers: false,
//        showControls: false,
//        fixedTop: false,
//        openFromLink: false,        
//        openClosePosition: startPopupPosition
//    });
//});

function NavigateTop(url) {
    window.top.location = url;
}

function OpenWallpaper(popupId) {

    if (typeof startPopupPosition == "string")
        startPopupPosition = parseFloat(startPopupPosition.replace("px", ""));
        
    if (!box.open) {
        box = new MultiBox('mb', {
            descClassName: 'multiBoxDesc',
            useOverlay: true,
            showNumbers: false,
            showControls: false,
            fixedTop: false,
            openFromLink: false,
            openClosePosition: startPopupPosition,
            closeWhite: false
        });
    }
    $('closeBtn').style.top = "3px";
    $('closeBtn').style.right = "3px";
    box.open($(popupId));
}

function OpenPopUp(popupId) {
    if (typeof startPopupPosition == "string")    
       startPopupPosition = parseFloat(startPopupPosition.replace("px", ""));
    
    if (!box.open) {
        box = new MultiBox('mb', {
            descClassName: 'multiBoxDesc',
            useOverlay: true,
            showNumbers: false,
            showControls: false,
            fixedTop: false,
            openFromLink: false,
            openClosePosition: startPopupPosition,
            closeWhite: false
        });
    }
    $('closeBtn').style.top = "3px";
    $('closeBtn').style.right = "3px";  
    box.open($(popupId));
}

function OpenTrackingPopUp(popupId, category, action, label) {

    if (typeof startPopupPosition == "string")
        startPopupPosition = parseFloat(startPopupPosition.replace("px", ""));

    if (!box.open) {
        box = new MultiBox('mb', {
            descClassName: 'multiBoxDesc',
            useOverlay: true,
            showNumbers: false,
            showControls: false,
            fixedTop: false,
            openFromLink: false,
            openClosePosition: startPopupPosition,
            closeWhite: false
        });
    }
    $('closeBtn').style.top = "3px";
    $('closeBtn').style.right = "3px";
    box.open($(popupId));
    try {
        pageTracker._trackEvent(category, action, label);
    } catch(err) {}
}

function CloseLightBox(ref) {
    ClosePopUp();
    box.closeButton.style.display = "block";
    if (ref == 1)
        sendToActionScript();   
}

function ClosePopUp() {
    box.close();        
}

var datacoll = {};
function SetData(value) {
    datacoll[datacoll].length = value;
}

function OpenPrintPayment(values) {
    var anc = document.getElementById("PaymentCalculator");
    var href = anc.href.split("?")[0];
    anc.href = href + "?data=" + escape(EncodeURL(values));
    if (!box.open) {
        box = new MultiBox('mb', {
            descClassName: 'multiBoxDesc',
            useOverlay: true,
            showNumbers: false,
            showControls: false,
            fixedTop: false,
            openFromLink: false,
            openClosePosition: startPopupPosition,
            closeWhite: true
        });
    }
    $('closeBtn').style.top = "3px";
    $('closeBtn').style.right = "3px";
    this.box.closeWhite = true;
    box.open($("PaymentCalculator"));
    this.box.closeWhite = false;
}

function OpenPrintPayment2(values){
    OpenPrintPayment(values);
}

function OpenPrintImplementDetail() {   
    if (!box.open) {
        box = new MultiBox('mb', {
            descClassName: 'multiBoxDesc',
            useOverlay: true,
            showNumbers: false,
            showControls: false,
            fixedTop: false,
            openFromLink: false,
            openClosePosition: startPopupPosition,
            closeWhite: true
        });
    }
    $('closeBtn').style.top = "3px";
    $('closeBtn').style.right = "3px";
    this.box.closeWhite = true;
    box.open($("PrintImplementDetail"));
    this.box.closeWhite = false;
}

function OpenPrintImplementDetailTracking(category, action, label) {
    TrackEvent(category, action, label);

    OpenPrintImplementDetail();
}

function OpenPrintTractorDetail() {
    if (!box.open) {
        box = new MultiBox('mb', {
            descClassName: 'multiBoxDesc',
            useOverlay: true,
            showNumbers: false,
            showControls: false,
            fixedTop: false,
            openFromLink: false,
            openClosePosition: startPopupPosition,
            closeWhite: true
        });
    }
    $('closeBtn').style.top = "3px";
    $('closeBtn').style.right = "3px";
    this.box.closeWhite = true;
    box.open($("PrintTractorDetail"));
    this.box.closeWhite = false;
}

function OpenPrintTractorDetailTracking(category, action, label) {
    TrackEvent(category, action, label);

    OpenPrintTractorDetail();
}

function OpenGallery(imgId,gdId) {
    if (imgId == null) return;
    if (gdId == null) return;
    var anc = document.getElementById("ImageGallery");
    var href = anc.href.split("&")[0] 
    anc.href = href + "&id=" + imgId+"&gd="+gdId;
    if (!box.open) {
        box = new MultiBox('mb', {
            descClassName: 'multiBoxDesc',
            useOverlay: true,
            showNumbers: false,
            showControls: false,
            fixedTop: false,
            openFromLink: false,
            openClosePosition: startPopupPosition,
            closeWhite: true
        });
    }
    $('closeBtn').style.top = "3px";
    $('closeBtn').style.right = "3px";
    box.open($("ImageGallery"));
}

function OpenHowToVideo(id, start) {
    var anc = document.getElementById("HowToVideoGallery");
    var href = anc.href.split("?")[0];
    anc.href = href + "?howToKey=" + id + "&start="+start;
    if (!box.open) {
        box = new MultiBox('mb', {
            descClassName: 'multiBoxDesc',
            useOverlay: true,
            showNumbers: false,
            showControls: false,
            fixedTop: false,
            openFromLink: false,
            openClosePosition: startPopupPosition,
            closeWhite: true
        });
    }
    $('closeBtn').style.top = "3px";
    $('closeBtn').style.right = "3px";
    box.open($("HowToVideoGallery"));
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    } else {
        return document[movieName];
    }
}
function sendToActionScript() {
    thisMovie("main").sendToActionScript();    
}
