var cartText;
var showcart = false;
var listitems_page;
var myurl;
	
	myurl = window.location.href;
	if (myurl.indexOf("/secure/") > -1) 
		listitems_page = '/frames/secure/listitems.asp'
	else
		listitems_page = '/frames/listitems.asp';
		
function addCart(x) {
var objXMLHTTP;
var embr = "";
	if (document.getElementById('chkEmbroidery'))
		embr = document.getElementById('chkEmbroidery').checked;
	if (document.getElementById("frmQty").value > 0)
		document.getElementById("frameItems").contentWindow.location.replace('/frames/cartoperations.asp?dummy=' + (new Date()).getTime() + '&embr=' + embr + '&code=' + x + '&qty=' + document.getElementById("frmQty").value);
		//document.getElementById("frameItems").src = '/frames/cartoperations.asp?dummy=' + (new Date()).getTime() + '&embr=' + embr + '&code=' + x + '&qty=' + document.getElementById("frmQty").value;
	setTimeout('document.getElementById("frameItems").contentWindow.location.replace("' + listitems_page + '?dummy=' + (new Date()).getTime() + '&showcart=' + showcart + '");', 3000);
	//setTimeout('document.getElementById("frameItems").src = "' + listitems_page + '?dummy=' + (new Date()).getTime() + '&showcart=' + showcart + '";', 3000);
	return false;
}

function hideCart2() {
	showcart = false;
	document.getElementById("frameItems").contentWindow.location.replace(listitems_page + '?dummy=' + (new Date()).getTime() + '&showcart=' + showcart);
	//document.getElementById("frameItems").src = listitems_page + '?dummy=' + (new Date()).getTime() + '&showcart=' + showcart;
	return false;
}

function showCart2(showbutton) {
	showcart = true;
	//document.getElementById("frameItems").src = listitems_page + '?dummy=' + (new Date()).getTime() + '&showcart=true';
	document.getElementById("frameItems").contentWindow.location.replace(listitems_page + '?dummy=' + (new Date()).getTime() + '&showcart=true');
	return false;
}

function updMinicartHeader(tab) {
var el;
	if (el = document.getElementById("minicartheader"))
		el.innerHTML = tab;
}

function adjustIFrameSize(iframeWindow, show) {
var maxHeight;
var frameWidth = 246;
var iframeElement;
var divElement;
var bbarElement;
var posX = 736;

	maxHeight = Math.max(getSize()[1] - 250, 100);
	if (document.getElementById("frameItems")) {
		iframeElement = document.getElementById ("frameItems");
		divElement = document.getElementById ("cart2");
		bbarElement = document.getElementById ("bottombar");
	} else if (document.all) {
		iframeElement = document.all["frameItems"];
		divElement = document.all["cart2"];
		bbarElement = document.all["bottombar"];
	} else {
		return;
	}
	iframeElement.style.width = frameWidth + 'px';
	if (iframeWindow.document.height) {
	//alert('a' + iframeWindow.document.height );
		//if (iframeWindow.document.height < 50) {
		if (!show) {
			bbarElement.style.visibility = "hidden";
			iframeElement.style.visibility = "hidden";
			iframeElement.style.height = '';
		} else {
			bbarElement.style.visibility = "visible";
 			iframeElement.style.visibility = "visible";
			if (iframeWindow.document.height > maxHeight) {
				divElement.style.left = posX - 18 + 'px';
				iframeElement.style.height = maxHeight + 'px';
				iframeElement.style.width = frameWidth + 18 + 'px';
				iframeElement.setAttribute('scrolling','auto');
			} else {
				iframeElement.style.height = iframeWindow.document.height + 'px';
				iframeElement.style.width = frameWidth + 'px';
				iframeElement.setAttribute('scrolling','off');
				divElement.style.left = posX + 'px';
			}
		}
	} else if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat') {
	//alert('b' + iframeWindow.document.documentElement.scrollHeight );
		//if (iframeWindow.document.documentElement.scrollHeight < 50) {
		if (!show) {
			bbarElement.style.visibility = "hidden";
			iframeElement.style.visibility = "hidden";
			iframeElement.style.height = '';
		} else {
			bbarElement.style.visibility = "visible";
 			iframeElement.style.visibility = "visible";
			if (iframeWindow.document.documentElement.scrollHeight > maxHeight) {
				divElement.style.left = posX - 18 + 'px';
				iframeElement.style.height = maxHeight + 'px';
				iframeElement.style.width = frameWidth + 18 + 'px';
				iframeElement.setAttribute('scrolling','on');
			} else {
				iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + 'px';
				iframeElement.style.width = frameWidth + 'px';
				iframeElement.setAttribute('scrolling','off');
				divElement.style.left = posX + 'px';
			}	
			//alert('bend');
		}
	} else if (document.all) {
	//alert('c' + iframeWindow.document.body.scrollHeight);
		//if (iframeWindow.document.body.scrollHeight < 50) {
		if (!show) {
			bbarElement.style.visibility = "hidden";
			iframeElement.style.visibility = "hidden";
			iframeElement.style.height = '';
		} else {
			bbarElement.style.visibility = "visible";
 			iframeElement.style.visibility = "visible";
			//alert('cmiddle');
			if (iframeWindow.document.body.scrollHeight > maxHeight) {
				divElement.style.left = posX - 18 + 'px';
				iframeElement.style.height = maxHeight + 'px';
				iframeElement.style.width = frameWidth + 18 + 'px';
				iframeElement.setAttribute('scrolling','auto');
			} else {
				iframeElement.style.height = iframeWindow.document.body.scrollHeight + 'px';
				iframeElement.style.width = frameWidth + 'px';
				iframeElement.setAttribute('scrolling','off');
				divElement.style.left = posX + 'px';
			}
			//alert('cend');
		}
	} else if (iframeElement.document) {
	//alert(iframeWindow.document.body.offsetHeight);
		//if (iframeWindow.document.body.offsetHeight < 50) {
		if (!show) {
			//alert('f0');
			bbarElement.style.visibility = "hidden";
			iframeElement.style.visibility = "hidden";
			iframeElement.style.height = '';
		} else {
			bbarElement.style.visibility = "visible";
 			iframeElement.style.visibility = "visible";
			if (iframeWindow.document.body.offsetHeight > maxHeight) {
				//alert('f1');
				divElement.style.left = posX - 15 + 'px';
				iframeElement.style.height = maxHeight + 'px';
				iframeElement.style.width = frameWidth + 15 + 'px';
				iframeElement.setAttribute('scrolling','auto');
			} else {
				//alert('f2');
				iframeElement.style.height = iframeWindow.document.body.offsetHeight + 'px';
				iframeElement.style.width = frameWidth + 'px';
				iframeElement.setAttribute('scrolling','off');
				divElement.style.left = posX + 'px';
			}
		}
	} else {
	//alert('d' );
		bbarElement.style.visibility = "hidden";
	}
}

function getSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth, myHeight];
}
