﻿var ie = document.all;
var ns4 = document.layers;
var ns6 = document.getElementById;												
var tabz = (ie)?"document.all":(ns4)?"document":"document";

function OpenNewWindow(TheURL,wWidth,wHeight) { 
	//aURL=TheURL
	//alert(wTop + " : " + wLeft)
	var pattern = /\|/;
	var tempTop = '';
	var tempLeft = '';
	var wTop= 10;
	var wLeft= 10;
	if(wWidth.toString().search(pattern) > 0) {
		tempTop = wWidth.split('|');
		wLeft = tempTop[1].toString();
		wWidth = tempTop[0].toString();
	} 
	if(wHeight.toString().search(pattern) > 0) {
		tempLeft = wHeight.split('|');
		wTop = tempLeft[1].toString();
		wHeight = tempLeft[0].toString();
	} 
	aCondition='toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + wWidth + ',height=' + wHeight +', left=' + wLeft + ' top=' +wTop
	var rand = Math.ceil(Math.random() * 10000);
	var str = rand.toString(10);
	window.open (TheURL, "a" + str, aCondition);
}

function replace(string,text,by) {
		var strLength = string.length, txtLength = text.length;
		if ((strLength == 0) || (txtLength == 0)) return string;
		var i = string.indexOf(text);
		if ((!i) && (text != string.substring(0,txtLength))) return string;
		if (i == -1) return string;
		var newstr = string.substring(0,i) + by;
		if (i+txtLength < strLength)
			newstr += replace(string.substring(i+txtLength,strLength),text,by);
		return newstr;
}

function LogIn() { 
	var tempUrl = location.href
	tempUrl = replace(tempUrl,'&','|')
	OpenNewWindow('/login/index.asp?purl=\'' + tempUrl +'\'',450,400)
}

function CheckOut(){
	eval(tabz + ".frmCheckOut.cmd.value='checkout'")
	eval(tabz + ".frmCheckOut.target='_top'")
	eval(tabz + ".frmCheckOut.submit()")	
}
