function photo_countUp(a,b) {

		var f = document.writeForm;
		f.photo_num.value=a;
		f.size_num.value=b;
		f.action = "popup_download.jsp";
		f.submit();
	
	}
	
function photo_file(a,b) {

		var f = document.writeForm;
		f.file_name.value=a;
		f.site_cd.value=b;
		f.action = "filedown.jsp";
		f.submit();

	}	
	
function getCookie( name ){
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
			endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
		break;
	}
	return "";
}
function setCookie( name, value, expiredays ) {
	var today = new Date();
	today.setDate( today.getDate() + expiredays );
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + today.toGMTString() + ";";
}
function closewin(obj) {
	var tmp = document.getElementById(obj);
	setCookie( tmp.id,"done" ,1);
	tmp.style.display="none";
}
function showLayer(obj1,obj2){

	var obj =document.getElementById(obj2);
	//alert(document.getBoxObjectFor(obj1));

	var box1 = getBoundsFront(document.getElementById(obj1));
	
	//var top =  get_obj_top(obj1);
	obj.style.visibility="visible";	
	obj.style.top  = box1.top+'px';
	obj.style.left = box1.left+'px';

}
function showLayer2(obj1,obj2){

	var obj =document.getElementById(obj2);
	//alert(document.getBoxObjectFor(obj1));

	var box1 = getBoundsFront(document.getElementById(obj1));
	
	//var top =  get_obj_top(obj1);
	obj.style.visibility="visible";	
	obj.style.zIndex="10";
	obj.style.top  = box1.top+'px';
	obj.style.left = (box1.left-500)+'px';

}
function showLayer_login(obj1,obj2){

	var obj =document.getElementById(obj2);
	//alert(document.getBoxObjectFor(obj1));

	var box1 = getBoundsFront(document.getElementById(obj1));
		
	//var top =  get_obj_top(obj1);
	obj.style.visibility="visible";	
	obj.style.zIndex="10";
	obj.style.top  = (box1.top-200)+'px';
	obj.style.left = (box1.left-680)+'px';

}
function showLayerCal(obj1,obj2){

	var obj =document.getElementById(obj2);
	var box1 = getBoundsOrg(document.getElementById(obj1));

	obj.style.visibility="visible";	
	obj.style.zIndex="30";
	obj.style.top  = box1.top+'px';
	obj.style.left = box1.left+'px';

}
function showLayer3(obj1,obj2){

	var obj =document.getElementById(obj2);
	//alert(document.getBoxObjectFor(obj1));

	var box1 = getBoundsFront(document.getElementById(obj1));

	//var top =  get_obj_top(obj1);
	obj.style.visibility="visible";	
	obj.style.zIndex="10";
	obj.style.top  = (box1.top-300)+'px';
	obj.style.left = (box1.left-500)+'px';

}

function showLayer7(obj1,obj2){

	var obj =document.getElementById(obj2);
	//alert(document.getBoxObjectFor(obj1));

	var box1 = getBoundsFront(document.getElementById(obj1));

	//var top =  get_obj_top(obj1);
	obj.style.visibility="visible";	
	obj.style.zIndex="10";
	obj.style.top  = (box1.top-300)+'px';
	obj.style.left = (box1.left-900)+'px';

}

function showLayer5(obj1,obj2){

	var obj =document.getElementById(obj2);
	//alert(document.getBoxObjectFor(obj1));

	var box1 = getBoundsFront(document.getElementById(obj1));
	
	//var top =  get_obj_top(obj1);
	obj.style.visibility="visible";	
	obj.style.zIndex="10";
	obj.style.top  = (box1.top-300)+'px';
	obj.style.left = (box1.left-300)+'px';

}

function showLayer6(obj1,obj2){

	var obj =document.getElementById(obj2);
	//alert(document.getBoxObjectFor(obj1));

	var box1 = getBoundsFront(document.getElementById(obj1));
	
	//var top =  get_obj_top(obj1);
	obj.style.visibility="visible";	
	obj.style.zIndex="10";
	obj.style.top  = (box1.top-340)+'px';
	obj.style.left = (box1.left-500)+'px';

}
function getBounds(tag) 
{ 
    var ret = new Object(); 
    if(document.all) { 
        var rect = tag.getBoundingClientRect(); 
        ret.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft); 
        ret.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop); 
        ret.width = rect.right - rect.left; 
        ret.height = rect.bottom - rect.top; 
    } else { 
        var box = document.getBoxObjectFor(tag); 
        ret.left = box.x; 
        ret.top = box.y; 
        ret.width = box.width; 
        ret.height = box.height; 
    } 
    ret.top=ret.top+15;
    ret.left=ret.left-40;
    return ret; 
}
function getBoundsFront(tag) 
{ 
    var ret = new Object(); 
  
   // if(document.all) { 
        var rect = tag.getBoundingClientRect(); 
        ret.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft); 
        ret.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop); 
        ret.width = rect.right - rect.left; 
        ret.height = rect.bottom - rect.top; 
   // } else { 
   //     var box = document.getBoxObjectFor(tag); 
   //     ret.left = box.x; 
   //     ret.top = box.y; 
   //     ret.width = box.width; 
   //     ret.height = box.height; 
  //  } 
    ret.top=ret.top+20;
    ret.left=ret.left+ret.width;
    return ret; 
}
function getBoundsOrg(tag) 
{ 
    var ret = new Object(); 
    if(document.all) { 
        var rect = tag.getBoundingClientRect(); 
        ret.left = rect.left; 
        ret.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop); 
        ret.width = rect.right - rect.left; 
        ret.height = rect.bottom - rect.top; 
    } else { 
        var box = document.getBoxObjectFor(tag); 
        ret.left = box.x; 
        ret.top = box.y; 
        ret.width = box.width; 
        ret.height = box.height; 
    } 
    ret.top=ret.top;
    ret.left=ret.left-ret.left/2;
    return ret; 
}
function closeLayer(objName){
	var obj =document.getElementById(objName);
	obj.style.visibility="hidden";	
}

function getPosition(aTag)
{
	var oTmp = aTag;
	var pt = new Position(0,0);

	do
	{
		pt.x += oTmp.offsetLeft;
		pt.y += oTmp.offsetTop;
		oTmp = oTmp.offsetParent;
	}
	//alert(oTmp);
	while(oTmp.tagName !="DIV");
	return pt;
}
function Position(iX, iY)
	{
		this.x = iX;
		this.y = iY;
	}


String.prototype.trim = function() {
  var pattern = !arguments[0] ? /^\s+|\s+$/g
              : new RegExp('^['+arguments[0]+']+|['+arguments[0]+']+$', 'g')
  return this.replace(pattern, '')
}


function replaceUTF8(str) {
	var tempDiv = document.createElement("DIV");
	tempDiv.innerHTML = str;
	var encoded = tempDiv.innerHTML;

	var splited = encoded.split("<BR>");
	var result = splited[0];
	for (var i = 1; i < splited.length; i++) {
		result = result+ '\n' + splited[i]
	}
	return result;
}

function countedIndexOf(str, target, count) {
	if (str.indexOf(target) < 0)
		return -1;
	var buf = str;
	var lastIndex = -1;
	for (var i = 0; i < count; i++) {
		if (buf.indexOf(target) >= 0) {
			var index = buf.indexOf(target) + 1;
			lastIndex += index;
			buf = buf.substring(index);
		}
	}
	return lastIndex;
}

function checkNumber1(event) {
	 if((event.keyCode<48)||(event.keyCode>57))
		 event.returnValue = false;
}

function moveParent(url) {
	Try.these(
		function() {
			opener.location.href = url;
			opener.focus();
		},
		function() {
			var popupWindow = window.open(url, "newIndow");
			popupWindow.focus();
		}
	);
}

function photo_countUp(a,b) {
		var f = document.writeForm;
		//alert(a);
		//alert(b);
		f.photo_num.value = a;
		f.size_num.value = b;
		f.target = "hiddenFrm";
		f.action = "/proc/footer/photo_count_up.jsp";
		//alert(f.action);
		f.submit();
		//alert(1);
	}