function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) {
		return null;
	}
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) +
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}


function openwin(pUrl, pName, pScroll, pWidth, pHeight, pLeft, pTop) {
	var opt = "width=" + pWidth + ", height=" + pHeight + ", scrollbars=" + pScroll + ", toolbars=no, status=no";
	if(pLeft != "") opt = opt + ", left=" + pLeft;
	if(pTop != "") opt = opt + ", top=" + pTop;

	newwin = window.open(pUrl, pName, opt);
	newwin.focus();
}

function myTrim(str) {
	str = str.replace(/\s/g,"");
	return str;
}

function isnum(NUM) {
	for(var i=0;i<NUM.length;i++) {
		achar = NUM.substring(i,i+1);
		if( achar < "0" || achar > "9" )
			return true;
	}
	return false;
}

/* 20060804-wmode add */
function setEmbed() {

  var obj = new String;
  var parameter = new String;
  var embed = new String;
  var html = new String;
  var allParameter = new String;
  var clsid = new String;
  var codebase = new String;
  var pluginspace = new String;
  var embedType = new String;
  var src = new String;
  var width = new String;
  var height = new String;

  this.init = function(getType, s, w, h, wm) {

      if( getType == "flash") {
        clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";
        codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
        pluginspage = "http://www.macromedia.com/go/getflashplayer";
        embedType = "application/x-shockwave-flash";
      }
      parameter += "<param name=\"movie\" value=\""+ s + "\">\n";
      parameter += "<param name=\"quality\" value=\"high\">\n";
      parameter += "<param name=\"wmode\" value=\"transparent\">\n";
      parameter += "<param name=\"menu\" value=\"false\">\n";

      src = s;
      width = w;
      height = h;
  }

  this.parameter = function(parm, value) {
      parameter += "<param name=\"" + parm + "\" value=\"" + value + "\">\n";
      allParameter += " " + parm + "=\"" + value + "\"";
  }

  this.show = function() {
      if( clsid ) {
        obj = "<object classid=\"clsid:" + clsid + "\" codebase=\"" + codebase + "\" width=\"" + width + "\" height=\"" + height + "\">\n";
      }
      embed = "<embed src=\"" + src + "\" pluginspage=\"" + pluginspage + "\" type=\"" + embedType + "\" width=\"" + width + "\" height=\"" + height + "\"" + allParameter + "></embed>\n";

      if ( obj ) {
        embed += "</object>\n";
      }

      html = obj + parameter + embed;
      document.write( html );
  }
}

function ExecutionTime() {
    this.start_time = 0;
    this.start = function() { this.start_time = (new Date()).getTime(); }
    this.from_start = function() { var curr_time = (new Date()).getTime(); return ( curr_time - this.start_time ) / 1000; }
}


function Main_setEmbed() {

  var obj = new String;
  var parameter = new String;
  var embed = new String;
  var html = new String;
  var allParameter = new String;
  var clsid = new String;
  var codebase = new String;
  var pluginspace = new String;
  var embedType = new String;
  var src = new String;
  var width = new String;
  var height = new String;

  this.init = function(getType, s, w, h, wm) {

      if( getType == "flash") {
        clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";
        codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
        pluginspage = "http://www.macromedia.com/go/getflashplayer";
        embedType = "application/x-shockwave-flash";
      }
      parameter += "<param name=\"movie\" value=\""+ s + "\">\n";
      parameter += "<param name=\"quality\" value=\"high\">\n";
      parameter += "<param name=\"wmode\" value=\"transparent\">\n";
      parameter += "<param name=\"menu\" value=\"false\">\n";

	  src = s;
      width = w;
      height = h;
  }

  this.parameter = function(parm, value) {
      parameter += "<param name=\"" + parm + "\" value=\"" + value + "\">\n";
      allParameter += " " + parm + "=\"" + value + "\"";
  }

  this.show = function() {
      if( clsid ) {
        obj = "<object classid=\"clsid:" + clsid + "\" codebase=\"" + codebase + "\" width=\"" + width + "\" height=\"" + height + "\">\n";
      }
      embed = "<embed src=\"" + src + "\" pluginspage=\"" + pluginspage + "\" type=\"" + embedType + "\" width=\"" + width + "\" height=\"" + height + "\"" + allParameter + "></embed>\n";

      if ( obj ) {
        embed += "</object>\n";
      }

      html = obj + parameter + embed;
			document.all.flash_chart.innerHTML = html
  }
}

// List Sort
function Sortedby(pQuery) {
	location.href = './?sort=' + pQuery;
}

// iframe resize
function resizeIfr(obj, minHeight) {

	minHeight = minHeight || 150;

	try {
		var doc = obj.contentDocument || obj.contentWindow.document;
		if(doc.location.href == 'about:blank') {
			obj.style.height = '0px';
			return;
		}

		if(/MSIE/.test(navigator.userAgent)) {
			var s = doc.body.appendChild(document.createElement('DIV'))
			s.style.clear = 'both';
			var h = s.offsetTop;
			s.parentNode.removeChild(s);
		} else {
			var s = doc.body.appendChild(document.createElement('DIV'))
			s.style.clear = 'both';
			var h = s.offsetTop;
			s.parentNode.removeChild(s);
		}

		if(h < minHeight) h = minHeight;

		obj.style.height = h + 'px';
		if(typeof resizeIfr.check == 'undefined') resizeIfr.check = 0;
		if(typeof obj._check == 'undefined') obj._check = 0;

		doc.document.scrollTo(1,1);

	} catch (e) {
	}
}
