function Querystring(frame)
{
// get the query string, ignore the ? at the front.
	var querystring=frame.location.search.substring(1,location.search.length);

// parse out name/value pairs separated via &
	var args = querystring.split('&');

// split out each name = value pair
	var posEqualSign = 0;
	for (var i=0;i<args.length;i++)
	{
		posEqualSign = args[i].indexOf('=');
		var pair = new Array(2);
		pair[0] = args[i].substring(0,posEqualSign);
		pair[1] = args[i].substring(posEqualSign+1, args[i].length);

		// Fix broken unescaping
		temp = unescape(pair[0]).split('+');
		name = temp.join(' ');

		temp = unescape(pair[1]).split('+');
		value = temp.join(' ');

		this[name]=value;
	}

	this.get=Querystring_get;
}


function Querystring_get(strKey,strDefault)
{
	var value=this[strKey];
	if (value==null)
	{
		value=strDefault;
	}

	return value;
}

function getFriendlyURL()
{
	var qs; var end; var prefix; var rest; var loc;
	var frame = frames['catcontent'];
	//alert("frame: " + frame);
	
	if (frame) {
		qs = new Querystring(frame);
		loc = frame.location;
	}
	else {
		qs = new Querystring(window);
		loc = location;
	}
	//alert("qs: " + qs);
	
	end = loc.pathname.indexOf("/");
	//alert(end);
	prefix = loc.pathname.substring(0, end + 1);
	//alert(prefix);
	rest = loc.pathname.substring(end + 1, loc.pathname.length);
	//alert(rest);
	for (var i = 0; i < 2; i++) {
		end = rest.indexOf("/");
		//alert(end);
		prefix += rest.substring(0, end + 1);
		//alert(prefix);
		rest = rest.substring(end + 1, rest.length);
		//alert(rest);
	}
	prefix = prefix.substring(0, prefix.length - 1);
	//alert(prefix);
	
	var path = loc.pathname.replace(prefix, '')
		+ loc.search.replace('&BV_UseBVCookie=yes', '')
			.replace('BV_UseBVCookie=yes&', '')
			.replace('&BD_SID='+qs.get('BD_SID',''),'');
			
	path = 'path=' + escape(path.replace('frameless/catalog/catalogNodeAction.bd?', 'catalog/catalogview.bd?action=catalogNodeAction&')
			.replace('frameless/catalog/catalogDetail.bd?', 'catalog/catalogview.bd?action=catalogDetail&'));		
	
	var url = prefix + '/bdweb/eservices/contextselect.bd?' + path + '&BV_UseBVCookie=yes&BD_SID=' + qs.get('BD_SID','');
	//alert("url: " + url);
	return url;
}

function echeck(str) {
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==1 || str.indexOf(at)==lstr){
	   return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false;
	}
	if (str.indexOf(at,(lat+1))!=-1){
		return false;
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false;
	}
	if (str.indexOf(dot,(lat+2))==-1){
		return false;
	}
	if (str.indexOf(" ")!=-1){
		return false;
	}
	return true;	
}

isLoaded = 0;

function rolloverbg(cellId,bgc) {
	cellId1 = cellId + "a";
	cellId2 = cellId + "b";
	if (document.getElementById) {
		document.getElementById(cellId1).style.background = bgc;
		document.getElementById(cellId2).style.background = bgc;
	} else if (document.all) {
		eval(cellId1).style.background = bgc;
		eval(cellId2).style.background = bgc;
	}
}

function printPage() {
	window.print();
}

function reDo(){ window.location.reload() }

function fullScreenPopup(url, windowName) {
	var my_popup = window.open(url,windowName,'location=no,toolbar=no,directories=no,menubar=no,resizable=yes,scrollbars=no,status=no,width=800,height=600,screenY=0,screenX=0');
	my_popup.moveTo(0,0);
	my_popup.resizeTo(screen.availWidth, screen.availHeight);
}