﻿//show search
function GotoSearch()
{
	
//alert(window.document.getElementById("search_content").getAttribute("value"));
if(document.getElementById("search_content").value=="" || document.getElementById("search_content").value=="Search..")
alert("搜索内容不能为空！");
else
    window.location.href="http://s.01w.com/s/index.html?q="+escape(document.getElementById("search_content").value); //临时搜索地址

return false;
}
function newGotoSearch()
{
//alert(window.document.getElementById("search_content").getAttribute("value"));
if(document.getElementById("search_content").value=="" || document.getElementById("search_content").value=="Search..")
alert("搜索内容不能为空！");
else
window.location.href="http://s.01w.com/s/s_list.html?q="+escape(document.getElementById("search_content").value); 

return false;
}


function ClearWord()
{
    if(document.getElementById("search_content").value=="Search..")
    {
        window.document.getElementById("search_content").setAttribute("value","");
    }
    else
    {
         document.getElementById("search_content").select();
    }
    
}

function UTF8UrlEncode(input)
{
	var output = "";
	var currentChar = '';
	
	for(var counter = 0; counter < input.length; counter++) 
	{
		currentChar = input.charCodeAt(counter);
		
		if((48 <= currentChar) && (currentChar <= 57))
			output = output + input.charAt(counter);
		else if((65 <= currentChar) && (currentChar <= 90))
			output = output + input.charAt(counter);
		else if((97 <= currentChar) && (currentChar <= 122))
			output = output + input.charAt(counter);
		else
			output =  output + UTF8UrlEncodeChar(currentChar); 
	}
	return output;
}

function UTF8UrlEncodeChar(input)
{
	if(input <= 0x7F) return "%" + input.toString(16);

	var leadByte = 0xFF80; var hexString = ""; var leadByteSpace = 5;
	while(input > (Math.pow(2, leadByteSpace + 1) - 1))
	{
		hexString = "%" + ((input & 0x3F) | 0x80).toString(16) + hexString;
		leadByte = (leadByte >> 1);
		leadByteSpace--;
		input = input >> 6;
	} 
	return ("%" + (input | (leadByte & 0xFF)).toString(16) + hexString).toUpperCase();

}

