/* ---------- ---------- ---------- ---------- */

//initUserEnv
function initUserEnv(){
	this.isWin		= navigator.userAgent.indexOf("Win") != -1 ? true : false;
	this.isMac		= navigator.userAgent.indexOf("Mac") != -1 ? true : false;
	this.isNs		= navigator.appName.indexOf("Netscape") != -1 ? true : false;
	this.isNs4		= (document.layers) ? true : false;
	this.isNs4_7	= navigator.userAgent.indexOf("4.7") != -1 ? true : false;
	this.isNs6		= navigator.userAgent.indexOf("Netscape6") != -1 ? true : false;
	this.isNs7		= navigator.userAgent.indexOf("Netscape/7") != -1 ? true : false;
	this.isMoz		= navigator.userAgent.indexOf("Gecko") != -1 ? true : false;
	this.isIe		= navigator.userAgent.indexOf("MSIE") != -1 ? true : false;
	this.isIe4		= navigator.userAgent.indexOf("MSIE 4") != -1 ? true : false;
	this.isIe5		= navigator.userAgent.indexOf("MSIE 5") != -1 ? true : false;
	this.isIe6		= navigator.userAgent.indexOf("MSIE 6") != -1 ? true : false;
	this.isOp		= navigator.userAgent.indexOf("Opera") != -1 ? true : false;
	this.isW3CDom	= (document.getElementById) ? true : false;
	this.isMsDom	= (document.all) ? true : false;
	this.isNsDom	= (document.layers) ? true : false;
	this.isDom		= (this.isW3CDom || this.isMsDom || this.isNsDom) ? true : false;
	return this;
}
var userEnv = new initUserEnv();


//checkBlowser
function checkBlowser(){
	return (userEnv.isW3CDom)? 1:0;
}


//pritnCssLink
var cssPath ="css/";
function printCssLink(){
	var cssFileName = "default"
	cssFileName = ((userEnv.isWin) ?  "win" : "mac") +"_"+ ((userEnv.isIe) ?   "ie" :  "ns") ;
	document.write ('<link rel="stylesheet" type="text/css" href="' + cssPath + cssFileName + '.css">');
}
//printCssLink();


//getFlashPlayerVersion
function getFlashPlayerVersion(){
	var flashVersion = 0;
	if (userEnv.isIe && userEnv.isWin) {
		var flashVersion = new ActiveXObject ("ShockwaveFlash.ShockwaveFlash").FlashVersion ();
		flashVersion = Math.floor (flashVersion / 0x10000);
	} else {
		if (userEnv.isNs && !navigator.plugins) {
			flashVersion = 0;
		} else {
			var s = "application/x-shockwave-flash";
			if (navigator.mimeTypes && navigator.mimeTypes[s] && navigator.mimeTypes[s].enabledPlugin) {
				flashVersion=navigator.plugins["Shockwave Flash"].description.match (/\d+/);
			} else {
				flashVersion = 0;
			}
		}
	}
	return flashVersion;
}


//printUserEnvironment
function printUserEnvironment(){
	var html ="";
	html += '<table><tr valign="top"><td>';
		html += '<table class=dataTable>';
		for(i in navigator){
			html += '	<tr>';
			html += '		<td bgcolor="#e5e5e5">'+i+'<br></td>';
			html += '		<td>'+navigator[i]+ '<br></td>';
			html += '	</tr>';
		}
		html += '</table>';
		html += '</td><td>';
		html += '<table class=dataTable>';
		for(i in userEnv){
			html += '	<tr>';
			html += '		<td ' + ((userEnv[i]) ? "bgcolor=#e5e5e5": "bgcolor=#ffffff") + '>'+i+'<br></td>';
			html += '	</tr>';
		}
		html += '</table>';
	html += '</td></tr></table>';
	document.write(html);
}

//openSubWindow
function openSubWindow(url,name,width,height,misc,centering) {
	var details;
	details = "width="+ width +",height=" + height +",";
	details += "toolbar="+ misc.charAt(0) +",location="+ misc.charAt(1) +",status="+ misc.charAt(2);
	details += ",menubar="+ misc.charAt(4) +",scrollbars="+misc.charAt(5) +",resizable="+misc.charAt(6)+"";
	if (centering =="center") {
		var posX = (screen.width / 2) - (width / 2);
		var posY = (screen.height / 2) - (height / 2);
		details += ",left=" + posX + ",top=" + posY + ",screenX=" + posX + ",screenY=" + posY;
	}
	window.open(url,name,details);
}



//cookie
function checkEnabledCookie(){
	return (document.cookie) ? 1:0;
}
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}



//swapImage
function MM_preloadImages() {
	var d = document;
	if (d.images) {
		if (!d.MM_p) {
			d.MM_p = new Array();
		}
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
		for (i=0; i<a.length; i++) {
			if (a[i].indexOf("#") != 0) {
				d.MM_p[j] = new Image();
				d.MM_p[j++].src = a[i];
			}
		}
	}
}
function MM_swapImage() {
	var i, j = 0, x, a = MM_swapImage.arguments;
	document.MM_sr = new Array();
	for (i=0; i<(a.length-2); i += 3) {
		if ((x=MM_findObj(a[i])) != null) {
			document.MM_sr[j++] = x;
			if (!x.oSrc) {
				x.oSrc = x.src;
			}
			x.src = a[i+2];
		}
	}
}
function MM_swapImgRestore() {
	var i, x, a = document.MM_sr;
	for (i=0; a && i<a.length && (x=a[i]) && x.oSrc; i++) {
		x.src = x.oSrc;
	}
}
function MM_findObj(n, d) {
	var p, i, x;
	if (!d) {
		d = document;
	}
	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0, p);
	}
	if (!(x=d[n]) && d.all) {
		x = d.all[n];
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x = d.forms[i][n];
	}
	for (i=0; !x && d.layers && i<d.layers.length; i++) {
		x = MM_findObj(n, d.layers[i].document);
	}
	if (!x && d.getElementById) {
		x = d.getElementById(n);
	}
	return x;
}

