



var sc={
	Page : {},
	Ajax : {}
}


sc.Page.getURL=function(url, target){
	if(target){
		target=target.toLowerCase();
		if      (target == '_blank')  void this.popup(url);
		else if (target == '_top'   ) top.location.href=url;
		else if (target == '_parent') parent.location.href=url;
		else if (target == '_self')   document.location.href=url;
		else{
			try{eval("top.$('"+target+"')").src=url;}catch(e){document.location.href=url;}
		}
	}else{
		document.location.href=url;
	}
}

sc.Page.popup=function(url, name, vars){
	url  = url  ? url  : 'about:blank';
	name = name ? name : '';
	vars = vars ? vars : 'width=800,height=600,scrollbars=yes,'
	+ 'resizable=yes,menubar=yes,toolbar=yes,location=yes,status=yes';
	var win=window.open(url, name, vars);
	if(!win){
		alert('似乎某个弹出式窗口拦截器导致了无法打开该网页。\n\n如果您使用了窗口拦截器，请尝试关闭它，以便打开该窗口。');
		return null;
	}else{
		win.focus();
		return win;
	}
}

sc.Page.favorite=function(title,url){ 
   var desc='';
	if(typeof(window.sidebar)=='object' && typeof(window.sidebar.addPanel)=='function'){ 
		window.sidebar.addPanel(title,url,desc);
	}else{ 
		window.external.AddFavorite(url,title); 
	} 
}


sc.Page.png=function(img){
	var str=String(navigator.appVersion);
	if(str.indexOf("MSIE 6")==-1) return;
	var SC_w = img.width ;
	var SC_h = img.height;
	var imgName = img.src.toUpperCase() 
	if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){  
		img.style.filter+="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="
		+ img.src + ", sizingmethod=scale);"  
		img.src="js/watermark.gif"//为1px*1px的透明gif图片 
		img.width=SC_w; 
		img.height=SC_h;
	}
}


sc.Page.plug=function(paramObj){
	var o=paramObj;
	if(!o.src){
		alert('初始化播放插件失败，未指定文件地址。');
		return;
	}
   var src    = o.src;
	var width  = o.width  ? o.width  : '100%';
	var height = o.height ? o.height : '100%';
	var id     = o.id     ? o.id     : 'SC_Plug';
	
	var ext    = src.substring(src.lastIndexOf(".")+1).toUpperCase();
	if( ext=='RM' || ext=='RAM' || ext=='RMVB') initRealPlayer();
	else if(ext=='SWF')          initFlashPlayer();
	else                         initMediaPlayer();
	
	function initRealPlayer(){
		var s=[];
		with(s){
			push('<object id="' + id + '" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"');
			push('width="'+width+'" height="'+height+'">');
			push('<param name="_ExtentX" value="9313"> ');
			push('<param name="_ExtentY" value="7620"> ');
			push('<param name="AUTOSTART" value="1"> ');
			push('<param name="SHUFFLE" value="0"> ');
			push('<param name="PREFETCH" value="0"> ');
			push('<param name="NOLABELS" value="0"> ');
			push('<param name="src" value="'+src+'">');
			push('<param name="CONTROLS" value="ImageWindow"> ');
			push('<param name="CONSOLE" value="Clip1"> ');
			push('<param name="LOOP" value="0"> ');
			push('<param name="NUMLOOP" value="0">');
			push('<param name="CENTER" value="0"> ');
			push('<param name="MAINTAINASPECT" value="0"> ');
			push('<param name="BACKGROUNDCOLOR" value="#000000">');
			push('<embed src="' + src + '" type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1"');
			push('CONTROLS="ImageWindow" height="' + height + '" WIDTH="' + width + '" AUTOSTART="false">');
			push('</object>');
		}
		document.writeln(s.join(''));
	}

   function initFlashPlayer(){
      var vars = o.vars ? o.vars : null;
		var wmode= o.wmode? o.wmode:"transparent"
		var s  = [];
		with(s){
			push('<object id="' + id + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ');
			push('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.');
			push('cab#version=7,0,0,0" width="' + width + '" height="' + height + '" align="middle">');
			push('<param name="allowScriptAccess" value="sameDomain" />\n');
			push('<param name="quality" value="high" />\n');
			push('<param name="menu" value="false" />\n');
			push('<param name="wmode" value="'+wmode+'" />\n');
			if(vars)  push('<param name="FlashVars" value="' + vars + '" /> ');
			push('<param name="movie" value="' + src + '" />');
			push("<embed src=\""+ src +"\" quality=\"high\" width=\""+ width +"\" height=\""+ height);
			push("\" name=\"index\" align=\"middle\" allowScriptAccess=\"sameDomain\" ");
			push( vars ? "FlashVars=\"" + vars + "\"" : "");
			push(' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go');
			push('/getflashplayer" wmode="'+wmode+'" menu="false" />');
			push('</object>');
		}
		document.writeln(s.join(""));
	}

   function initMediaPlayer(){
		/*
		*相关控制代码:
		** 全屏代码:       对象id.displaySize= 3
		**
		**/
		var s = [];
	   with(s){
			push('<object id="' + id + '" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"');
			push(' width="'+width+'" height="'+height+'">');
			push('<param id="furl" name="Filename" value="'+src+'">');
			push('<param name="AudioStream" value="-1">');
			push('<param name="AutoSize" value="0">');
			push('<param name="AutoStart" value="-1">');
			push('<param name="AnimationAtStart" value="-1">');
			push('<param name="AllowScan" value="-1">');
			push('<param name="AllowChangeDisplaySize" value="1">');
			push('<param name="AutoRewind" value="0">');
			push('<param name="Balance" value="0">');
			push('<param name="BaseURL" value>');
			push('<param name="BufferingTime" value="5">');
			push('<param name="CaptioningID" value>');
			push('<param name="ClickToPlay" value="-1">');
			push('<param name="CursorType" value="0">');
			push('<param name="CurrentPosition" value="-1">');
			push('<param name="CurrentMarker" value="0">');
			push('<param name="DefaultFrame" value>');
			push('<param name="DisplayBackColor" value="0">');
			push('<param name="DisplayForeColor" value="16777215">');
			push('<param name="DisplayMode" value="0">');
			push('<param name="DisplaySize" value="2">');
			push('<param name="Enabled" value="-1">');
			push('<param name="EnableContextMenu" value="-1">');
			push('<param name="EnablePositionControls" value="-1">');
			push('<param name="EnableFullScreenControls" value="0">');
			push('<param name="EnableTracker" value="-1">');
			push('<param name="InvokeURLs" value="-1">');
			push('<param name="Language" value="-1">');
			push('<param name="Mute" value="0">');
			push('<param name="PlayCount" value="1">');
			push('<param name="PreviewMode" value="0">');
			push('<param name="Rate" value="1">');
			push('<param name="SAMILang" value>');
			push('<param name="SAMIStyle" value>');
			push('<param name="SAMIFileName" value>');
			push('<param name="SelectionStart" value="-1">');
			push('<param name="SelectionEnd" value="-1">');
			push('<param name="SendOpenStateChangeEvents" value="-1">');
			push('<param name="SendWarningEvents" value="-1">');
			push('<param name="SendErrorEvents" value="-1">');
			push('<param name="SendKeyboardEvents" value="0">');
			push('<param name="SendMouseClickEvents" value="0">');
			push('<param name="SendMouseMoveEvents" value="0">');
			push('<param name="SendPlayStateChangeEvents" value="-1">');
			push('<param name="ShowCaptioning" value="0">');
			push('<param name="ShowControls" value="0">');
			push('<param name="ShowAudioControls" value="-1">');
			push('<param name="ShowDisplay" value="0">');
			push('<param name="ShowGotoBar" value="0">');
			push('<param name="ShowPositionControls" value="0">');
			push('<param name="ShowStatusBar" value="0">');
			push('<param name="ShowTracker" value="-1">');
			push('<param name="TransparentAtStart" value="0">');
			push('<param name="VideoBorderWidth" value="0">');
			push('<param name="VideoBorderColor" value="0">');
			push('<param name="VideoBorder3D" value="0">');
			push('<param name="Volume" value="-40">');
			push('<param name="WindowlessVideo" value="0">');
			push('</object>');
		}
		document.writeln(s.join(""));
	}
}


sc.Ajax=function (url, method, data){
	method = method ? method : 'GET';
	method = method.toUpperCase()=='POST' ? 'POST' : 'GET';
	url    = "../SC_Xml/"+ url;
	if(method=='GET') url += '?' + data;
	var sync=false;

	this.method = method;
	this.url    = url;
	this.data   = data;
   this.ajax   = null;
	if(window.ActiveXObject)        this.ajax = new ActiveXObject("Microsoft.XMLHTTP");
   else if (window.XMLHttpRequest) this.ajax = new XMLHttpRequest();

   this.addFill=function(obj,loc){
		var ajax=this.ajax;
	   this.ajax.onreadystatechange=function(){
		   if(ajax.readyState==4){
				  var s = ajax.status==200 ? ajax.responseText : "抱歉，装载数据失败。原因：　"+ajax.statusText;
				  loc=String(loc).toLowerCase();
				  if(loc=='before')     obj.innerHTML  = s + obj.innerHTML;
				  else if(loc=='after') obj.innerHTML += s;
				  else                  obj.innerHTML  = s;
		   }
      }
		sync=true;
	}

   this.addFillBefore=function(obj){
	   this.addFill(obj, 'before');
	}

   this.addFillAfter=function(obj){
	   this.addFill(obj, 'after');
	}

	this.addEventListener=function(funName){
		this.ajax.onreadystatechange = funName;
		sync=true;
	}

	this.Exec=function(str){
		this.ajax.open(this.method, this.url, sync);
		this.ajax.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
		this.ajax.send(this.data);
		if(sync){
			return null;
		}else{
			switch(str){
				case 'xml'   :  return this.ajax.responseXML;break;
				case 'body'  :  return this.ajax.responseBody;break;
				case 'stream':  return this.ajax.responseStream;break;
				default      :  return this.ajax.responseText;break;
			}
		}
	}

}



/*可检测日期范围：1900-2099*/
String.prototype.isDate=function(){
	var str=this;
   if(str==null || str=="") return true;
	var re0=/^\d{4}\-\d{1,2}\-\d{1,2}$/;//YYYY-MM-DD　(　MM和DD是一位数或两位都可以,下同)
	var re1=/^\d{4}\/\d{1,2}\/\d{1,2}$/;//YYYY/MM/DD
	var re2=/^\d{4}\.\d{1,2}\.\d{1,2}$/;//YYYY.MM.DD
	var re3=/^\d{4},\d{1,2},\d{1,2}$/;  //YYYY,MM,DD
	var re4=/^\d{4} \d{1,2} \d{1,2}$/;  //YYYY MM DD
	var re5=/^\d{8}$/;                  //YYYYMMDD   (MM和DD必须是两位,不足前加０,即整串必须是８位.)
	if(!re0.test(str) && !re1.test(str) && !re2.test(str) && !re3.test(str) && !re4.test(str) && !re5.test(str)){
	   return false;
	}
	if(!re5.test(str)){
	   str=str.replace(/ /g,"-").replace(/,/g,"-").replace(/\./g,"-").replace(/\//g,"-");
		var strA=str.split("-");
		if(strA[1].length==1) strA[1]="0"+String(strA[1]);
		if(strA[2].length==1) strA[2]="0"+String(strA[2]);
		str=strA.join("");
	}
	var y=str.substring(0,4);
	var m=str.substring(4,6);
	var d=str.substring(6);
	if(m<1 || m>12 || d<1 || d>31){
      return false;
   }
	if(y%4!=0 && m==2 && d>28){
	   return false;
	}
	if(m<7 && m%2==0 && d>30) return false;
	if(m>8 && m%2==1 && d>30) return false;
	if(m==2 && d>29) return false;
	if(y<1900 || y>2099) return false;
	return true;
}