openWin = function(url,name,width,height,xpos,ypos,chrome,scroll) {
	var x, y, w, h, moveX=0, moveY=0, features="";
	chrome = chrome ? "yes" : "no";
	scroll = scroll ? "yes" : "no";
	features += "toolbar="+chrome+",location="+chrome+",status="+chrome+",menubar="+chrome;
	features += ",scrollbars="+scroll+",resizable="+scroll;
	if(width) features += ",width="+width;
	if(height) features += ",height="+height;
	if(xpos && window.screen){
		w = window.screen.availWidth;
		width = parseInt(width);
		switch(xpos){
			case "left": x = 0; break;
			case "center": x = (w-width)/2; break;
			case "right": x = w-width; break;
			default: x = xpos;
			}
		features += ",screenX="+x+",left="+x;
		var moveX = x;
		}
	if(ypos && window.screen){
		h = window.screen.availHeight;
		height = parseInt(height);
		switch(ypos){
			case "top": y = 0; break;
			case "middle": y = (h-height)/2; break;
			case "bottom": y = h-height; break;
			default: y = ypos;
			}
		features += ",screenY="+y+",top="+y;
		var moveY = y;
		}
	openWinReference = window.open(url,name,features);
	if(moveX || moveY){
		// position the window for browsers that don't recognize screenX, screenY
		openWinReference.moveTo(moveX,moveY);
		}
	}

openScroll = function(url,name,width,height){
	openWin(url,name,width,height,false,false,false,"scroll");
	}

openCenter = function(url,name,width,height){
	openWin(url,name,width,height,"center","middle");
	}

openCenterScroll = function(url,name,width,height){
	openWin(url,name,width,height,"center","middle",false,"scroll");
	}

openFull = function(url,name){
	openWin(url,name,false,false,false,false,"chrome","scroll");
	}

function view_flash(name, width, height) {
	
	if (!cookie_value('redknee_user_id')) {
		
		url = 'http://www.redknee.com/account/login?next_action=' + URLEncode(window.location.pathname);
		window.location = url;
		
		return false;
	}
	
	filename = '/_media/flash/' + name + '.php';
	
	openWin(filename, 'blank', '760', '455');
	
	return false;
	
}

function view_video(name, width, height) {
	
	filename = '/_media/video/' + name + '.php';
	
	openWin(filename, 'blank', '450', '325');
	
	return false;
	
}

function URLEncode(sStr) {
    return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F');
}

function cookie_value(key) {
	
	if (key == '') {
		return null;	
	}
	
	cookies = cookie_values();
	num_cookies = cookies.length;
	
	for(x = 0; x < num_cookies; x++) {
		parts = cookies[x].split('=');
		
		if (parts[0].indexOf(key) != -1) {
			return parts[1];	
		}
		
	}
	
	return null;
	
}

function cookie_values() {
	return document.cookie.split(';');	
	
}

function toggle_related_text() {
	
	curtext = document.getElementById("related_text").innerHTML;
	if(curtext == '- Hide Related Items') {
		document.getElementById("related_text").innerHTML = "+ Show Related Items";
	} else {
		document.getElementById("related_text").innerHTML = "- Hide Related Items";
	}
	
	
}


function showlayer() {
	document.getElementById('theLayer').style.visibility = "visible";
}

function hideMe() {
	document.getElementById('theLayer').style.visibility = "hidden";
}

// var timer = window.setTimeout("showlayer()",2500);