function center(id){
	return (height()/2)-($j("#"+id).height()/2);
}

function height() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    // Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
    // IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && (document.body.clientHeight ) ) {
    // IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function width() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    // Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth ) ) {
    // IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && (document.body.clientWidth ) ) {
    // IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function IsNumeric(input)
{
   return (input - 0) == input && input.length > 0;
}

function exists(id){
	return ( $j("#"+id).length > 0 );
}

var xob = false;
function inComparePopUp(){
	if(xob){
		return false;
	}
	xob=true;

	if(window.opener != null){
		var lo = window.location;
		var splitted = lo.toString().split("/");
		var i =0;
		while( i < splitted.length ){
			if(splitted[i] == 'product_compare'){
				return true;
			}
			i++;
		}
	}
	return false;
}


function extractId(url){
	t = url.split('/');
	next = false;
	
	for (i in t){
		if(next){
			return t[i];
		}
		if(t[i]== 'item'){
			next = true;
		}
	}
}


function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function refresh_toplink(n){
      aoscksaovnjwjen = $j("a.top-link-cart")[0];
      if(n == 0){
             aoscksaovnjwjen.update('My Cart');
      }else if (n == 1){
             aoscksaovnjwjen.update('My Cart (1 item)');
      }else{
             aoscksaovnjwjen.update('My Cart ('+n+' items)');
      }
}

