
var win1Open=null

//function displayImage(picName, windowName, windowWidth, windowHeight) {
//	return window.open(picName, windowName, "toolbar=no, scrollbars=yes, resizable=no, width="+
//	(parseInt(windowWidth)+20) | ", height="+(parseInt(windowHeight) +15))
//}

function winClose(){
	if(win1Open!=null) win1Open.close()
}

function doNothing(){}

function displayImage(picName, windowName, windowWidth, windowHeight) {
//	if(winHandle !=null) {
//		winHandle.document.close();
//	}

	var winHandle=window.open("", windowName, "toolbar=no, scrollbars=auto,resizable=no, width="+windowWidth+",height="+windowHeight)
	if(winHandle !=null){
	var htmlString="<html><head><title>Picture</title></head>"
	htmlString+="<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>"
	htmlString+="<a href='javascript:window.close()'><img src='"+picName+"' border='0' title='´Ý±â'></a>"
	htmlString+="</body></html>"
	winHandle.document.open()
	winHandle.resizeTo(windowWidth, eval(windowHeight)+30)
	winHandle.document.write(htmlString)
	winHandle.document.close()
	}

	if(winHandle !=null) winHandle.focus()
	return winHandle
}


//======================== Cookies =========================//
// Set Cookie
function setCookie(name, value, expires) {
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;

	var today = new Date() ;
	today = new Date( today.getYear(), today.getMonth(), today.getDate()+expires );

	//var expires = ( argc > 2 ) ? argv[2] : null;
	var path = ( argc > 3 ) ? argv[3] : null;
	var domain = ( argc > 4 ) ? argv[4] : null;
	var secure = ( argc > 5 ) ? argv[5] : false;
	var dsp_cookie;


	dsp_cookie = name + "=" + escape(value) + 
	((expires == null) ? "" : (";expires=" + today.toGMTString())) +
	((path == null) ? "" : (";path=" + path)) +
	((domain == null) ? "" : (";domain=" + domain)) +
	((secure == true) ? ";secure" : "");

	document.cookie = dsp_cookie;
}

// Get Cookie
function getCookie (name) {
	var flag, start, end ;
	var str="";
	var i=0 ;

	while ( i < document.cookie.length ) {
		if ( document.cookie.substr(i, name.length) == name ) {
			flag = true;
			break;
		}
		i++;
	}

	if (flag) {
		start = i + name.length+1;
		end = document.cookie.indexOf(";", start) ;

		if ( end < start ) {
			end = document.cookie.length;
		}

		str = unescape(document.cookie.substring(start, end));
	}

	return str;
}

// Delete Cookie
function delCookie (name) {
	var value = getCookie(name);
	if ( value != "" ) {
		var today = new Date() ;
		today.setTime(today.getTime() - 1) ;
		document.cookie = name + "=" + value + ";expires=" + today.toGMTString() ;
	}
}
