﻿/*
** 站点浏览器辅助脚本
** 作者： Molay
** 版本： 1.0
** 修改时间： 2007-09-20
** 版权所有： Vnice's Group, Inc.
*/
// IE6 PNG格式透明适应程序
function fixPNG(myImage) {    
	var arVersion = navigator.appVersion.split("MSIE");     
	var version = parseFloat(arVersion[1]);     
	if ((version >= 5.5) && (version < 7) && (document.body.filters)){
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "";
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : "";
		var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' ";
		var imgStyle = "display:inline-block;" + myImage.style.cssText;
		var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>";
		myImage.outerHTML = strNewHTML;     
	}
}
// 创建FLASH对象
function Create_Flash(id, url, name, width, height){
	var version = deconcept.SWFObjectUtil.getPlayerVersion();
	if (document.getElementById && version["major"] > 0) {
		var so = new SWFObject(url, name, width, height, "9", "#FFFFFF");
		//so.addParam("scale", "noscale");
		so.addParam("wmode", "transparent");
		so.addParam("allowScriptAccess", "always");
		so.addParam("allowFullScreen", "true");
		so.addParam("menu", "false");
		so.write(id);
	}
}
// 简单的弹出新窗口
function openPage(url){
	var para="height=400, width=700, top=0, left=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes";
	var name="mySystem";
	open_window(url,name,para);
}
function open_window(url,name,para) {
	window.open(url,name,para);
}
// 简单的弹出提示
function AlertMsg(msg){
	window.alert(msg);
}
// 加载进度
function Fill_Begin(){
	Create_Flash("Fill", "media/flash/loader.swf", "myLoader", "600", "350");
}
// 获取完整填充数据后，进行填充
function Fill_Complete(str){
	document.getElementById("Fill").innerHTML = str;
}
// Ajax异步支持
function ajaxRead(url, fun){
	Fill_Begin();
	var xmlObj = null;
	if(window.XMLHttpRequest){
		xmlObj = new XMLHttpRequest();
	} else if(window.ActiveXObject){
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		AlertMsg("Your Browser is too old to support Ajax!");
		return;
	}
	xmlObj.onreadystatechange = function(){
		if(xmlObj.readyState == 4){
			if (xmlObj.status ==200){
				obj = xmlObj.responseXML;
				eval(fun);
			}else{
				alert("Load error, the error number is [" + xmlObj.status  + "]");
			}
		}
	}
	xmlObj.open('GET', url, true);
	xmlObj.send(null);
}
// 获取指定类型XML的CDATA数据
function getCDATA(obj){
	var res = obj.getElementsByTagName("Vnices");
	var temp = res[0].firstChild.nodeValue;
	if(window.XMLHttpRequest){
		temp = res[0].childNodes[1].nodeValue;
	}
	Fill_Complete(temp);
}
// 管理专用
function Open_Admin_Page(url){
	//top.window.frames['mainFrame'].location.href=url;
	top.mainFrame.location.href=url;
}
// 检查帐户名
function CheckUser(username,id){
	var profile_username_toolong = '您的帐户名超过 20 个字符，请输入一个较短的帐户名。';
	var profile_username_tooshort = '帐户名不能小于5个字符';
	var unlen = username.replace(/[^\x00-\xff]/g, "**").length;
	if(unlen < 5 || unlen > 20) {
		document.getElementById(id).innerHTML = (unlen < 5 ? profile_username_tooshort : profile_username_toolong);
	}else{
		document.getElementById(id).innerHTML = '';
	}
}
// 检查密码
function CheckPwd(username,id){
	var profile_username_toolong = '您的密码超过 20 个字符，请输入一个较短的密码。';
	var profile_username_tooshort = '密码不能小于5个字符';
	var unlen = username.replace(/[^\x00-\xff]/g, "**").length;
	if(unlen < 5 || unlen > 20) {
		document.getElementById(id).innerHTML = (unlen < 5 ? profile_username_tooshort : profile_username_toolong);
	}else{
		document.getElementById(id).innerHTML = '';
	}
}

// 其他非空验证
function CheckAll(str,id,txt){
	if(str!=""){
		document.getElementById(id).innerHTML = "";
	}else{
		document.getElementById(id).innerHTML = "<span style='color: #FF0000;padding-left: 10px;'>"+txt+"</span>";
	}
}

// 执行FCK API
function ExecuteCommand(commandName){
	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance('MyFCKeditor') ;
	// Execute the command.
	oEditor.Commands.GetCommand( commandName ).Execute() ;
}
