/*
* Filename	: common.js
* Function	:
* Comment		:
* History		: 2003/05/09, jerry, setup
*						
* Version		:	1.0
* Author		:	Copyright (c) 2005 by JcomTech Corp. All Rights Reserved.
*/

var IE = document.all;
var NS4 = document.layers;
var NS6 = !IE && document.getElementById != null ? true : false;
var doc = (IE ? document.all : document);

/* open window */
function __openWindow(url, popupName, scrollFlag, resizeFlag, width, height, left, top) {
	popupName = popupName == null ? "popup" : popupName;
	scrollFlag = scrollFlag == null ? "no" : scrollFlag;
	resizeFlag = resizeFlag == null ? "no" : resizeFlag;
	width = width == null ? 300 : width;
	height = height == null ? 300 : height;
	left = left == null ? 50 : left;
	top = top == null ? 50 : top;
	
	window.open(url, popupName, "scrollbars=" + scrollFlag + ", resizable=" + resizeFlag + ", width=" + width + ", height=" + height + ", left=" + left + ", top=" + top);
}

function openWindow(url, width, height, popupName) {
	__openWindow(url, popupName, "no", "yes", width, height);
}

function openWindowFixed(url, width, height, popupName) {
	__openWindow(url, popupName, "no", "no", width, height);
}

function openWindowScroll(url, width, height, popupName) {
	__openWindow(url, popupName, "yes", "yes", width, height);
}

function openWindowPos(url, width, height, popupName, left, top) {
	__openWindow(url, popupName, "no", "yes", width, height, left, top);
}

function openWindowFixedPos(url, width, height, popupName, left, top) {
	__openWindow(url, popupName, "no", "no", width, height, left, top);
}

function openWindowScrollPos(url, width, height, popupName, left, top) {
	__openWindow(url, popupName, "yes", "yes", width, height, left, top);
}

/* get IE version */
function getIEVersion() {
	var IEVersion = 0;
//var browserName = navigator.appName;
	var idx = navigator.appVersion.indexOf("MSIE");

	if (idx > -1) {	IEVersion = parseFloat(navigator.appVersion.substr(idx + 4)); }

	return IEVersion;
}

/* get object */
function getObjectByName(objName) {
	var obj = null;
	if (IE) {obj = document.all[objName];}
	else {obj = document.getElementById(objName);}
	return obj;
}

/* make array SET(eliminate duplication) */
function makeSet(array){
	var arrayLength = array.length;
	var ary = new Array();
	var size = 0;
	ary[0] = array[0];
	var unique = true;
	for(i=0;i<arrayLength;i++){
		unique = true;
		size = ary.length;
		for(j=0;j<size;j++){
			if(array[i]==ary[j]){
				unique = false;
				break;
			}
		}
		if(unique){
			ary[size] = array[i];
		}
	}
	return ary;
}

/* Merge two Array (concatenate two array)*/
function mergeArray(iArray, jArray){
	var iSize = iArray.length;
	var jSize = jArray.length;
	var mArray = new Array();
	var mSize = 0;
	var unique = true;
	
	mArray[0] = iArray[0];
	for(i=0;i<iSize;i++){
		mSize = mArray.length;
		mArray[mSize] = iArray[i];
	}
	
	for(j=0;j<jSize;j++){
		mSize = mArray.length;
		mArray[mSize] = jArray[j];
	}
	var nArray = makeSet(mArray);
	
	return nArray;
}

/* Array to String with seperator */
function arrayToString(array, sep){
	var size = array.length;
	var str = "";
	for(i=0;i<size;i++){
		if(array[i].length > 0){
			str = str+array[i]+sep;
		}
	}
	return str;
}

/* We need sort Array */

/* main image s rollover */
function MM_swapImgRestore() { //v3.0
  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_preloadImages() { //v3.0
  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_findObj(n, d) { //v4.01
  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;
}

function MM_swapImage() { //v3.0
  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];}
}
/* main image e rollover */



/* main_r image s rollover */
function MM_swapImgRestore() { //v3.0
  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_preloadImages() { //v3.0
  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_findObj(n, d) { //v4.01
  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;
}

function MM_swapImage() { //v3.0
  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];}
}
/* main_r image e rollover */


