﻿function openCenterWindow(url,openWindowName,wishWidth,wishHeight)
{
	var realWidth = wishWidth;
	if(realWidth >= screen.width)
	{
		realWidth = screen.width - 20;
	}
	var realHeight = wishHeight;
	if(realHeight >= screen.height)
	{
		realHeight = screen.height - 80;
	}
	var realTop = 0;
	realTop = (screen.height - realHeight)/2 - 20;
	var realLeft = 0;
	realLeft = (screen.width - realWidth)/2 - 5;
	
	var openWindow = window.open(url,openWindowName,"width="+ realWidth +",height="+ realHeight +",top="+ realTop +",left="+ realLeft +",Status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no")
	openWindow.focus();
}
function closeMe()
{
    window.close();
    return false;
}
function closeMeWithConfirm(msg)
{
    if (confirm(msg))
    {
        window.close();
    }    
    return false;
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
function copy(text)
{
    if (clipboardData.setData("text",text))
    {
        alert("复制成功!");
    }
    else
    {
        alert("复制失败!");
    }
}
