﻿
//<!--* ****************************************************** -->
//<!--*					公用客户端JS脚本					 -->
//<!--* ****************************************************** -->
	
// 打开新窗口
function OpenNewWindow(url){
	window.open(url);
}

// 打开模式对话框
function OpenDialogWindow(url,title,width,height){
	var s;
	if(width == null)
		width = 600;
	if( height == null )
		height = 400;
	if( width >= 600 )
		s = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;resizable:no;status:no;scroll:yes";
	else
		s = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;resizable:no;status:no;scroll:no";
    var result = window.showModalDialog(url,title,s );
    if( "reload" == result )
		window.location.href=window.location.href;
	else if( "Refresh" == result )
		document.forms[0].submit();
	else
		return false;

}
// 按"ESC"键关闭窗口
function EscToCloseWindow(){
	if(event.keyCode == 27)
		closeWindow();
}
// 关闭窗口
function closeWindow(){
	window.opener = null;
	window.close();
}
// 将回车转换为 Tab
function EnterToTab()
{
	if(event.keyCode == 13 && (event.srcElement.type == "text" || event.srcElement.type == "password"))
		event.keyCode = 9;
}

// 检测上传图片文件格式是否有效
function CheckImageFileIsValidate(photoFile, isUpload)
{
	var fileUpload = eval("document.all." + isUpload );
	var postFile = eval( "document.all." + photoFile );
	fileUpload.value = "true";	// 默认上传图片文件
	strFileName = postFile.value;
	var re = /^\s+|\s+$/g;
	strFileName = strFileName.replace( re,"" );
	if( strFileName == "" || strFileName.length < 5 ){
		fileUpload.value = "false";
		return true;
	}

	var postfix = strFileName.substring( strFileName.lastIndexOf("."), strFileName.length ).toUpperCase();
	if( postfix == ".MPEG" || postfix == ".MPG" || postfix == ".AVI" || postfix == ".WMV" || postfix == ".WMA" )
	{
		return true;
	}
	else if( postfix != ".BMP" && postfix != ".JPG" && postfix != ".GIF" && postfix != ".PNG" )
	{
		if(confirm("上传的图片格式无效！是否继续？"))
		{
			fileUpload.value = "false";
			return true;
		}
		else
		{
			return false;
		}
	}
	return true;
}
// 图片缩放
var count = 10;
function Picture( imgObject )
{
	count = Counting(count);
	imgObject.style.zoom = count + '0%';
	return false;
}
function Counting(count){   
    if (event.wheelDelta >= 120)
        count++;
    else if (event.wheelDelta <= -120)
        count--;   
    return count; 
}
function suitImage(img,w,h)
{
	var image=new Image();
	image.src=img.src;
	var iw=image.width;
	var ih=image.height;
	var iratio=iw/ih;
	
	if(iw>w)
	{
		iw=w;
		ih=w/iratio;
	}
	if(ih>h)
	{
		ih=h;
		iw=h*iratio;
	}  
	img.width=iw;
	img.height=ih;
}
// 页面头块
function HeadBlock(strHrefClass)
{
	if (!strHrefClass)
		strHrefClass = "";
	var str =	"<table cellSpacing='0' cellPadding='0' width='98%' align='center' border='0'><tr>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://www.golfonlife.com/' target='_blank'>首页</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://match.golfonlife.com/MatchActivity/MatchActivity.aspx' target='_blank'>赛事</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://match.golfonlife.com/PrizeMatch/default.aspx' target='_blank'>差点赛</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://shop.golfonlife.com/Point/default.aspx' target='_blank'>点券专区</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://www.golfonlife.com/news/default.aspx' target='_blank'>新闻</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://shop.golfonlife.com/GolfActivity/default.aspx' target='_blank'>快乐体验</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://shop.golfonlife.com/DianPing/default.aspx' target='_blank'>球场点评</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://shop.golfonlife.com/' target='_blank'>商城</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://51gto.golfonlife.com/' target='_blank'>GTO卡专区</a><img src='http://images.golfonlife.com/newicon.gif' /></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://www.golfonlife.com/ImageCenter/Default.aspx' target='_blank'>图片视频</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://blog.golfonlife.com/Index.aspx' target='_blank'>博客</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://www.golfonlife.com/handicap/default.aspx' target='_blank'>差点</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://team.golfonlife.com/' target='_blank'>球队</a></td><td width='1%' align='center' class='" + strHrefClass + "'>|</td>" +
				"<td align='center' class='" + strHrefClass + "'><a href='http://www.golfonlife.com/forum/Default.htm' target='_blank'>论坛</a></td>" +
				"</tr></table>";
	document.write(str);
}

// 页面结束块
function EndBlock(urlHome,colorValue)
{
	var str = 
	     "<a style='color:" + colorValue + "' href='" + urlHome + "Inc/HomePage/webhelp/zc.shtml'>本站帮助</a> <font color='" + colorValue + "'>|</font> "
		+"<a style='color:" + colorValue + "' href='" + urlHome + "Inc/HomePage/about/gywm.html'>关于本站</a> <font color='" + colorValue + "'>|</font> "
		+"<a style='color:" + colorValue + "' href='" + urlHome + "Inc/HomePage/about/ggkl.html'>广告服务</a> <font color='" + colorValue + "'>|</font> "
		+"<a style='color:" + colorValue + "' href='" + urlHome + "Inc/HomePage/about/mjxs.html'>诚聘英才</a> <font color='" + colorValue + "'>|</font> "
		+"<a style='color:" + colorValue + "' href=mailto:info#golfonlife.com>联系我们</a>"
		+"<br/><font color=" + colorValue + "' >Copyright &copy; 2004 - 2010 GolfOnLife Inc. All Rights Reserved</font><br/>"
		+"<a style='color:" + colorValue + "' href='" + urlHome + "' target=_blank>上海高林文化传播有限公司</a> <font color='" + colorValue + "'>[</font>"
		+"<a  class='bule' href='http://www.miibeian.gov.cn' target =_blank>沪ICP备05049352号</a><font color='" + colorValue + "'>]</font>";
	document.write(str);
}
var ie4 = (document.all && !document.getElementById) ? true : false;// IE 4
var ie5 = (document.all && document.getElementById) ? true : false;	// IE 5+
var ns4 = (document.layers) ? true : false;							// netscape 4
var ns6 = (!document.all && document.getElementById) ? true : false;// netscape 6

function $(objName) 
{
	var result = "";
	if (ie5 || ns6)
		result = document.getElementById(objName);
	else if (ie4)
		result = document.all[objName];
	else if (ns4)
		result = document.layers[objName];
	return result;
}
function trim(s){
	if (s)
 		return rtrim (ltrim(s));
 	return "";
}
function ltrim(s){
	if (s)
 		return s.replace (/^\s*/, ""); 
 	return "";
} 
function rtrim(s){
	if (s)
 		return s.replace (/\s*$/, ""); 
 	return "";
}
function isNumber(num)
{
	if(num.length == 0)
		return false;
		
	for(i = 0; i < num.length; i++)
	{
		if(num.charAt(i) < "0" || num.charAt(i) > "9")
		return false;
	}
	return true;
}
//全选
//chkAll--传全选CheckBox对象
//itemID--传DataGrid(块)的ClientID
//块中间的CheckBoxID必须包含chkItem_
function CheckAll(chkAll, itemID)
{
	var objs =document.all.tags("input");
	for(var i=0;i<objs.length;i++)
	{
		if(objs[i].type.toUpperCase() =="CHECKBOX" && objs[i].name.indexOf("EvertchkItem")>-1 && objs[i].disabled == "")
			objs[i].checked = chkAll.checked;	
	}
}
//等比例缩放图片
//obj图像对象
//MaxW，MaxH
function ResizeImage(obj, MaxW, MaxH)
{
	if (obj != null) imageObject = obj;
	var state=imageObject.readyState;
	if(state!='complete') 
	{
		setTimeout("ResizeImage(null,"+MaxW+","+MaxH+")",50);
		return;
	}
	var oldImage = new Image();
	oldImage.src = imageObject.src;
	var dW=oldImage.width; var dH=oldImage.height;
	if(dW>MaxW || dH>MaxH)
	{
       a=dW/MaxW; b=dH/MaxH;
      if(b>a) a=b;
      dW=dW/a; dH=dH/a;
	 }
	 
	if(dW > 0 && dH > 0)
	{
		imageObject.width=dW;
		imageObject.height=dH;
	}
}

function e3i5size() 
{

	var e3i5;//=new Array()
	for (i=0; i<fqy.length; i++)
	{	
		if (document.getElementById)
		{
	//自动调整iframe高度
			e3i5 = document.getElementById(fqy[i]);			
			if (e3i5 && !window.opera)
			{			
			e3i5.style.display="block"
			if (e3i5.contentDocument && e3i5.contentDocument.body.offsetHeight) //如果用户的浏览器是NetScape
			e3i5.height = e3i5.contentDocument.body.offsetHeight; 
			else if (e3i5.Document && e3i5.Document.body.scrollHeight) //如果用户的浏览器是IE
			e3i5.height = e3i5.Document.body.scrollHeight;
			}
		}
	//根据设定的参数来处理不支持iframe的浏览器的显示问题
		if ((document.all || document.getElementById) && iframehide=="no")
		{
		var tempobj=document.all?document.all[fqy[i]]:document.getElementById(fqy[i])
		tempobj.style.display="block"
		}
	}
}


function GetObj(objName){
	if(document.getElementById){
		return eval('document.getElementById("' + objName + '")');
	}else if(document.layers){
		return eval("document.layers['" + objName +"']");
	}else
	{
		return eval('document.all.' + objName);
	}	
}

 //日期增加函数
 function  dateAdd(strInterval,  NumDay,  dtDate)  {  
    var  dtTmp  =  new  Date(dtDate);  
    if  (isNaN(dtTmp))  dtTmp  =  new  Date();  
    switch  (strInterval)  {  
     case  "s":return  new  Date(Date.parse(dtTmp)  +  (1000  *  NumDay));  
     case  "n":return  new  Date(Date.parse(dtTmp)  +  (60000  *  NumDay));  
     case  "h":return  new  Date(Date.parse(dtTmp)  +  (3600000  *  NumDay));  
     case  "d":return  new  Date(Date.parse(dtTmp)  +  (86400000  *  NumDay));  
     case  "w":return  new  Date(Date.parse(dtTmp)  +  ((86400000  *  7)  *  NumDay));  
     case  "m":return  new  Date(dtTmp.getFullYear(),  (dtTmp.getMonth())  +  NumDay,  dtTmp.getDate(),  dtTmp.getHours(),  dtTmp.getMinutes(),  dtTmp.getSeconds());  
     case  "y":return  new  Date((dtTmp.getFullYear()  +  NumDay),  dtTmp.getMonth(),  dtTmp.getDate(),  dtTmp.getHours(),  dtTmp.getMinutes(),  dtTmp.getSeconds());  
    }  
 } 