function showDialog(str){
alert(str);
if(str=="true"){
window.showModalDialog('/help/protocol.jsp','','');

}
}
function inputNameLose(nameValue){
	var name = document.getElementById("username");
	 if(name.value==""||name.value.length==0){
	 	name.value = nameValue;
	 }
}

function inputPasswordLose(country){
	var password = document.getElementById("password");
	//将来需要在这里填更多的国际化配置
	if(country=="US"){
		if(password.value.length>0){
			//password.style.background = "url('/help/images/usshousuotiao1.png') left no-repeat";
		}else{
			//password.style.background = "url('/help/images/usshousuotiao.png') left no-repeat";
		}
	}
	if(country=="CN"){
		if(password.value.length>0){
			//password.style.background = "url('/help/images/cnshousuotiao1.png') left no-repeat";
		}else{
			//password.style.background = "url('/help/images/cnshousuotiao.png') left no-repeat";
		}
		
	}
	if(country=="null"||""==country||country==null){
		if(password.value.length>0){
			//password.style.background = "url('/help/images/cnshousuotiao1.png') left no-repeat";
		}else{
			//password.style.background = "url('/help/images/cnshousuotiao.png') left no-repeat";
		}
	}
	//if(password.value==""||password.value.length==0){
	// 	password.value = passwordValue;
	// }
}
function reback(value,id){
	//alert(id);
	var password = document.getElementById(id);
	 //alert(password);
	
	if(password.value==""||password.value.length==0){
	 	password.value = value;
	 	 password.style.color = "gray";
	 }
}

function SetHome(obj){
 		var pageURL = "http://www.doernet.com";
        try{ 
               obj.style.behavior='url(#default#homepage)';obj.setHomePage(pageURL); 
                obj.setHomePage(pageURL); 
                
        }catch(e){ 
                if(window.netscape) { 
                        try{ 
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                        }catch (e) { 
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。"); 
                        } 
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
                        prefs.setCharPref('browser.startup.homepage',pageURL); 
                        
                 } 
        } 
        // alert("操作已成功!");
} 


function hand(obj){
obj.style.cursor = "hand";
}
function nohand(obj){
obj.style.cursor = "";
}
function keyboard(key,illegal,e){
var ev = e.keyCode;
if(ev==13){
	checkSubmit(key,illegal);
}

}

function checkSubmit(key,illegal){
//alert("1.agencies,organlization,company!".length);
//alert("1.job,title,status!".length);

//alert("1.请在此输入！".length);
//alert("2.input username here please!".length);
//alert("2.organlization,company...".length);
var username = document.getElementById("username");
var password = document.getElementById("password");
	if(username.value.length==0&&password.value.length==0){
		alert(key);
		username.focus();
		return;
	}
	if(username.value.length==0&&password.value.length!=0){
		alert(key);
		username.focus();
		return;
	}
	if(username.value.length!=0&&password.value.length==0){
		alert(key);
		password.focus();
		return;
	}

if(username.value.indexOf("'")>=0||password.value.indexOf("'")>=0){
	alert(illegal);
	if(username.value.indexOf("'")>=0){
	    username.value="";
		username.focus();
	}
	if(password.value.indexOf("'")>=0||username.value.indexOf("'")<0){
		  password.value="";
			password.focus();
	}
  	 return;
}
	
	var mainform = document.getElementById("mainForm");
	mainform.method = "post";
	mainform.action = "/help/user/login.do";
	mainform.submit();
}
function addSpace(obj){
var user = "";
var username = document.getElementById("username");
for(var i = 0; i<username.value.length; i++){
 
 if(username.value.charAt(i)==" ") { 
  user = user;
  }else{  
  user+=username.value.charAt(i); 
  }   
}

if(user.length>0&&user.length<16){
	if(user.length%4==0){
      username.value+="  "; 
	}
}
}
function setCursor(){
	var username = document.getElementById("username");
	//alert("fdssss"+username.id);
	username.focus();	
}
function changeSch(obj){
 var submitbtn = document.getElementById("submitBtn");
if(obj.id=='password'){
var username = document.getElementById("username");
if(username.value.length>0){
		submitbtn.style.color = "#FF6699";
}else{
	submitbtn.style.color = "#000000";
}
}
if(obj.id=="username"){
var password = document.getElementById("password");
if(password.value.length>0){
		submitbtn.style.color = "#FF6699";
	}else{
	submitbtn.style.color = "#000000";
}
}

	//if(username.value.indexOf("1.")<0&&username.value.indexOf("！")<0){
		//submitbtn.value = "go";
	//	submitbtn.style.color = "red";
		//submitbtn.style.fontSize = "40px";
		//submitbtn.style.paddingTop = "2px";
		//submitbtn.style.paddingBottom = "7px";
		//submitbtn.style.textAlign = "left";
	//}
	
}
function tab(obj){
//var msgsDiv = document.getElementById("msgs");
//var msgsDiv1 = document.getElementById("msgs1");
//msgsDiv.style.visibility = "hidden";
//msgsDiv1.style.visibility="hidden";
if(obj.value.length==22){
		//obj.nextSibling.focus(); 
		document.getElementById("password").focus();  
		//window.event.charCode = 9;
		obj.style.color = "black";
		
		var password = document.getElementById("password");
		//password.style.background = "url('/help/images/hengtiao.jpg') left no-repeat";
		password.value = "";
		password.style.color = "red";
}
}
function toPasswrdType(obj){
obj.type="password";
}
function toNull(obj){//alert(obj.id);
var submitbtn = document.getElementById("submitBtn");
submitbtn.style.color = "#000000";
//var msgsDiv = document.getElementById("msgs");
//var msgsDiv1 = document.getElementById("msgs1");
//msgsDiv.style.visibility="hidden";
//msgsDiv.style.visibility = "hidden";
var username = document.getElementById("username");
var password = document.getElementById("password");
obj.value="";
obj.style.color = "red";
if(obj.id=="password"){
//obj.style.background = "url('/help/images/hengtiao.jpg') left no-repeat";

username.style.color = "black";
}
}
function toNull_1(obj){
obj.style.color = "#000000";
obj.value="";
//obj.style.background = "url('/help/images/hengtiao1.jpg') left no-repeat";
}


 function checkInquiry(obj,key,illegal){
	var Company = null;
	var Job = null;
	Company = obj.company.value;
	Job = obj.job.value;
	//alert("请输入机构、团体、公司或者单位名称...".length);
		alert("输入：地址 | 产品 | 品牌 | 服务......如：江北或牛肉".length);
	//	alert("job,title,status,brand,products,services...".length);
	//	alert("organlization,company...".length);
//如果都为默认提示信息，则提示信息，里面的数字时默认关键字的长度，因为国际化的原因，所以长度不同
	if(Company.length==0||Job.length==0){
	 	alert(key);
	return false;
	}
	//alert(Company.length+"------------"+Job.length);
	if(Company.length==19&&Job.length==29){
	if(Company.indexOf("...")>=0&&Job.indexOf("...")>=0){
 	alert(key);
	return false;
	}
	}
	if(Company.length==24&&Job.length==43){
	if(Company.indexOf("...")>=0&&Job.indexOf("...")>=0){
 	alert(key);
	return false;
	}
	}
	if(Company.indexOf("'")>=0||Job.indexOf("'")>=0||Company.indexOf("#")>=0||Job.indexOf("#")>=0){
 	alert(illegal);
	return false;
	}
	//如果为默认的字符，则将查询关键字设为null
	if(Company.length==24||Company.length==19){
		if(Company.indexOf("...")>=0){
		Company = null;
	}
	}
	if(Job.length==29||Job.length==43){
		if(Job.indexOf("...")>=0){

		Job = null;
	}
	}
		//下面去关键字的空格
	var ctemp = "";
	var jtemp = "";
	if(Company!=null){
	for(var i = 0;i<Company.length;i++){
	if(Company.charAt(i)==" "){
	ctemp = ctemp;
	}else{
	ctemp += Company.charAt(i);
	}
	}
	}
	if(Job!=null){
	for(var i = 0;i<Job.length;i++){
	if(Job.charAt(i)==" "){
	jtemp = jtemp;
	}else{
	jtemp += Job.charAt(i);
	}
	}
	}
	ctemp = encodeURI(ctemp);
	ctemp = encodeURI(ctemp);
	jtemp = encodeURI(jtemp);
	jtemp = encodeURI(jtemp);
	obj.method = "post";
	//alert("------ctemp---------"+ctemp+"-----jtemp-------"+jtemp);
	obj.action = "/help/help/ResultFrame.jsp?isCompany="+ctemp+"&isJob="+jtemp;
	//obj.submit();
}
function checkInquiry_1(obj,key,illegal){
	var Company = null;
	var Job = null;
	Company = obj.company.value;
	Job = obj.job.value;
	//alert("输入：机构 | 团体 | 公司 | 单位 | 店铺名称......如： 移动".length);
	//alert("输入：地址 | 产品 | 品牌 | 服务......如：江北或牛肉".length);
	//如果都为默认提示信息，则提示信息，里面的数字时默认关键字的长度，因为国际化的原因，所以长度不同
		if(Company.length==0||Job.length==0){
	 	alert(key);
	return false;
	}
	if(Company.length==19&&Job.length==29){
	if(Company.indexOf("...")>=0&&Job.indexOf("...")>=0){
 	alert(key);
	return false;
	}
	}
	if(Company.length==38&&Job.length==33){
	if(Company.indexOf("......")>=0&&Job.indexOf("......")>=0){
 	alert(key);
	return false;
	}
	}
	if(Company.indexOf("'")>=0||Job.indexOf("'")>=0||Company.indexOf("#")>=0||Job.indexOf("#")>=0){
 	alert(illegal);
	return false;
	}
	//如果为默认的字符，则将查询关键字设为null
	if(Company.length==38||Company.length==19){
		if(Company.indexOf("......")>=0){
		Company = null;
	}
	}
	if(Job.length==33||Job.length==38){
		if(Job.indexOf("......")>=0){

		Job = null;
	}
	}
		//下面去关键字的空格
	var ctemp = "";
	var jtemp = "";
	if(Company!=null){
	for(var i = 0;i<Company.length;i++){
	if(Company.charAt(i)==" "){
	ctemp = ctemp;
	}else{
	ctemp += Company.charAt(i);
	}
	}
	}
	if(Job!=null){
	for(var i = 0;i<Job.length;i++){
	if(Job.charAt(i)==" "){
	jtemp = jtemp;
	}else{
	jtemp += Job.charAt(i);
	}
	}
	}
	ctemp = encodeURI(ctemp);
	ctemp = encodeURI(ctemp);
	jtemp = encodeURI(jtemp);
	jtemp = encodeURI(jtemp);
	
	obj.method = "post";
	obj.target = "main_result";
	//alert("/help/toResult.do?isCompany="+ctemp+"&isJob="+jtemp);
	if(ctemp!=null&&ctemp!=""&&jtemp!=null&&jtemp!=""){
	obj.action = "/help/toResult.do?isCompany="+ctemp+"&isJob="+jtemp;
	}else{
	obj.action = "/help/toResult.do?isCompany="+(ctemp==""? "null":ctemp)+"&isJob="+(jtemp==""? "null":jtemp);
	
	}
	//obj.submit();
}

function whenBodyLoad(){
var broswer =navigator.userAgent.toString().toLowerCase();
//alert(broswer);
		if(broswer.indexOf("ie 6") > -1&&broswer.indexOf("msie 6") > -1){
		document.getElementById("company").style.width = "322px";
		document.getElementById("job").style.width = "322px";
		
		}
		if(broswer.indexOf("ie 7") > -1&&broswer.indexOf("msie 7") > -1){
		document.getElementById("company").style.width = "323px";
		document.getElementById("job").style.width = "324px";
		
		}
		if(broswer.indexOf("ie 8") > -1&&broswer.indexOf("msie 8") > -1){
		document.getElementById("company").style.width = "328px";
		document.getElementById("job").style.width = "328px";
		
		}
		if(broswer.indexOf("3.0.2 safari") > -1){
		document.getElementById("company").style.height = "15px";
		document.getElementById("job").style.height = "15px";
		
		}

}
/* From prototype.js */
document.getElementsByClassName = function(className) {
	var children = document.getElementsByTagName('*') || document.all;
	var elements = new Array();
  
	for (var i = 0; i < children.length; i++) {
		var child = children[i];
		var classNames = child.className.split(' ');
		for (var j = 0; j < classNames.length; j++) {
			if (classNames[j] == className) {
				elements.push(child);
				break;
			}
		}
	}
	return elements;
}

var Reflection = {
	defaultHeight : 0.5,//Ĭ��ͼƬ�ĸ�
	defaultOpacity: 0.5,//Ĭ��ͼƬ�Ŀ�
	
	add: function(image, options) {
		Reflection.remove(image);
		
		doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
		if (options) {
			for (var i in doptions) {
				if (!options[i]) {
					options[i] = doptions[i];
				}
			}
		} else {
			options = doptions;
		}

	
		try {
			var d = document.createElement('div');
			var p = image;
			
			var classes = p.className.split(' ');
			var newClasses = '';
			for (j=0;j<classes.length;j++) {
				if (classes[j] != "reflect") {
					if (newClasses) {
						newClasses += ' '
					}
					
					newClasses += classes[j];
				}
			}

			var reflectionHeight = Math.floor(p.height*options['height']);
			var divHeight = Math.floor(p.height*(1+options['height']));
			
			var reflectionWidth = p.width;
	
			/* Copy original image's classes & styles to div */
			d.className = newClasses;
			p.className = 'reflected';
			
			d.style.cssText = p.style.cssText;
			p.style.cssText = ' ';
			
			if (document.all && !window.opera) {
				var reflection = document.createElement('img');
				reflection.src = p.src;
				reflection.style.width = reflectionWidth+'px';
				
				reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
				reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';
				
				d.style.width = reflectionWidth+'px';
				d.style.height = divHeight+'px';
				p.parentNode.replaceChild(d, p);
				
				d.appendChild(p);
				d.appendChild(reflection);
			} else {
				var canvas = document.createElement('canvas');
				var context = canvas.getContext("2d");
			
				canvas.style.height = reflectionHeight+'px';
				canvas.style.width = reflectionWidth+'px';
				canvas.height = reflectionHeight;
				canvas.width = reflectionWidth;
				
				d.style.width = reflectionWidth+'px';
				d.style.height = divHeight+'px';
				p.parentNode.replaceChild(d, p);
				
				d.appendChild(p);
				d.appendChild(canvas);
				
				context.save();
				
				context.translate(0,image.height-1);
				context.scale(1,-1);
				
				context.drawImage(image, 0, 0, reflectionWidth, image.height);

				context.restore();
				
				context.globalCompositeOperation = "destination-out";
				var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);
				
				gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
				gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");
	
				context.fillStyle = gradient;
				if (navigator.appVersion.indexOf('WebKit') != -1) {
					context.fill();
				} else {
					context.fillRect(0, 0, reflectionWidth, reflectionHeight*2);
				}
			}
		} catch (e) {
	    }
	},
	
	remove : function(image) {
		if (image.className == "reflected") {
			image.className = image.parentNode.className;
			image.parentNode.parentNode.replaceChild(image, image.parentNode);
		}
	}
}

function addReflections() {
	var rimages = document.getElementsByClassName('reflect');
	for (i=0;i<rimages.length;i++) {
		var rheight = null;
		var ropacity = null;
		
		var classes = rimages[i].className.split(' ');
		for (j=0;j<classes.length;j++) {
			if (classes[j].indexOf("rheight") == 0) {
				var rheight = classes[j].substring(7)/100;
			} else if (classes[j].indexOf("ropacity") == 0) {
				var ropacity = classes[j].substring(8)/100;
			}
		}
		
		Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
	}
}

var previousOnload = window.onload;
window.onload = function () { //if(previousOnload) previousOnload(); addReflections(); 
}

/**********/
	
