function popUp (url, width, height) {			
	//center the pop-up	
	if (parseInt(navigator.appVersion) >= 4 ) {
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;}

	args = "width=" + width + ","
	+ "height=" + height + ","
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=1,"
	+ "scrollbars=1,"
	+ "status=no," 
	+ "titlebar=1,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "screenx=" + xposition + ","  //NN Only
	+ "screeny=" + yposition + ","  //NN Only
	+ "left=" + xposition + ","     //IE Only
	+ "top=" + yposition;           //IE Only
		
	var mynewpop = window.open(url,'myfile',args);
	mynewpop.focus();
}

function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1) 
      return element;

    elements.push(element);
  }

  return elements;
}

function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function toggleRoy(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function doAjax (url, pars, outputdiv, meth) {	
	pars = pars + '&nocache=' + Math.random();
	var myAjax = new Ajax.Updater(outputdiv, url, {method: meth, parameters: pars, evalScripts: true});		
}

function genPassword() {

	var useChars = "0123456789abcdefghijklmABCDEFGHIJKLMnopqrstuvwxyzNOPQRSTUVWYXZ";	
	var password = "";
	
	for (var j = 1; j <= 6; j++) {
		password += useChars.charAt(Math.floor(Math.random() * (useChars.length - 0)) + 0);
	}
	
	$('password').value = password;	
	
}

function blindit(nav) {

	var menu = new Array("nb_articles", "nb_videos", "nb_museum");
	
	for (var j = 0; j <= menu.length - 1; j++) {
		if (menu[j] != nav)
			$blindup(menu[j]);	
	}
		
	$blinddown(nav);	
}

function searchCheck() {
	
	$('searchSF').style.color = "#CCCCCC";
	
	if ($('searchSF').value == "search sneaker freaker") {
		$('searchSF').value = '';
	}
	
	if ($('searchSF').value == "") {
		return false;	
	}
	
	return true;

}

function frkn_nav(x, colorit) {

	var bah = $('nav_upto').value;	
	$('frkn_nav_' + x).style.color = colorit;

	if (bah != "") {
		$('nav_' + bah).style.display = 'none';	
		$('frkn_nav_' + bah).style.color = '#FFFFFF';	
	} 
		
	$('frkn_nav').style.display = 'none';
	$('frkn_nav').style.display = 'block';	
	
	$('nav_' + x).style.display = 'block';
	$('nav_upto').value = x;

}

function changeDisplay(ele, attr) {
	$(ele).style.display = attr;	
}

function getWindowHeight() {

	if (typeof(window.innerHeight)=='number')
		return window.innerHeight;
	
	if (document.documentElement && document.documentElement.clientHeight)
		return document.documentElement.clientHeight;
		
	if (document.body && document.body.clientHeight)
		return document.body.clientHeight;
		
	return 0;

}

function setFooter() {

	if (!document.getElementById)
		return false;

	var windowHeight = getWindowHeight();
	var contentHeight = document.getElementById('container').offsetHeight;
	
	var footerElement = document.getElementById('footer');
	//var footerHeight = footerElement.offsetHeight;
	var footerHeight = 35;

	if (windowHeight - (contentHeight + footerHeight) >= 0) {

		if(navigator.appName == "Microsoft Internet Explorer") {
			
			footerElement.style.position = 'relative';
			footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
			
		} else {

			footerElement.style.position = 'absolute';
			footerElement.style.bottom = '0px';
		
		}

	}
	footerElement.style.display = '';

}

function subsOrder(order) {
	
	for (var i = 1; i <= 4; i++) {
		$('order' + i).style.background = '#FFFFFF';
	}

	$('order' + order).style.background = '#87cfb7';
	$('selection').value = order;
		
}


function lengthen() {

	if (!document.getElementById)
		return false;
		
	if(!document.getElementById('lengthenMe'))
		return false;
		
	lengthMe = document.getElementById('lengthenMe');	
	var contentHeight = document.getElementById('container').offsetHeight - 200;	
	lengthMe.style.height = contentHeight + 'px';

}

function showVTotal(x) {
	
	var totalProducts = $('totalCartItems').value;
	var t = 0;
	
	if ($('Item_quantity_' + x).value > 0) { 
		$('orderbox' + x).style.background = '#ddf1e2'; 
	} else { 
		$('orderbox' + x).style.background = '#F3F3F3'; 
	}	
	
	for (var i = 1; i <= totalProducts; i++) {
		t = t + ($('Item_quantity_' + i).value * 1);
	}
	
	if (t < 40) {
		$('total_order').innerHTML = t + " Magazines.<br />" + (40 - t) + " more needed.";	
		$('wholesale_form').style.display = 'none';
	} else if (t > 100) {
		$('total_order').innerHTML = t + " Magazines. " + Math.abs(100 - t) + ' over the limit.<br />For orders over 100 copies, please email <a href="mailto: woody@sneakerfreaker.com?subject=Wholesale Order over 100">woody@sneakerfreaker.com</a>';
		$('wholesale_form').style.display = 'none';
	} else {
		$('total_order').innerHTML = t + " Magazines";	
		$('wholesale_form').style.display = 'block';
	}
}
	
	
function listPosts(list, id, output) {
	
	if ($(output).style.display == 'none') {
		$(output).style.display = 'block';
		var url = "functions.frknblog.php";
		var pars = "f=frknlist&list=" + list + "&id=" + id;
		var target = output;
		
		$(output).innerHTML = '<span style="color: #FFFFFF;">&nbsp;&nbsp;loading ...</span>';
		
		var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars});			
		
	}	else {
		$(output).style.display = 'none';
	}

}
	
