

function trim(s){
	return s.replace(/^\s+|\s+$/,'');
}

// trim spaces, translate special character to xml entity
function xmlEncode(value){
	var s = value.replace(/^\s+|\s+$/gim, "");
	s = s.replace(/&/gim,"&amp;");
	s = s.replace(/</gim,"&lt;");
	s = s.replace(/>/gim,"&gt;");
	s = s.replace(/'/gim,"&apos;");
	s = trim(s);
	return s.replace(/"/gim, "&quot;");
}

function padLeft(s, toLength, c){
	s = s + '';
	if(!c) c = ' ';
	var t = '';
	for(var i = 0; i < toLength - s.length; i++){
		t += c;
	}
	return t + s;
}
function getCurTime()
{	
	var dCurrDate = new Date();
	var sCurrDate = dCurrDate.getFullYear() + "-";
	sCurrDate += padLeft(parseInt(dCurrDate.getMonth() + 1).toString(), 2, "0") + "-";
	sCurrDate += padLeft(dCurrDate.getDate(), 2, '0') + " ";
	sCurrDate += padLeft(dCurrDate.getHours(), 2, '0') + ":";
	sCurrDate += padLeft(dCurrDate.getMinutes(), 2, '0') + ":";
	sCurrDate += padLeft(dCurrDate.getSeconds(), 2, '0');
	return sCurrDate;
}
function getCurDate()
{
    var dCurrDate = new Date();
	var sCurrDate = dCurrDate.getFullYear() + "-";
	sCurrDate += padLeft(parseInt(dCurrDate.getMonth() + 1).toString(), 2, "0") + "-";
	sCurrDate += padLeft(dCurrDate.getDate(), 2, '0') + " ";	
	return sCurrDate;
}

//转换特殊字符
function f_transferSpecial(str)
{
	//var strnew=str.replace(/\+/gi,"%2b");
	//var strnew=str.replace(/%/gim,"%25").replace(/\+/gim,"%2B").replace(/\?/gim,'%3F').replace(/#/gim,'%23').replace(/&/gim,'%26').replace(/\//gim,'%2F');
	//return strnew;
}

//转换特殊字符
function f_untransferSpecial(str)
{
	//var strnew=str.replace(/%25/gim, '%').replace(/%2B/gim,"+").replace(/%3F/gim,'?').replace(/%23/gim, '#').replace(/%26/gim, '&').replace(/%2F/gim, '\\');
	//return strnew;
}

//
function bookmark()
{
    if(! window.external.haveFavorite("http://www.gamektv.com"))
    {
       alert();
       if (window.confirm("您是否把本站添加到收藏夹?"))  
       {      
	        window.external.AddFavorite("http://www.gamektv.com", "鹤乡棋牌乐")

        }
    }
}

function markpic_click(id,name,mark)
{
    var sURL="../system/myMark.htm?id=" + id + "&name="+ name + "&mark=" + mark;
    var w=400;
    var h=300;
    var l=300;
    var t=200;
    OpenNewWindow(sURL,w,h,l,t) 
}
            
function setFirstPage()
{
}


function GetCookie(sName)
{
  // cookies are separated by semicolons  
 
  var aCookie = document.cookie.split(";");
  for (var i=0; i < aCookie.length; i++)
  {
     // a name/value pair (a crumb) is separated by an equal sign
     // alert( aCrumb); 
    var aCrumb = aCookie[i].split("=");   
    if (sName == aCrumb[0]) 
      return aCrumb[1];
  }

  // a cookie with the requested name does not exist
  return null;
}
function SetCookie(sName, sValue)
{
   var date = new Date();   
   date.setMonth(date.getMonth()+6);
   var aaa = sName + "=" +sValue + "; expires=" + date.toGMTString();
   document.cookie = aaa;
 
}

function DelCookie(sName)
{
  document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1990 23:59:59 GMT;";
}


