function check_contact_author(a){
	var regexp=new RegExp("^[(\\w)-_\.]{1,}@+(\\w){1,}\.+(\\w){2,}");
	if(a.subject.value.length<1){
	alert("Please input a subject.");
	a.subject.focus();
	return false;
	}
	if(a.message.value.length<1){
	alert("Please input your message.");
	a.message.focus();
	return false;
	}
	if(a.name.value.length<1){
	alert("Please input your name.");
	a.name.focus();
	return false;
	}
	if((a.email.value.length<1)||(!regexp.test(a.email.value))){
	window.alert("Please input a valid email address.")
	a.email.focus();
	return false;
	}
	if(a.img_code.value.length!=4){
	window.alert("Please read the digital number in the image.");
	a.img_code.focus();
	return false;
	}
}

function check_contact_us(a){
	var regexp=new RegExp("^[(\\w)-_\.]{1,}@+(\\w){1,}\.+(\\w){2,}");
	if(a.subject.value.length<1){
	alert("Please input a subject.");
	a.subject.focus();
	return false;
	}
	if(a.message.value.length<1){
	alert("Please input your message.");
	a.message.focus();
	return false;
	}
	if(a.name.value.length<1){
	alert("Please input your name.");
	a.name.focus();
	return false;
	}
	if((a.email.value.length<1)||(!regexp.test(a.email.value))){
	window.alert("Please input a valid email address.")
	a.email.focus();
	return false;
	}
	if(a.img_code.value.length!=4){
	window.alert("Please read the digital number in the image.");
	a.img_code.focus();
	return false;
	}
}
function check_report_spam(a){
	if((!a.cat[0].checked)&&(!a.cat[1].checked)&&(!a.cat[2].checked)){
	window.alert("Please choose an item.");
	return false;
	}
	if(a.img_code.value.length!=4){
	window.alert("Please read the number in the image.");
	a.img_code.focus();
	return false;
	}
	var regexp=new RegExp("^[(\\w)-_\.]{1,}@+(\\w){1,}\.+(\\w){2,}");
	if((a.email.value.length<1)||(!regexp.test(a.email.value))){
	window.alert("Please input the valid email address of your own.");
	a.email.focus();
	return false;
	}
}
function check_send_friend(a){
	var regexp=new RegExp("^[(\\w)-_\.]{1,}@+(\\w){1,}\.+(\\w){2,}");
	if(a.col_name.value.length<1){
	window.alert("Please input the name of your friend.");
	a.col_name.focus();
	return false;
	}
	if((a.col_email.value.length<1)||(!regexp.test(a.col_email.value))){
	window.alert("Please input a valid email address of your friend.");
	a.col_email.focus();
	return false;
	}
	if(a.name.value.length<1){
	window.alert("Please input your own name.");
	a.name.focus();
	return false;
	}
	if((a.email.value.length<1)||(!regexp.test(a.email.value))){
	window.alert("Please input the valid email address of your own.");
	a.email.focus();
	return false;
	}
	if(a.img_code.value.length!=4){
	window.alert("Please read the number in the image.");
	a.img_code.focus();
	return false;
	}
}



//the news----
function loading(pic0, pic1){
	if ( pic1 ){
		if ( pic1.complete ){
			pic0.style.display='none';
			pic1.style.display='inline';
			pwidth=pic1.clientWidth;
			pheight=pic1.clientHeight;
			pic1.className = 'p_full';
			changeme(pic1);
			clearInterval( going );
			return true;
		}
	}
	return false;
}
function changeme( p ){
	if ( pwidth<=400 && pheight<=100 ){
		return false;
	}
	if ( p.className=="p_resized" ){
		p.className = "p_full";
		p.style.width=pwidth + 'px';
		p.style.Height=pheight + 'px';
	} else {
		p.className = "p_resized";
		x=pwidth/400;
		y=pheight/100;
		if ( x>y ){
			p.style.width='400px';
			p.style.Height= Math.ceil( pheight * 400 / pwidth) + 'px';
		} else {
			p.style.Height='100px';
			p.style.width= Math.ceil( pwidth * 100 / pheight) + 'px';
		}
	}
}
function check_comment(a){
	var regexp=new RegExp("^[(\\w)-_\.]{1,}@+(\\w){1,}\.+(\\w){2,}");
	if(a.title.value.length<10) {
	window.alert("Please input a valid title. No less than 10 characters.");
	a.title.focus();
	return false;
	}
	if(a.message.value.length<30){
		window.alert("Please input a meaningful message.  No less than 30 characters.")
		a.message.focus();
		return false;
	}
	if(a.message.value.length>500){
		window.alert("Please input a meaningful message.  No more than 500 characters.")
		a.message.focus();
		return false;
	}	
	if(a.name.value.length<1){
		window.alert("Please input your name.")
		a.name.focus();
		return false;
	}
	if(!a.email.value || !regexp.test(a.email.value)){
		window.alert("Please input a valid email address.")
		a.email.focus();
		return false;
	}
	if(a.img_code.value.length!=4){
		window.alert("Please read the number in the image.");
		a.img_code.focus();
		return false;
	}
	return true;
}
//the news

function check_subscribe(a){
	var regexp=new RegExp("^[(\\w)-_\.]{1,}@+(\\w){1,}\.+(\\w){2,}");
	if((a.email.value.length<1)||(!regexp.test(a.email.value))){
	window.alert("Please input a valid email address.");
	a.email.focus();
	return false;
	}
	if(a.username.value.length<1){
	window.alert("Please input your name.");
	a.username.focus();
	return false;
	}
	return true;
}
//press release
function check_press_release(a,t){
	if ( t=='p' ){
		limit = 10000;
	} else {
		limit = 3000;
	}
	var regexp=new RegExp("^[(\\w)-_\.]{1,}@+(\\w){1,}\.+(\\w){2,}");
	if(a.headline.value.length<20 || a.headline.value==press_guide_title){
		window.alert("Please input your headline. 20 characters at least.");
		a.headline.focus();
		return false;
	}
	if(a.summary.value.length<50 || a.summary.value==press_guide_summary){
		window.alert("Please input a valid summary of your news. 50 characters at least.");
		a.summary.focus();
		return false;
	}
	if(a.newsbody.value.length<1000 || a.newsbody.value==press_guide_body){
		window.alert("Please input your news body. 1000 characters at least.");
		a.newsbody.focus();
		return false;
	} else if(a.newsbody.value.length>limit){
		window.alert("Please keep your news body shorter than " +limit+ " characters.");
		a.newsbody.focus();
		return false;
	}
	if(a.industry.value == "--------"){
		window.alert("Please select an industry.");
		a.industry.focus();
		return false;
	}
	if(a.country.value == "--------"){
		window.alert("Please choose a country.");
		a.country.focus();
		return false;
	}
	if(a.author_name.value.length<1){
		 window.alert("Please input your name / publisher name.");
		 a.author_name.focus();
		 return false;
	}
	if((a.email.value.length<1)||(!regexp.test(a.email.value))){
		 window.alert("Please input a valid email address.");
		 a.email.focus();
		 return false;
	}
	if ( a.img_code ){
		if(a.img_code.value.length<1){
			window.alert("Please read the number in the image.");
			a.img_code.focus();
			return false;
		}
	}
	return true;
}

function preview( t ){
	if ( check_press_release( document.getElementById("form1"), t ) ){
		document.getElementById("preview").style.display = "block";
		document.getElementById("industry").style.display = "none";
		document.getElementById("country").style.display = "none";
		preview_data();
	}
}
function close_preview(){
	document.getElementById("preview").style.display = "none";
	document.getElementById("industry").style.display = "inline";
	document.getElementById("country").style.display = "inline";
}
function preview_data(){
	document.getElementById("headline1").innerHTML = '';
	document.getElementById("headline1").appendChild(document.createTextNode(document.getElementById("headline").value));
	document.getElementById("summary1").innerHTML = '';
	document.getElementById("summary1").appendChild(document.createTextNode( '" ' + document.getElementById("summary").value + ' "'));
	document.getElementById("author_name1").innerHTML = '';
	document.getElementById("author_name1").appendChild(document.createTextNode("by "+document.getElementById("author_name").value));
	document.getElementById("newsbody1").innerHTML =style_replace(newline(document.getElementById("newsbody").value));
	if(document.getElementById("keywords").value=='keyword1,keyword2' || document.getElementById("keywords").value==''){
		document.getElementById("keywords1").innerHTML ='Keyword: -';
	}else{
		document.getElementById("keywords1").innerHTML ='';
		document.getElementById("keywords1").appendChild(document.createTextNode("Keyword: "+document.getElementById("keywords").value));
	}
	if ( document.getElementById("other_info").value ){
		 document.getElementById("other_info1").innerHTML = newline("For more info:\n" +document.getElementById("other_info").value );
	}
	document.getElementById("website1").innerHTML = '';
	if ( document.getElementById("website").value!='' && document.getElementById("website").value!='http://' ){
		document.getElementById("website1").innerHTML = 'Website: ' + document.getElementById("website").value;
	}
	document.getElementById("picture1").innerHTML = '';
	if ( document.getElementById("picture").value!='' && document.getElementById("picture").value!='http://' ){
		document.getElementById("picture1").innerHTML = 'Attachement:<br><iframe width="300" height="100" src="' +document.getElementById("picture").value+ '" frameborder="1"></iframe>';
	}
}
function newline(a){
	var b = /\n/g;
	a = a.replace(/&/g,"&amp;");
	a = a.replace(/</g,"&lt;");
	a = a.replace(/>/g,"&gt;");
	return a.replace(b,"<br>");
}
//free press release<--
function load_sys(){
	var pic = document.getElementById("sysimg");
	r = Math.random();
	pic.src = '/inc/sysimg.php?' + r;
}
function style_replace(str,customized){ 
    str = str.replace(/\[B\]/gi, "<b>"); 
    str = str.replace(/\[\/B\]/gi, "</b>"); 
    str = str.replace(/\[I\]/gi, "<i>"); 
    str = str.replace(/\[\/I\]/gi, "</i>"); 
    str = str.replace(/\[\/COLOR\]/gi, "</span>"); 
	str = str.replace(/\[\/LARGE\]/gi, "</span>"); 
	str = str.replace(/\[COLOR=(.{3,7})\]/gi, "<span style='color:\$1'>"); 
	str = str.replace(/\[LARGE\]/gi, "<span style='font-weight:bold;font-size:16px'>");
	if(customized=="customized"){
		str = str.replace(/\[LINK=(.{0,255}?)\]/gi, "<a href='$1'>");
		str = str.replace(/\[\/LINK\]/gi, "</a>");
	}
    return str; 
}
function change_pic(){
	load_sys();
	document.getElementById('img_code').value='';
	document.getElementById('img_code').focus();
}
function news_adm(id,adult){
	document.writeln('<div id="'+id+'" style="right:0px;padding:7px 15px; color:#000;font:13px000; background-color:#D4E1F7; position:absolute; -moz-opacity:0.85;filter:alpha(opacity=85);z-index:99; display:none">'+
			'<img src="/img/delete.gif" style="vertical-align:middle" /> <a href="/_manage_/member-manage/perform.php?id='+id+'&o=delete" id="adm_del_'+id+'" target="perform" style="color:#000;font:13px">删除新闻</a>&nbsp;&nbsp;&nbsp;&nbsp;'+
			'<img src="/img/wh.gif"/> <a href="/_manage_/member-manage/perform.php?id='+id+'&o=ding" id="adm_journal_'+id+'" target="perform" style="color:#000;font:13px">推荐到本期journal</a>&nbsp;&nbsp;&nbsp;&nbsp;');
	if(adult){
		document.writeln('<img src="/img/report.gif" id="img_adult_'+id+'"/> <a href="/_manage_/member-manage/perform.php?id='+id+'&o=common" id="adm_adult_'+id+'"  target="perform"  style="color:#000;font:13px">标记为普通内容</a>');	
	}else{
		document.writeln('<img src="/img/tick.gif" id="img_adult_'+id+'"/> <a href="/_manage_/member-manage/perform.php?id='+id+'&o=adult" id="adm_adult_'+id+'" target="perform"  style="color:#000;font:13px">标记为成人内容</a>');
	}
	document.writeln('<iframe frameborder="0" name="perform" id="perform" style="display:none"></iframe></div>');
}
function tab_change(show,all_tab){
	for(i=0;i<all_tab.length;i++){
		document.getElementById(all_tab[i]).className='';
		document.getElementById(all_tab[i]+"_c").style.display='none';
	}
	document.getElementById(show).className='on';
	document.getElementById(show+"_c").style.display='block';
	return false;
}