function createXMLHttpRequest() {
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   try { return new XMLHttpRequest(); } catch(e) {}
   return null;
 }

function LogCheck() {	// Check login input fields
	if (document.Login.Email.value == "") {
		alert("No Email supplied for Login");
		return false;
		}
	if (document.Login.Shopper_Password.value == "") {
		alert("No Password supplied for Login");
		return false;
		}
	return true;
	}

function popUpWindow(url, w, h) {
	var dims = "height=" + h + ",width=" + w;
	var options = dims + ",toolbar=no,location=top,status=no,menubar=no,scrollbars=yes,resizable=yes";
	var Win = window.open(url, "win", options);
	Win.focus();
	}

function getElement(psID) {
   if(document.all) return document.all[psID];
   if(document.getElementById) return document.getElementById(psID);
   for (var iLayer=1; iLayer<document.layers.length; iLayer++) {
        if(document.layers[iLayer].id==psID) return document.layers[iLayer];
      	}
   return Null;
	}

function visI(nr,which) {
	if (document.layers) {
		document.layers[nr].visibility = (which == 'show') ? 'visible': 'hidden';
	} else if (document.all) {
		document.all[nr].style.visibility = (which == 'show') ? 'visible': 'hidden';
	} else if (document.getElementById) {
	try {
		document.getElementById(nr).style.visibility = (which == 'show') ? 'visible' : 'hidden';
	} catch(e) { if(ASI_Internal) alert('visi: ' + e.description + ' for ' + nr);
				return false; }
		finally { }
		}
	return false;
	}

function div_vis(nr,which) {
	if (document.layers) {
		document.layers[nr].visibility = (which == 'show') ? 'visible': 'hidden';
		document.layers[nr].display = (which == 'show') ? 'block' : 'none';
	} else if (document.all) {
		document.all[nr].style.visibility = (which == 'show') ? 'visible': 'hidden';
		document.all[nr].style.display = (which == 'show') ? 'block' : 'none';
	} else if (document.getElementById) {
	try {
		document.getElementById(nr).style.visibility = (which == 'show') ? 'visible' : 'hidden';
		document.getElementById(nr).style.display = (which == 'show') ? 'block' : 'none';
	} catch(e) { if(ASI_Internal) alert('visi: ' + e.description + ' for ' + nr);
				return false; }
		finally { }
		}
	return false;
	}

function style_get(objId,where) {
	if (document.layers) {
		return eval("document.layers['" + objId + "']." + where);
	} else if (document.all) {
		return eval("document.all['" + objId + "'].style." + where);
	} else if (document.getElementById) {
			try { return eval("document.getElementById('" + objId + "').style." + where); }
			catch(e) { alert("Error setting " + objId);}
			}
		return '';
	}

function style_set(objId,where,what) {
	if (typeof objId=='object') {
		eval('objId.' + where + '=\'' + what + '\'');
	} else if (document.layers) {
		eval("document.layers['" + objId + "']." + where + "='" + what + "';");
	} else if (document.all) {
		try {	var tmp = "document.all['" + objId + "'].style." + where + '="' + what + '";';
				eval(tmp);
				}
			catch(e) {  }
	} else if (document.getElementById) {
		try { eval("document.getElementById('" + objId + "').style." + where + "='" + what + "';"); }
		catch(e) { alert("Error setting " + id);}
		}
	}
function objPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
			}
		}
	return [curleft,curtop];
	}
function say_pos(obj,typ,xOffset,yOffset) {
	var pos = objPos(obj);
	var show = document.getElementById(typ);
	show.style.left = pos[0] + xOffset;
	show.style.top = pos[1] + yOffset;
	visI(typ,'show');
	}

function popOver(obj,typ,xoff,yoff) {
	var pos = objPos(obj);
	var show = document.getElementById(typ)
	show.style.left = pos[0] + xoff;
	show.style.top = pos[1] + yoff;
	visI(typ,'show');
	}

var backwas;
function inRow(row) {
	getElement('id_' + row).style.backgroundColor = '#e0e0f0';
	if(getElement('a_' + row)) { getElement('a_' + row).style.fontWeight = 'bold' };
	}
function outRow(row) {
	getElement('id_' + row).style.backgroundColor = '#F0F0F0';
	if(getElement('a_' + row)) { getElement('a_' + row).style.fontWeight = 'normal' };
	}
function inRowX(row) {
	backwas = getElement('id_' + row).style.backgroundColor;
	getElement('id_' + row).style.backgroundColor = '#E0E0F0';
	if(getElement('a_' + row)) getElement('a_' + row).style.fontWeight = 'bold';
	}
function outRowX(row) {
	getElement('id_' + row).style.backgroundColor = '#F0F0F0';
	if(getElement('a_' + row)) getElement('a_' + row).style.fontWeight = 'normal';
	}

var tu = new Date();
var unique_num = Math.floor(tu.getTime()/1000);	// unique number to prevent stupid IE from cacheing AJAX calls

function msg_over(key) {	// get message from article database table 
	if(!getElement('show_msg')) {
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id','show_msg');
		newdiv.style.zIndex = 100;
		newdiv.style.visibility = 'hidden';
		newdiv.style.width = 300;
		newdiv.style.position = 'absolute';
		newdiv.style.left = 200;
		newdiv.style.top = 200;
		newdiv.style.backgroundColor = 'beige';
		newdiv.style.borderStyle = 'double';
		newdiv.style.padding = 5;
		document.body.appendChild(newdiv);
		}
	if (window.XMLHttpRequest) 		// Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject) { // IE
		try { page_request = new ActiveXObject("Msxml2.XMLHTTP") }
		catch (e) {
			try { page_request = new ActiveXObject("Microsoft.XMLHTTP") }
			catch (e) { return true; // go back and SUBMIT
							}
			}
		}
	else
		return true;	// use normal link 

	document.body.style.cursor = "wait";
	var url = window.location;
	page_request.onreadystatechange = function() { show_msg_now(page_request); }
	page_request.open('GET', url.protocol + '//www.ecomfrontier.com/asi/getmsg.asp?aj=1&key=' + key + '&unq=' + (++unique_num), true);
	page_request.send(null);
	return false;	// Don't trigger normal link 
	}

function msg_over2(key,title) {	// get message from article database table
	img_reset();
	if(!getElement('show_msg')) {	// create one
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id','show_msg');
		newdiv.style.zIndex = 100;
		newdiv.style.visibility = 'hidden';
		newdiv.style.width = 300;
		newdiv.style.position = 'absolute';
		newdiv.style.left = 200;
		newdiv.style.top = 200;
		newdiv.style.backgroundColor = '#f5f5dc';	// beige
		newdiv.style.borderStyle = 'double';
		newdiv.style.padding = 5;
		document.body.appendChild(newdiv);
		}

	var tmp = new String(key);
	if(tmp.search(/.gif/)!=-1||tmp.search(/.jpg/)!=-1) {	// image=width
		getElement('show_msg').innerHTML = ((title!='')?'<b>' + title + '<\/b><br>':'') + '<img name="show_img" src="https://www.asi-ez.com/' + key + '" alt="' + title
									+ '"><div id="msg_close" style="float: right; color: #ff0000; cursor: pointer;" onclick="div_vis(\'show_msg\',\'hide\');"><b>Close<\/b><\/div>';
		style_set('show_msg','width',(document.images['show_img'].width + 5) + 'px');
		style_set('show_msg','height',(document.images['show_img'].height + ((title=='')?30:50) + 'px'));
		div_vis('show_msg','show');
		getElement('msg_close').focus();
		msg_close.scrollIntoView(false);	// bottom
		return false;
		}

	if (window.XMLHttpRequest) 		// Mozilla, Safari etc
		page_request = new XMLHttpRequest();
	else if (window.ActiveXObject) { // IE
		try { page_request = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) {
			try { page_request = new ActiveXObject("Microsoft.XMLHTTP") }
			catch (e) { return true; // go back and SUBMIT
							}
			}
		}
	else
		return true;	// use normal link

	document.body.style.cursor = "wait";
	page_request.onreadystatechange = function() { show_msg_now(page_request); }
	page_request.open('GET',document.location.protocol + '//www.ecomfrontier.com/asi/getmsg.asp?aj=1&key=' + key + '&unq=' + (++unique_num), true);
	page_request.send(null);
	return false;	// Bypass normal link
	}

function show_msg_now1(page_request) {
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) {
		var response = new String(page_request.responseText);
		getElement('show_msg').innerHTML = response + '<span id="msg_close" style="float: right; color: #ff0000; font-weight: bold; cursor: pointer;" onclick="div_vis(\'show_msg\',\'hide\');">Close</span>';
		style_set('show_msg','width',getElement('msg_article').style.width) + 5 + 'px';
		div_vis('show_msg','show');
		document.body.style.cursor = "default";
		getElement('msg_close').scrollIntoView(false);
		}
	}
function show_msg_now(page_request) {
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) {
		var response = new String(page_request.responseText);
		getElement('show_msg').innerHTML = response + '<span id="msg_close" onclick="getElement(\'show_msg\').innerHTML=\'\';visI(\'show_msg\',\'hide\');" style="float:right;color:red;font-weight:bold;cursor:pointer;">Close</span>';
		getElement('msg_close').innerHTML =  'Close<!--' + getElement('show_msg').clientWidth + '-->';
		var w = new String(style_get('msg_article','width'));
		var w1 = parseInt(w.substr(0,w.length-2)) + 5;
		visI('show_msg','show');
		style_set('show_msg','width',w1);
		var idx = response.indexOf('background-color:');
		style_set('show_msg','backgroundColor',(idx>1&&idx<response.indexOf('>'))?response.substr(idx+17,7):'#f5f5dc');
		document.body.style.cursor = "default";
		msg_close.scrollIntoView(false);
		}
	}

function i_flip() {	// followed by any number of ids and text strings to set 
	var val;
	for(var i=0;i<arguments.length;i++,i++) {
		val = new String(arguments[i+1]);
		if(val.indexOf('.jpg')!=-1||val.indexOf('.gif')!=-1) {
			var url = 'https://www.asi-ez.com/pix/illustrations/' + val;
			getElement(arguments[i]).src = url }
		else { getElement(arguments[i]).innerHTML = val;
			}
		}
	}

function img_reset() {
	if(getElement('img_note')) {
		visI('img_note','hide');
		sizer('img','img_little');
		getElement('img_id').src = img_name;
		}
	}

