﻿//改变正文文字大小
function chg_FontSize(obj,size,isAuto){
	conObj = document.getElementById(obj);
	conObj.style.fontSize = size + "px";
}

// 打印页面
function doPrint(obj){
	var str='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'+
	        '<html xmlns="http://www.w3.org/1999/xhtml">\n'+	
	        '<head>\n'+
	        '<meta http-equiv="content-type" content="text/html; charset=gb2312">\n'+
	        '<title>'+document.title+'</title>\n'+
	        '<style>\n'+
	        'body{font-family:"宋体";}\n'+
	        'td {font-size:14px;line-height:1.8em;}\n'+
	        '.title {font-size:24px;font-weight:bold;line-height:1.6em}\n'+
            '</style>\n'+
	        '</head>\n'+
	        '<body bgcolor="#ffffff" topmargin="5" leftmargin="5" marginheight="5" marginwidth="5" onload="window.print()">\n'+
	        '<table width="600" align="center" border="0" cellspacing="0" cellpadding="0">\n'+
	        '<tr>\n'+
	        '<td height="34" width="150">\n'+
	        '<td align="right" valign="bottom"><a href="javascript:history.back()">返回</a>　<a href="javascript:window.print()">打印</a></td>\n'+
	        '</tr>\n'+
	        '</table>\n'+
	        '<table width="600" align="center" border="0" cellpadding="0" cellspacing="0">\n'+
	        '<tr>\n'+
	        '<td>\n'+
            '<div align="center" class="title">' + document.title.split(' _ ')[0] + '</div><br>'+ document.getElementById(obj).innerHTML +
	        '</td>\n'+
	        '</tr>\n'+
	        '</table>\n'+ window.location.href +
	        '</body>\n'+
	        '</html>';
	var OpenWindow=window.open("","PrintWin");
	OpenWindow.document.write(str);
	OpenWindow.document.close();
}

function AddFavor(url, title) {
    if(url && title){
        try {
            window.external.addFavorite(url, title);  
        }catch (e){  
            try{  
                window.sidebar.addPanel(title, url, "");  
            }catch (e) {
			    alert("加入收藏失败，请使用Ctrl+D进行添加");  
            }  
        }
    }else{
        try {
            window.external.addFavorite(window.location.href, window.document.title);  
        }catch (e){  
            try{  
                window.sidebar.addPanel(window.document.title, window.location, "");  
            }catch (e) {
			    alert("加入收藏失败，请使用Ctrl+D进行添加");  
            }  
        }
    }
}  

// 设为首页
function SetHome(obj, url){ //obj:this 
	try{  
		obj.style.behavior='url(#default#homepage)';
		if(url) obj.setHomePage(url);
		else obj.setHomePage(window.location);
	}catch(e){  
		if(window.netscape) {  
			try {  
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
			}catch (e){  
				alert("此操作被浏览器拒绝！请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'");  
			}  
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);  
			if(url) prefs.setCharPref('browser.startup.homepage',url);
			else prefs.setCharPref('browser.startup.homepage',window.location); 
		 }  
	}
}

function guest() {
    var form=document.getElementById("form");
    var titles = document.getElementById ("titles").value ;
    var content = document.getElementById ("content1").value;
    var name = document.getElementById("name").value ;
    var phone = document.getElementById("tel").value ;
    var address = document.getElementById("address").value ;
    var email = document.getElementById("email").value ;
    var isEmail="a";

    var isSubmit=true;
     if ((isNull(titles ))||(isNull (content ))||(isNull (name ))||(isNull (email )))
    {
    isSubmit =false;
    alert ("输入的信息不能为空！");
    return isSubmit ;
    } 

    if(isSubmit)
    {
        form.action = "Backstage/";
    }
}

function search() {
    var search = document.getElementById("searchtext").value;
    if (search == "关键字/产品代码" || search == "") {
        alert("输入的信息不能为空！");
        return false;
    }
}
//判断提交的输入的验证信息
function isRegex(strText,strRegex)
{
	strClassRegex=strRegex
	if (strText=="")
	{
	      return false;
	}
	else
	{
	    if (!strClassRegex.exec(strText))
	    {
	         return false 
	    }
	    else 
	    {
	     	return true
	    }
	} 
}


function isNull(text) {
    if (text.length == 0) {
        return true;
    }
}


function clearDefault(e) {
    e.value = '';
}
