﻿function chkForm(obj)//搜索框判断函数
{
	if(obj.q.value == "" || obj.q.value == "请输入关键词")
	{
		alert("请输入关键词搜索！");
		obj.q.focus();
		return false;
	}
}


function swf(src, w, h) //运行swf函数
{
	html = '';
	html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" WIDTH="'+w+'" HEIGHT="'+h+'">';
	html += '<PARAM NAME=movie VALUE="'+src+'">';
	html += '<PARAM NAME=quality VALUE=high>';
	html += '<PARAM NAME="wmode" value="transparent" />';
	html += '<EMBED src="'+src+'" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent"  WIDTH="'+w+'"  HEIGHT="'+h+'" ></EMBED>';
	html += '</OBJECT>';
	document.write(html);
}

function clearText(field)//搜索框聚焦
{
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}

function AddFavorite(sURL, sTitle) {   
    try {   
        window.external.addFavorite(sURL, sTitle);   
    } catch (e) {   
        try {   
            window.sidebar.addPanel(sTitle, sURL, "");   
        } catch (e) {   
            alert("加入收藏失败，请使用Ctrl+D进行添加");   
        }   
    }   
}   
/**   
 *    
 * @param {} obj 当前对象，一般是使用this引用。   
 * @param {} vrl 主页URL   
 */   
function SetHome(obj, vrl) {   
    try {   
        obj.style.behavior = 'url(#default#homepage)';   
        obj.setHomePage(vrl);   
    } 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', vrl);   
        }   
    }   
}

function ShowLang()
{
	document.getElementById("showlang").style.display = '';
}

function HidLang()
{
	document.getElementById("showlang").style.display = 'none';
}

function formatPic(imgElem)
{
	csswidth = imgElem.width;
	cssheight = imgElem.height;
	var localImg = new Image();
	remoteUrl = imgElem.src;
	localImg.src = remoteUrl;
	
	if(localImg.width*cssheight - localImg.height*csswidth > 0)
	{
		imgElem.width = csswidth;
		imgElem.height = localImg.height*csswidth/localImg.width;
		imgElem.style.paddingTop = (cssheight - imgElem.height)/2 + 2 + "px";
		imgElem.style.paddingBottom = (cssheight - imgElem.height)/2 + 2 + "px";
		imgElem.style.paddingLeft = 2 + "px";
		imgElem.style.paddingRight = 2 + "px";
	}
	else
	{
		imgElem.height = cssheight;
		imgElem.width = localImg.width*cssheight/localImg.height;
		imgElem.style.paddingTop = 2 + "px";
		imgElem.style.paddingBottom = 2 + "px";
		imgElem.style.paddingLeft = (csswidth - imgElem.width)/2 + 2 + "px";
		imgElem.style.paddingRight = (csswidth - imgElem.width)/2 + 2 + "px";
		
	}	
}

//成功案例浏览效果
var num = 1;
var picArr = new Array(100);
var titleArr = new Array(100);


function showPic(n)
{
	document.getElementById('nowpic').src = picArr[n];
	document.getElementById('nowpic').alt = titleArr[n];
	document.getElementById('nowtitle').innerHTML = titleArr[n];
	document.getElementById('num').innerText = n;
	num = n;
}

function showLast()
{
	if(num > 1)
	{
		num = num - 1;
		setTimeout(function(){showPic(num);},100);
	}
}

function showNext()
{
	if(num < picnum)
	{
		num = num + 1;
		setTimeout(function(){showPic(num);},100);
	}
}

function showN()
{
		num = num + 1;
		if(num > 10)num = 1;
		setTimeout(function(){showPic(num);},100);
	setTimeout(function(){showN();},3000);
}
//-->
