var merchSection;
var ebaySection;
var webSection;
var merchSectionButton;
var ebaySectionButton;
var webSectionButton;
var firstDivider;
var secondDivider;
var minColumnWidth = 70;
var movement_threshold = 5;
var curSpacerCell;
var curSpacerCellX;
var mouseDownX;
var initColWidth = 500;
var windowWidth = 1000;
var windowMinWidth = 600;
var isIE = navigator.appVersion.indexOf( "MSIE" ) >= 1;
var isOpera = navigator.userAgent.toLowerCase().indexOf("opera") != -1;
var isFF = (navigator.userAgent.toLowerCase().indexOf("mozilla/5") != -1 && navigator.vendor=="Firefox");
window.onresize=setWindowWidth;
function loadScript() {
merchSection = document.getElementById("merch_column");
ebaySection = document.getElementById("ebay_column");
webSection = document.getElementById("web_column");
merchSectionButton = document.getElementById("merch_adjustTDbutton");
ebaySectionButton = document.getElementById("ebay_adjustTDbutton");
webSectionButton = document.getElementById("web_adjustTDbutton");
firstDivider = document.getElementById("ebay_adjTD");
secondDivider = document.getElementById("web_adjTD");
initCookie();
checkArrows();
setWindowWidth();
}
function setWindowWidth(){
if( typeof( window.innerWidth ) == 'number') windowWidth = window.innerWidth;
else if( document.documentElement && document.documentElement.clientWidth) windowWidth = document.documentElement.clientWidth;
else if( document.body && document.body.clientWidth) windowWidth = document.body.clientWidth;
windowWidth -= 75;
if(windowWidth < windowMinWidth) windowWidth = windowMinWidth;
resizeColumns();
setSECookie();
}
function toggleSection ( sectionName ) {
if ( document.getElementById( sectionName + "_column").style.display == 'none' ) { // show section, hide control
showSection( sectionName );
} else {
hideSection( sectionName );
}
firstDivider.style.display = (merchSection.style.display == '' && (ebaySection.style.display == '' || webSection.style.display == '')) ? '' : 'none';
secondDivider.style.display = (ebaySection.style.display == '' && webSection.style.display == '') ? '' : 'none';
checkArrows();
resizeColumns();
setSECookie();
}
function showSection ( sectionName ) {
var section;
var sectionButton;
if(sectionName == "merch"){
section = merchSection;
sectionButton = merchSectionButton;
}else if(sectionName == "ebay"){
section = ebaySection;
sectionButton = ebaySectionButton;
}else if(sectionName == "web"){
section = webSection;
sectionButton = webSectionButton;
}else{
return;
}
section.style.display = '';
var fullWidth = 900;
var openSections = displayed(merchSection) + displayed(ebaySection) + displayed(webSection);
var openColWidth = fullWidth / openSections;
if(displayed(merchSection)) resetSectionWidth(merchSection, openColWidth);
if(displayed(ebaySection)) resetSectionWidth(ebaySection, openColWidth);
if(displayed(webSection)) resetSectionWidth(webSection, openColWidth);
sectionButton.src = sectionButton.src.replace( '_off.gif', '_on.gif' );
}
function hideSection ( sectionName ) {
if(sectionName == 'merch'){
merchSection.style.display = 'none';
merchSectionButton.src = merchSectionButton.src.replace( '_on.gif', '_off.gif' );
}else if(sectionName == 'ebay'){
ebaySection.style.display = 'none';
ebaySectionButton.src = ebaySectionButton.src.replace( '_on.gif', '_off.gif' );
}else if(sectionName == 'web'){
webSection.style.display = 'none';
webSectionButton.src = webSectionButton.src.replace( '_on.gif', '_off.gif' );
}
}
function resizeColumns () {
var change = windowWidth - getShoppingTableWidth();
var openSections = displayed(merchSection) + displayed(ebaySection) + displayed(webSection);
var newSectionDiff = (change - (change % openSections)) / openSections;
var rem = 0;
if(displayed(merchSection))
rem = resetSectionWidth(merchSection, parseInt(merchSection.width) + newSectionDiff);
if(displayed(ebaySection))
rem = resetSectionWidth(ebaySection, parseInt(ebaySection.width) + newSectionDiff - rem);
if(displayed(webSection))
rem = resetSectionWidth(webSection, parseInt(webSection.width) + newSectionDiff - rem);
if(0 < rem){
if(displayed(merchSection))
rem = resetSectionWidth(merchSection, parseInt(merchSection.width) + newSectionDiff - rem);
if(displayed(ebaySection))
rem = resetSectionWidth(ebaySection, parseInt(ebaySection.width) + newSectionDiff - rem);
if(displayed(webSection))
rem = resetSectionWidth(webSection, parseInt(webSection.width) + newSectionDiff - rem);
}
}
function getShoppingTableWidth () {
var spTableWidth = 0;
var openSections = displayed(merchSection) + displayed(ebaySection) + displayed(webSection);
spTableWidth += displayed(merchSection) ? parseInt(merchSection.width) : 35;
spTableWidth += displayed(ebaySection) ? parseInt(ebaySection.width) : 35;
spTableWidth += displayed(webSection) ? parseInt(webSection.width) : 35;
if(displayed(firstDivider)) spTableWidth += 6;
if(displayed(secondDivider)) spTableWidth += 6;
spTableWidth += 10;
return spTableWidth;
}
function resetSectionWidth ( section, width) {
var rem = minColumnWidth - width;
section.width = 0 < rem ? minColumnWidth : width;
section.childNodes[0].style.width = parseInt(section.width);
return 0 < rem ? rem : 0;
}
function displayed( cell){
if(cell.style.display == 'none')
return false;
return true;
}
function handleMouseDown ( e ) {
if ( isIE ) {
e.cancelBubble = true;
e.returnValue = false;
curSpacerCell = e.srcElement;
mouseDownX = e.screenX;
} else {
e.stopPropagation();
e.preventDefault();
curSpacerCell = e.currentTarget;
mouseDownX = e.pageX;
}
curSpacerCellX = curSpacerCell.offsetLeft;
if(isOpera){
var tempCell = curSpacerCell;
while(tempCell.offsetParent){
tempCell = tempCell.offsetParent;
curSpacerCellX += tempCell.offsetLeft;
}
}
if(!isOpera){
window.onmousemove = handleMouseMove;
window.onmouseup = handleMouseUp;
document.onmousemove = handleMouseMove;
document.onmouseup = handleMouseUp;
}else if(document.attachEvent){
document.attachEvent("onmousemove", handleMouseMove);
document.attachEvent("onmouseup", handleMouseUp);
}
}
function handleMouseMove ( e ) {
if (!e) e = window.event;
if ( isIE ) {
e.cancelBubble = true;
e.returnValue = false;
newX = e.screenX;
} else {
e.stopPropagation();
e.preventDefault();
newX = e.pageX;
}
var actualDiff = newX - mouseDownX;
if(isOpera){
var newSpacerCellX = curSpacerCell.offsetLeft;
var tempCell = curSpacerCell;
while(tempCell.offsetParent){
tempCell = tempCell.offsetParent;
newSpacerCellX += tempCell.offsetLeft;
}
}
var dragDiff = (newSpacerCellX ? newSpacerCellX : curSpacerCell.offsetLeft) - curSpacerCellX;
var change = actualDiff - dragDiff;
if ( Math.abs( change ) < movement_threshold ) return;
var movement = 0;
var pos = 0 < change;
if(pos) change = - Math.abs( change );
var firstDiv = pos ? "ebay_adjTD" : "web_adjTD";
var secondDiv = pos ? "web_adjTD" : "ebay_adjTD";
var firstSection = pos ? webSection : merchSection;
var secondSection = pos ? merchSection : webSection;
if(curSpacerCell.id == firstDiv){
if(ebaySection.style.display == ''){
var rem = adjustColumnWidth( ebaySection, change );
movement += change - rem;
change = rem;
}
}
if(firstSection.style.display == ''){
var rem = adjustColumnWidth( firstSection, change );
movement += change - rem;
change = rem;
}
if(curSpacerCell.id == secondDiv){
if(ebaySection.style.display == '')
adjustColumnWidth( ebaySection, -movement );
else
adjustColumnWidth( secondSection, -movement );
}
else{
adjustColumnWidth( secondSection, -movement );
}
}
function adjustColumnWidth ( section, change ) {
var origSectionWidth = parseInt(section.width);
section.width = (origSectionWidth + change) < minColumnWidth ? minColumnWidth : origSectionWidth + change;
section.childNodes[0].style.width = parseInt(section.width);
return origSectionWidth + change - parseInt(section.width);
}
function handleMouseUp ( e ) {
setSECookie();
if (!e) e = window.event;
if ( isIE ) e.cancelBubble = true;
else e.stopPropagation();
if(!isOpera){
window.onmousemove = "";
window.onmouseup = "";
document.onmousemove = "";
document.onmouseup = "";
}else if(document.detachEvent){
document.detachEvent("onmouseup", handleMouseUp);
document.detachEvent("onmousemove", handleMouseMove);
}
}
function toggleclicktext( targetId, newtextId , hrefId ){
if (document.getElementById){
target = document.getElementById( targetId );
newtext = document.getElementById ( newtextId );
href = document.getElementById ( hrefId );
if (target.style.visibility == "visible"){
target.style.visibility = "hidden";
href.style.textDecoration = "underline";
newtext.style.fontWeight = "";
} else {
target.style.visibility = "visible";
href.style.textDecoration = "none";
newtext.style.fontWeight = "bold";
}
}
}
function checkArrows(){
var openSections = displayed(merchSection) + displayed(ebaySection) + displayed(webSection);
if(openSections < 2){
hideform('rightmerch');
hideform('leftebay');
hideform('rightebay');
hideform('leftresearch');
}else if (openSections == 3){
showform('rightmerch');
showform('leftebay');
showform('rightebay');
showform('leftresearch');
}else{
if(merchSection.style.display != 'none'){
showform('rightmerch');
hideform('rightebay');
if(ebaySection.style.display != 'none'){
showform('leftebay');
hideform('leftresearch');
}
else{
hideform('leftebay');
showform('leftresearch');
}
}else{
hideform('rightmerch');
hideform('leftebay');
showform('rightebay');
showform('leftresearch');
}
}
}
