/*
+--------------------------------------------------------
+	Javascript object
+--------------------------------------------------------
*/
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){
	return document.getElementById(id) ? document.getElementById(id) : false;
}

function mynavigatas(){
	this.navids = 8;
	this.navwrap = new Array();
	this.over = function(id){
		if ($(id)){
			$(id).className = 'nh';
		}
	}
	this.outer = function(id){
		if ($(id)){
			$(id).className = this.navwrap[id];
		}
	}
	this.initia = function(){
		for (var i = 1; i <= this.navids; i++){
			if ($('navid' + i)){
				this.navwrap['navid' + i] = this.navwrap['navid' + i] && this.navwrap['navid' + i] != '' ? this.navwrap['navid' + i] : $('navid' + i).className;
			}
		}
	}
	this.banner = function(){
		if ($('bannerid')){
			/*$('bannerid').innerHTML = '<br /><font color="#ff0000">皖易办公场所搬迁, 电话线路不畅时, 请拨打: 13966013721</font>&nbsp;&nbsp;';*/
		}
	}
	this.navmessage = [
		[jslang.navigata1,'/index.html'],
		[jslang.navigata2,'/license.html'],
		[jslang.navigata3,'/buy.html'],
		[jslang.navigata4,'/document.html'],
		[jslang.navigata5,'/download.html'],
		[jslang.navigata6,'/apply.html'],
		[jslang.navigata7,'/merchant.html'],
		[jslang.navigata8,'/answer/']
		//[jslang.navigata8,'/forum.html']//,
		//[jslang.navigata9,'/answer/']
	];
	this.navdisplay = function(id){
		this.tmper = '';
		for (var i = 0; i < this.navmessage.length; i++){
			this.navwrap['navid' + i] = i == id-1 ? 'nt' : 'nf';
			this.tmper += '<' + 'li id="navid'+i+'" class="' + (i == id-1 ? 'nt' : 'nf') + '" onmouseover="navigatas.over(this.id)" onmouseout="navigatas.outer(this.id)"' + '>' + '<' + 'a href="' + this.navmessage[i][1] + '">' + this.navmessage[i][0] + '<' + '/' + 'a' + '>' + '<' + '/' + 'li' + '>' + '<' + 'li class="ns"' + '>' + '<' + '/' + 'li' + '>';
		}
		$('navigataid').innerHTML = this.tmper;
	}
	this.footdisplay = function(){
		$('footer').innerHTML = jslang.footermsg;
	}
	this.cpanel = function(id){
		this.cpanels = 30;
		for (var i = 11; i <= this.cpanels; i++){
			if ($('cper' + i)){
				$('cper' + i).className = id == i ? 'ct' : 'cf';
			}
		}
	}
}
navigatas = new mynavigatas();



function myfocuser(){
	this.input = function(n,m){
		for (var i = 1; i <= m; i++){
			if ($('focusid' + i)){
				$('focusid' + i).className = i == n ? 'it' : 'if';
			}
		}
	}
}
focuser = new myfocuser();

function mymerchant(){
	this.login = function(result){
		var theform = document.wane_login;
		if (result){
			this.tmpmsg = '';
			switch (result){
				case 'uid' : this.tmpmsg = jslang.login_nouid; theform.uid.focus(); break;
				case 'mid' : this.tmpmsg = jslang.login_nomid; theform.mid.focus(); break;
				case 'pid' : this.tmpmsg = jslang.login_nopid; theform.pid.focus(); break;
				case 'iuid' : this.tmpmsg = jslang.login_inuid; theform.uid.focus(); break;
				case 'imid' : this.tmpmsg = jslang.login_inmid; theform.mid.focus(); break;
				case 'ipid' : this.tmpmsg = jslang.login_inpid; theform.pid.focus(); break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
			}
		}else{
			if (theform.uid.value == ''){
				this.login('uid');
				return false;
			}else if (theform.mid.value == ''){
				this.login('mid');
				return false;
			}else if (theform.pid.value == ''){
				this.login('pid');
				return false;
			}
		}
	}
	this.fetch = function(results){
		var theform = document.wane_login;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'iuid' : this.tmpmsg = jslang.fetch_iuid;	this.focuser = 'uid';	break; 
				case 'ieid' : this.tmpmsg = jslang.fetch_ieid;	this.focuser = 'eid';	break; 
				case 'imch' : this.tmpmsg = jslang.fetch_imch;	this.focuser = 'uid';	break; 
				case 'fnsh' : this.tmpmsg = jslang.fetch_true;	this.focuser = 'url';	break; 
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser == 'url'){
					this.location('merchant.html');
				}else if (this.focuser != ''){
					eval('theform.' + this.focuser + '.focus()');
				}
			}
		}
	}
	this.profile = function(results){
		var theform = document.wane_profile;
		if (results){
			this.tmpmsg = '';
			switch (results){
				case 'unopid' : this.tmpmsg = jslang.profile_unopid;	this.focuser = 'opid';	break;
				case 'inopid' : this.tmpmsg = jslang.profile_inopid;	this.focuser = 'opid';	break;
				case 'innpid' : this.tmpmsg = jslang.profile_innpid;	this.focuser = 'npid';	break;
				case 'unnpid' : this.tmpmsg = jslang.profile_unnpid;	this.focuser = 'rpid';	break;
				case 'email'  : this.tmpmsg = jslang.profile_inemail;	this.focuser = 'email';	break;
				case 'unbbsuid' : this.tmpmsg = jslang.profile_unbbsuid;	this.focuser = 'forumuser';	break;
				case 'unbbspwd'  : this.tmpmsg = jslang.profile_unbbspwd;	this.focuser = 'forumpass';	break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser != ''){
					eval('theform.' + this.focuser + '.focus()');
				}
				if (theform.Submit.disabled){
					theform.Submit.disabled = false;
				}
			}
		}else{
			theform.Submit.disabled = true;
		}
	}
	this.users = function(results){
		var theform = document.wane_user;
		if (results){
			this.tmpmsg = '';
			switch (results){
				case 'uuid' : this.tmpmsg = jslang.login_nouid; break;
				case 'umid' : this.tmpmsg = jslang.login_nomid; break;
				case 'upid' : this.tmpmsg = jslang.login_nopid; break;
				case 'ruid' : this.tmpmsg = jslang.login_ruid; break;
				case 'rmid' : this.tmpmsg = jslang.login_rmid; break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (theform.Submit.disabled){
					theform.Submit.disabled = false;
				}
			}
		}else{
			theform.Submit.disabled = true;
		}
	}
	this.domain = function(results){
		var theform = document.wane_domain;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'nodomain'  : this.tmpmsg = jslang.domain_nodomain;	this.focuser = 'url'; 		break;
				case 'indomain'  : this.tmpmsg = jslang.domain_indomain;	this.focuser = 'url'; 		break;
				case 'notitle' 	 : this.tmpmsg = jslang.domain_notitle;		this.focuser = 'webtitle'; 	break;
				case 'maxdomain' : this.tmpmsg = jslang.domain_maxdomain;								break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser != ''){
					eval('theform.' + this.focuser + '.focus()');
				}
				if (theform.Submit.disabled){
					theform.Submit.disabled = false;
				}
			}
		}else{
			theform.Submit.disabled = true;
		}
	}
	this.downs = function(results){
		var theform = document.wane_downs;
		if (results){
			this.tmpmsg = '';
			switch (results){
				case 'nodomain' : this.tmpmsg = jslang.domain_nodomain; break;
				case 'indomain' : this.tmpmsg = jslang.domain_indomain; break;
				case 'notitle' : this.tmpmsg = jslang.domain_notitle; break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (theform.Submit.disabled){
					theform.Submit.disabled = false;
				}
			}
		}else{
			theform.Submit.disabled = true;
		}
	}
	this.download = function(results){
		if (results){
			this.tmpmsg = '';
			this.evaler = '';
			switch (results){
				case 'unlogin'	: this.tmpmsg = jslang.download_unlogin;	this.evaler = 'window.location = "merchant.html"'; break;
				case 'unexists'	: this.tmpmsg = jslang.download_unexists;	break;
				case 'noaccess'	: this.tmpmsg = jslang.download_noaccess;	break;
				case 'nosource'	: this.tmpmsg = jslang.download_nosource;	break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.evaler != ''){
					eval(this.evaler);
				}
			}
		}
	}
	this.collapsed = function(id){
		if ($(id)){
			$(id).style.display = $(id).style.display == 'none' ? '' : 'none';
		}
	}
	this.alipayer = function(results,url){
		var theform = document.wane_payer;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'inmid'	: this.tmpmsg = jslang.payer_inmid;		break;
				case 'inuid'	: this.tmpmsg = jslang.payer_inuid;		this.focuser = 'username';	break;
				case 'inpid'	: this.tmpmsg = jslang.payer_inpid;		this.focuser = 'password';	break;
				case 'impid'	: this.tmpmsg = jslang.payer_impid;		this.focuser = 'repasswd';	break;
				case 'inemail'	: this.tmpmsg = jslang.payer_inemail;	this.focuser = 'email';		break;
				case 'remail'	: this.tmpmsg = jslang.payer_remail;	this.focuser = 'email';		break;
				case 'location'	:	window.location = url;				break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser != ''){
					eval('theform.' + this.focuser + '.focus()');
				}
			}
		}
	}
	this.location = function(url){
		window.location = url;
	}
}
merchant = new mymerchant();
