/*
+-----------------------------------------------
+	Javascript for WeSpace Softs.
+	-----------------------------------------
+	Copyright (c) 2004 - 2009 wesofts.com
+	http://www.wesofts.com
+-----------------------------------------------
*/
var uagent    = navigator.userAgent.toLowerCase();
var is_safari = ( (uagent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var is_ie     = ( (uagent.indexOf('msie') != -1) && (!is_opera) && (!is_safari) && (!is_webtv) );
var is_ie4    = ( (is_ie) && (uagent.indexOf("msie 4.") != -1) );
var is_moz    = (navigator.product == 'Gecko');
var is_ns     = ( (uagent.indexOf('compatible') == -1) && (uagent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_safari) );
var is_ns4    = ( (is_ns) && (parseInt(navigator.appVersion) == 4) );
var is_opera  = (uagent.indexOf('opera') != -1);
var is_kon    = (uagent.indexOf('konqueror') != -1);
var is_webtv  = (uagent.indexOf('webtv') != -1);
var is_win    =  ( (uagent.indexOf("win") != -1) || (uagent.indexOf("16bit") !=- 1) );
var is_mac    = ( (uagent.indexOf("mac") != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var ua_vers   = parseInt(navigator.appVersion);
function $(id){
	if (document.getElementById(id)){
		return document.getElementById(id);
	} else {
		return false;
	}
}
function globals_object(){
	this.secparse = function(fname,hashid){
		var theform = eval('document.'+fname);
		var srcimage = fname + '_secimage';
		if (theform && theform.formhash && $(srcimage)){
			theform.formhash.value = hashid;
			$(srcimage).src = Ajax_prefix+'securite.php?formhash=' + hashid + (is_ie ? '&' + Math.random() * 1000000000: '');
		}
	};
	this.sechange = function(fname){
		$('ajaxform').src = Ajax_prefix+'securite.php?action=create&option=' + fname + (is_ie ? '&' + Math.random() * 1000000000: '');
	};
	this.director = function(url){
		window.location.href = url.replace(/&amp;/g,'&');
	};
	this.collapsed = function(id){
		if ($(id)){
			if ($(id).style.display == 'none'){
				$(id).style.display = '';
			} else {
				$(id).style.display = 'none';
			}
		}
	};
	this.masker = function(message,isc){
		if (isc){
			$('masker_element').style.display = 'none';
			return true;
		} else {
			$('masker_element').style.display = '';
		}
		this.position('masker_element',500);
		$('masker_element').innerHTML = '<div style="padding:8px;border:1px solid #c7c7c8;background-color:#f8f8f8"><div style="height:25px;color:#555555;font-weight:bold;border-bottom:1px solid #dfdfdf">&#31995;&#32479;&#25552;&#31034;</div><div style="padding:20px 0px 20px 0px;color:#ff0000;font-size:14px;">'+message.replace(/\n/g,'<br />')+'</div><input type="button" value="&#30830;&#23450;" onclick="globals.masker(false,true)" style="padding:3px 8px 5px 8px;font-weight:bold;border-top:1px solid #ffffff;border-left:1px solid #ffffff;border-right:1px solid #cccccc;border-bottom:1px solid #cccccc;background-color:#dfdfdf" /></div>';
	};
	this.checkes = function(theform){
		var comma = '';
		var checkids = '';
		for (var i = 0; i < theform.elements.length; i++){
			if (theform.elements[i].type == 'checkbox' && theform.elements[i].name.substr(theform.elements[i].name.length - 2,2) == '[]'){
				if (theform.elements[i].checked){
					checkids += comma + theform.elements[i].value; comma = ',';
				}
			}
		}
		return checkids;
	};
	this.checkall = function(theform,checked,input){
		var comma = '';
		var checkids = '';
		var ischeckes = 0;
		var ischecked = true;
		if (typeof(theform) != 'object'){theform = eval('document.'+theform);}
		if (input){
			ischecked = checked ? true : false;
			for (var i = 0; i < theform.elements.length; i++){
				if (theform.elements[i].type == 'checkbox' && theform.elements[i].name.substr(theform.elements[i].name.length - 2,2) == '[]'){
					if (ischecked){
						checkids += comma + theform.elements[i].value; comma = ',';
						theform.elements[i].checked = true;
					} else {
						theform.elements[i].checked = false;
					}
				}
			}
		} else {
			for (var i = 0; i < theform.elements.length; i++){
				if (theform.elements[i].type == 'checkbox' && theform.elements[i].name.substr(theform.elements[i].name.length - 2,2) == '[]'){
					if (ischeckes == 0){ ischecked = theform.elements[i].checked ? false : true; }
					ischeckes++;
					if (ischecked){
						checkids += comma + theform.elements[i].value; comma = ',';
						theform.elements[i].checked = true;
					} else {
						theform.elements[i].checked = false;
					}
				}
			}
		}
		return checkids;
	};
	this.htmlupdater = function(url){if ($('htmlupdateform')){$('htmlupdateform').src = url.replace(/amp;/g,'');}};
	this.cookies = function(k,v,h){
		if (k && k != ''){
			var hours = !isNaN(h) && h > 0 ? h : 365 * 24;
			this.timed = hours * 3600000;
			this.exprites = new Date((new Date()).getTime() + this.timed);
			this.exprites = "; path=/; expires=" + this.exprites.toGMTString();
			document.cookie = k + "=" + escape(v) + this.exprites;
		}
	};
	this.position = function(id,width){
		if (!$(id)){ return false; } width = parseInt(width); if (width <= 0){ width = 578;}
		var _b_l_ = (document.body.clientWidth - width) / 2;
		var _b_t_ = document.documentElement.scrollTop ? document.documentElement.scrollTop : (document.body.scrollTop ? document.body.scrollTop : 0); _b_t_ += 200;//_b_t_ += _b_t_ > 0 ? 35 : 200;
		$(id).style.top = _b_t_ + 'px';
		$(id).style.left = _b_l_ + 'px';
	};
	this.appender = function(id){
		var appended = document.createElement('div');
		appended.setAttribute('id',id);
		$('wespace_append_wraper').appendChild(appended);
		$(id).style.position='absolute';
		$(id).style.display='none';
	};
} 
var globals = new globals_object();
function flash_object(){
	this.swf = Ajax_prefix + 'images/focus.swf';
	this.ader = function(v1,v2,v3,v4,v5,v6,v7){
		v1 = !isNaN(v1) && v1 > 0 ? parseInt(v1) : 240;
		v2 = !isNaN(v2) && v2 > 0 ? parseInt(v2) : 180; if (v7){ v2 += 20; }
		v6 = !isNaN(v6) && v6 > 0 ? parseInt(v6) : 5000;
		this.ks = ['v1','v2','v3','v4','v5','v6','v7'];
		this.vs = [v1,v2,v3,v4,v5,v6,v7];
		this.vr = '';
		this.tmp  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+v1+'" height="'+v2+'">';
		this.tmp += '<param name="movie" value="'+this.swf+'" />';
		this.tmp += '<param name="allowScriptAccess" value="sameDomain" />';
		this.tmp += '<param name="quality" value="high" />';
		this.tmp += '<param name="menu" value="false" />';
		this.tmp += '<param name="wmode" value="opaque" />';
		var cm = '';
		for (var i = 0; i < this.ks.length; i++){
			this.vr += cm + this.ks[i] + '=' + this.vs[i]; cm='&amp;';
			this.tmp+='<param name="'+this.ks[i]+'" value="'+this.vs[i]+'" />';
		}
		this.tmp+='<param name="FlashVars" value="'+this.vr+'" />';
		this.tmp+='<embed src="'+this.swf+'?'+this.vr+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+v1+'" height="'+v2+'"></embed>';
		this.tmp += '</object>';
		document.write(this.tmp);
	};
}
var flasher = new flash_object();
function marquee_object(){
	this.spd = 10;
	this.had = new Array();
	this.cfg = new Array();
	this.uper = function(id,height,limit,second){
		if ($(id)){
			var limit = !isNaN(limit) && limit > 0 ? parseInt(limit) : 100;
			var second = !isNaN(second) && second > 0 ? parseInt(second) : 5;
			var height = !isNaN(height) && height > 0 ? parseInt(height) : 200;
			var mheight = $(id).offsetHeight;
			var message = '';
			if (mheight > height){message = $(id).innerHTML; message = message.replace(/href/g,'onmouseover="marqueer.upstop(\''+id+'\')" onmouseout="marqueer.upstart(\''+id+'\')" href'); message += message;
				$(id).style.height = height + 'px';
				$(id).style.overflow = 'hidden';
				$(id).innerHTML = message;
				this.cfg[id] = [id,height,limit,mheight,second];
				this.updo(id,true);
			}
		};
	};
	this.updo = function(id,init){ 
		if (init){
			$(id).scrollTop = this.cfg[id][3];
			this.had[id] = setInterval('marqueer.updo("'+id+'")',this.cfg[id][4] * 1000);
			return true;
		} else {
			clearInterval(this.had[id]);
		}
		var Toped;
		Toped = $(id).scrollTop + 1; 
		if (Toped > this.cfg[id][3]){
			Toped = 1;
		}
		$(id).scrollTop = Toped;
		if (Toped % this.cfg[id][2] == 0 || Toped == this.cfg[id][3]){
			this.had[id] = setInterval('marqueer.updo("'+id+'")',this.cfg[id][4] * 1000);
		} else {
			this.had[id] = setInterval('marqueer.updo("'+id+'")',this.spd);
		}
	};
	this.upstop = function(id){
		clearInterval(this.had[id]);
	};
	this.upstart = function(id){
		this.had[id] = setInterval('marqueer.updo("'+id+'")',this.cfg[id][4] * 1000);
	};
}
var marqueer = new marquee_object();
function prompt_object(){
	this.xyset = 1000;
	this.xyitem = function(obj){
		var x = parseInt(obj.offsetLeft);
		var y = parseInt(obj.offsetTop);
		var w = parseInt(obj.offsetWidth);
		var h = parseInt(obj.offsetHeight);
		while ((obj = obj.offsetParent) !=null ){
			x += parseInt(obj.offsetLeft);
			y += parseInt(obj.offsetTop);
		}
		return{'x':x,'y':y,'w':w,'h':h};
	};
	this.onitem = function(id,msg){
		if ($(id)){
			var ap = 'wespace_prompts_displayer_' + id;if (!$(ap)){globals.appender(ap);}
			var mx = parseInt(document.body.clientWidth) - 200;
			var xy = this.xyitem($(id));
			var px = xy.x;
			var py = xy.y + xy.h;
			var rt = false;
			if (px > mx){
				px = px + xy.w - 200;
				rt = true;
			}
			$(ap).style.top = py + 'px';
			$(ap).style.left = px + 'px';
			this.onitemsger(ap,msg,rt);
		}
	};
	this.onitemsger = function(ap,msg,right){
		var message = '<div class="p_m">';
		message += '<div class="' + (right ? 'p_m_hr' : 'p_m_hl') + '"><a href="#" title="Close ?" onclick="prompter.offitem(\''+ap+'\');return false"></a></div>';
		message += '<div class="p_m_cc">'+msg+'</div>'
		message += '<div class="p_m_ff"></div>';
		message += '</div>';
		this.xyset++;
		$(ap).innerHTML = message;
		$(ap).style.zIndex = this.xyset;
		$(ap).style.display = '';
	};
	this.offitem = function(id){
		if ($(id)){
			$(id).style.display = 'none';
		}
	};
}
var prompter = new prompt_object();
document.write('<style type="text/css">');
document.write('.p_m {width:200px;overflow:hidden;}');
document.write('.p_m .p_m_hl {padding:14px 13px 0px 0px;height:8px;overflow:hidden;background:url('+Ajax_prefix+'images/system/prompt.' + (is_ie ? 'gif' : 'png') + ') no-repeat 0px 0px;}');
document.write('.p_m .p_m_hl a {width:7px;height:7px;overflow:hidden;display:block;float:right;}');
document.write('.p_m .p_m_hr {height:22px;overflow:hidden;background:url('+Ajax_prefix+'images/system/prompt.' + (is_ie ? 'gif' : 'png') + ') no-repeat -200px 0px;}');
document.write('.p_m .p_m_cc {padding:0px 21px 5px 14px;color:#777777;font-size:14px;background:url('+Ajax_prefix+'images/system/prompt.' + (is_ie ? 'gif' : 'png') + ') repeat-y -400px 0px;}');
document.write('.p_m .p_m_ff {height:14px;overflow:hidden;background:url('+Ajax_prefix+'images/system/prompt.' + (is_ie ? 'gif' : 'png') + ') no-repeat -600px 0px;}');
document.write('</style>');
document.write("<div id=\"wespace_append_wraper\" style=\"position:absolute\"></div>");
document.write('<div id="masker_element" style="margin:0px;padding:4px;width:490px;border:1px solid #c7c7c8;;background-color:#dfdfdf;position:absolute;display:none;z-index:9999"></div>');
document.write('<iframe id="ajaxform" name="ajaxform" src="" width="0" height="0" style="width:0px;height:0px;overflow:hidden;display:none"></iframe>');