var unloadFlag=0;
var IMGPATH		= '/';
var form='';
var php_bgPicture   = "orangebg.gif";   
var php_arrow       = "icon_menu_dot2.gif";
var php_bgColor     = "#0099ff";
var objX = 0;
var objY = 0;

var layer=new Array();
var dragObj=new Array();
var dragObjId=new Array();

var layer1;


//var bdMvEvt= document.body.onmousemove;
//var bdUpEvt= document.body.onmouseup;
//
//function recoverBodyEvent() {
//	document.body.onmousemove = bdMvEvt;
//	document.body.onmouseup = bdUpEvt;
//}

var bodyScrollWidth=0;
var bodyScrollHeight=0;
function reCalBodySize(){
	bodyScrollWidth=window.screen.availWidth;
	bodyScrollHeight=window.screen.availHeight;
//	bodyScrollHeight=document.body.scrollHeight;
}
reCalBodySize();

if(navigator.appName.indexOf("Explorer") > -1){//ie
	var exp=1;
} 
else{//for ff
	var exp=2;
}


function checkAndResetStyleTop (obj) {
	var clientHeight=obj.firstChild.clientHeight;
	var styleTop=parseInt(obj.style.top.substring(0,obj.style.top.length-2));
	if ( clientHeight+styleTop>bodyScrollHeight ) {
		obj.style.top=(bodyScrollHeight- clientHeight)+'px';
	}
}


function set_div_style(obj,id,top,left,width,height,position,border,cursor,background) {
        var obj = obj;
        obj.id = id?id:null;
        obj.style.top = top?top:'0px';
        obj.style.left = left?left:'0px';
        obj.style.width = width?width:'0px';
        obj.style.height = height?height:'0px';
        obj.style.position = position?position:"static";
        obj.style.border = border?border:"1px #000 solid";
        obj.style.cursor = cursor?cursor:"default";
        obj.style.background = background?background:"";
        return obj
}

function drag_mouse_down(event,obj){
	var obj_left = obj.style.left;
	var obj_top = obj.style.top;
	var obj_left = obj_left.replace(/p|x/g,"");
	var obj_top = obj_top.replace(/p|x/g,"");
	if ( event == null ) {//IE????
		event=window.event;
	}
	var clientX = String(event.clientX).replace(/p|x/g,"");
	var clientY = String(event.clientY).replace(/p|x/g,"");
	objX = clientX - obj_left;
	objY = clientY - obj_top;
}

function drag(event,obj){
	if( objX != 0 && objY != 0 ) {
		if ( event == null ) {//IE????
			event=window.event;
		}
		if ( event.button == 1 ||  event.button == 0 ){
			var objWidth=obj.firstChild.clientWidth;
			var objHeight=obj.firstChild.clientHeight;
			reCalBodySize();

			var leftPo= event.clientX-objX;
			if ( leftPo < 0 ) {
				leftPo=0;
			}
			if ( leftPo > bodyScrollWidth-objWidth ) {
				leftPo=bodyScrollWidth-objWidth;
			}

			var topPo=event.clientY-objY;
			if ( topPo < 0 ) {
				topPo=0;
			}
			if ( topPo > bodyScrollHeight-objHeight ) {
				topPo=bodyScrollHeight-objHeight;
			}
			obj.style.left=leftPo+'px';
			obj.style.top=topPo+'px';
		}
	}
}

function GetLength(strTemp){
	var i,sum;
	sum=0;
	for(i=0;i<strTemp.length;i++){
		if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255)) 
			sum = sum + 1;
		else 
			sum=sum + 2;
	}
	return sum;
}

function subStringPro(str, length){
	var stri = '';
	for(i=0,j=0; j<length;){
		if ((str.charCodeAt(i)>=0) && (str.charCodeAt(i)<=255)) {
			stri += str.charAt(i);
			j++;
		} else {
			stri += str.charAt(i);
			j += 2;
		}
		i++;
	}
	return stri;
}

function chgKt(no) {
	form.keywordtype.value=no;
	for ( var i=0;i<3;i++ ) {
		document.getElementById("kt"+i).className='kt_bg0';
	}
	document.getElementById("kt"+no).className='kt_bg';
}

//*********************

function HideElement(strElementTagName){
	try{
		for(i=0;i<window.document.all.tags(strElementTagName).length; i++){
			var objTemp = window.document.all.tags(strElementTagName)[i];
			objTemp.style.visibility = "hidden";
		}
	}catch(e){
		alert(e.message);
	}
}

// 
function ShowElement(strElementTagName){
	try{
		for(i=0;i<window.document.all.tags(strElementTagName).length; i++){
			var objTemp = window.document.all.tags(strElementTagName)[i];
			objTemp.style.visibility = "visible";
		}
	}catch(e){
		alert(e.message);
	}
}

function hideElementAll(){
	HideElement("SELECT");
	HideElement("OBJECT");
	HideElement("IFRAME");
}

function showElementAll(){
	ShowElement("SELECT");
	ShowElement("OBJECT");
	ShowElement("IFRAME");
}
//
function hide() {
	synSizeByBody("globalDiv");
	document.getElementById("globalDiv").style.display = "block";
	if ( 1 == exp ) {
		hideElementAll();
	}
}

function cancel() {
	document.getElementById("globalDiv").style.display = "none";
	if ( 1 == exp ) {
		showElementAll();
	}
//	recoverBodyEvent();
}
function buildGlobalDiv(){
		reCalBodySize();
		var globalDiv=document.createElement('div');
		globalDiv.id='globalDiv';
		globalDiv.style.display='none';
		globalDiv.style.zIndex='98';
		globalDiv = set_div_style(globalDiv,'globalDiv','0px','0px',bodyScrollWidth+'px',bodyScrollHeight+'px',"absolute"," #333333 0px solid","default","darkgray");
		globalDiv.onselectstart=function(){return false}
		if ( 1 == exp ) {
			globalDiv.style.filter="alpha(opacity=30)";
		}
		else {
			globalDiv.style.opacity=30/100;
		}
		document.body.appendChild(globalDiv);
}
function synSizeByBody() {
	reCalBodySize();
	var argArr=synSizeByBody.arguments;
	for ( var i=0;i<argArr.length;i++ ) {
		if ( document.getElementById(argArr[i]) != null ) {
			document.getElementById(argArr[i]).style.width = (bodyScrollWidth)+'px';
			document.getElementById(argArr[i]).style.height = (bodyScrollHeight)+'px';
		}
	}
}
// 
function GetCenterXY_ForLayer(objdiv){
	objdiv.style.display='block';
	var styleWidth=objdiv.style.width.substring(0,objdiv.style.width.length-2);
	var clientHeight=objdiv.firstChild.clientHeight;
	var objLeft = parseInt(document.body.scrollLeft+(document.body.clientWidth - styleWidth)/2)+'px';
	var relTop=(document.body.clientHeight-clientHeight)/2 > 0 ? (document.body.clientHeight-clientHeight)/2:0;
	var objTop = parseInt(document.body.scrollTop+relTop)+'px';
	objdiv.style.top = document.getElementById('fast').offsetTop+document.getElementById('fast').clientHeight;
	objdiv.style.left = objLeft;
	checkAndResetStyleTop(objdiv);
}

function doChg(no) {// 
	if ( this.curNo == no ) {
		return false;
	}
	this.val(this.curNo,0);
	this.val(no,1);
	this.curNo=no;
}

function init() {// 
	for ( var i=0;i<this.len;i++ ) {
		this.val(i,0);
		$(this.argArray[i][0]).name=this.argArray[i][0]+i;
		$(this.argArray[i][0]).style.cursor='pointer';
	}
	this.val(0,1);// 
	this.curNo=0;
}
chgBg =function (arr,eventCode,bgOrText) { // 
    // 
	this.argArray		=arr;
	this.eventCode		= eventCode;
	this.len			= this.argArray.length;
	this.curNo			= '0';
	this.bgOrText		= 1;// 

	// 
	this.val=val;
	this.doChg=doChg;
	this.val=val;
	this.init=init;
 }

  function attEvt(chg){// 
 	for ( var i=0;i<chg.len;i++ ) {
		if ( 2 ==  chg.eventCode ) {
			$(chg.argArray[i][0]).onmouseover=function (){chg.doChg(this.name.charAt(this.name.length-1))};
		}
		else {
			$(chg.argArray[i][0]).onclick=function (){chg.doChg(this.name.charAt(this.name.length-1))};
		}
	}
  }
  function openwin( url , name , width , height , left , top ){
	window.open( url , name ,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+width+",height="+height+",left="+left+",top="+top );
}

function goNone() {}