/*  Prototype Rolin framework, version 1.0.0
 *  (c) 2007 Rolin <rolin8606@163.com>
 * 	QQ:25281877

/*--------------------------------------------------------------------------*/
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
    	if (typeof element == 'string') element = document.getElementById(element);
		if (arguments.length == 1)  return element;
		elements.push(element);
	}
	return elements;
}


String.prototype.pxToNum = function() {
	var num = Number(this.replace("px",""));
	if (isNaN(num)) num = null;
	return num;
}

function getNextNode(obj) {
	var result = obj.nextSibling;
	while (!result.tagName) {
		result = result.nextSibling;
	}
	return result;
}
function getFirstChild(obj) {
	var result = obj.firstChild;
	while (!result.tagName) {
		result = result.nextSibling;
	}
	return result;
}

function rolinAlertWindow(str) {
	var closeBtn;
	var movieInterval
	var shieldAlpha = 30;
	var dBody = document.getElementsByTagName("BODY")[0];
	var rolinShield = document.createElement("DIV");
	rolinShield.id = "shield";
	var tarH;
	var tarW;
	
	var arr = [["position","absolute"],
				["left","0px"],
				["top","0px"],
				["width","100%"],
				["height",dBody.scrollHeight + "px"],
				["zIndex","10000"],
				["filter","alpha(opacity="+shieldAlpha+")"],
				["opacity",shieldAlpha/100],
				["textAlign","center"],
				["background","#000"]];
	
	for (var i=0; i<arr.length; i++) {
		rolinShield.style[arr[i][0]] = arr[i][1];
	}
	dBody.appendChild(rolinShield)
	var alertMain = document.createElement("DIV");
	alertMain.className = "alert_main";
	alertMain.innerHTML = str;
	alertMain.style.visibility = "hidden";
	dBody.appendChild(alertMain);
	alertMain.style.zIndex = 10002;
	
	alertMain.style.left = "50%";
	alertMain.style.top = "50%";
	alertMain.style.marginLeft = -alertMain.offsetWidth/2 + "px";
	alertMain.style.marginTop =  -alertMain.offsetHeight/2 + document.documentElement.scrollTop + "px";
	
	var div = document.createElement("DIV");
	playMovie(alertMain);
	
	closeBtn = alertMain.getElementsByTagName("IMG")[0];
	closeBtn.style.cursor = "pointer";
	closeBtn.onclick = function() {
		alertMain.parentNode.removeChild(alertMain);
		div.parentNode.removeChild(div);
		rolinShield.parentNode.removeChild(rolinShield);
	}
	
	function playMovie() {
		tarH = alertMain.offsetHeight;
		tarT = alertMain.offsetTop;
		div.style.fontSize = "0px"
		div.style.background = "#fff";
		div.style.position = "absolute";
		div.style.top = (alertMain.offsetTop + tarH/2) + "px" ;
		div.style.left = alertMain.offsetLeft + "px";
		div.style.height = "1px";
		div.style.width = alertMain.offsetWidth + "px";
		div.style.zIndex = 10001;
		dBody.appendChild(div);
		movieInterval = setInterval(moving,10);
	}
	var speed = 0.1666;
	var range = 1;
	var mH = 1;
	var mT = div.style.top.pxToNum();
	function moving() {
		
		mH += (tarH - mH)*speed;
		mT += (tarT - mT)*speed;
		div.style.height = mH + "px";
		div.style.top = mT + "px";
		if (Math.abs(tarH -mH) <= range) {
			clearInterval(movieInterval);
			div.style.height = tarH + "px";
			alertMain.style.visibility = "visible";
		}
	}
	
}

function setAlpha(obj,alpha) {
	if (obj.style.filter) {
		obj.style.filter = "alpha(opacity="+alpha+")";
	} else if (obj.style.opacity) {
		obj.style.opacity = alpha/100;
	}
}

function getAlpha(obj) {
	var result;
	if (obj.style.filter) {
		var reg = /opacity=.[0-9]/i;
		result = Number(obj.style.filter.match(reg)[0].split("=").pop());
	} else if (obj.style.opacity) {
		result = obj.style.opacity*100;
	}
	return result;
}

function innerSWF(obj,oID) {
	var iid = (obj.info[0].substr(obj.info[0].indexOf("/")+1,(obj.info[0].indexOf(".")-1-obj.info[0].indexOf("/"))));
	var url = obj.info[0];
	var w = obj.info[1];
	var h = obj.info[2];
	var quality = obj.info[3];
	var tmp = ""
	tmp += ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"  width="'+w+'" height="'+h+'" id="'+iid+'">');
	tmp += ('<param name="movie" value="'+url+'" />');
    tmp += ('<param name="quality" value="'+quality+'" />');
    tmp += ('<param name="wmode" value="transparent" />');
    tmp += ('<param name="menu" value="false" />');
    tmp += ('<embed  src="'+url+'" wmode="transparent" quality="high"  name="'+iid+'"pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed>');
    tmp += ('</object>');
	document.getElementById(oID).innerHTML = tmp;
}

