function searchResultLoad(){
    addLineUnderComments();
}

function search(objName) {
	var mysearchbox=document.getElementById(objName);
	if (mysearchbox.value!='') {
		var a=mysearchbox.value;
		a=escape(escape(a.replace(/\s+/g, "+")));
		a=a.replace(/\+/g, "%2B");
		document.location='/subject/'+a;
	} else {
		document.location='/';
	}
}

function showmyimg(id,name) {
	if (name!='') {
		var imgdiv=document.getElementById('prodlist'+id);
		if (imgdiv) {
			imgdiv.style.display='block';
			imgdiv.innerHTML='<img src="'+name+'"  />';
		}
	}
}
function hidemyimg(id) {
	var imgdiv=document.getElementById('prodlist'+id);
	if(imgdiv){
		imgdiv.style.display='none';
	}
}

function SetCookie (name, value)
{
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

function GetCookie (name) 
{
    var arg = name + "=";
    var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return null;
}

function getCookieVal (offset)
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function installOpensearch(src, obj){
    window.external.AddSearchProvider(src);
    SetCookie('INS_OPENSEARCH', 1, null, '/');
    if (obj.parentNode.parentNode.className == "underYahoo"){
        obj.parentNode.parentNode.previousSibling.className="imagesYahoo";
    }
    obj.parentNode.parentNode.style.display = 'none';
}

function showOpenSearch(){
    if (GetCookie('INS_OPENSEARCH') != 1) {
        if (tsk.browser.msie && tsk.browser.version >= 7) {
            document.getElementById('msie_os').className = "toolbarBox";
        } else if (tsk.browser.mozilla) {
            document.getElementById('mozilla_os').className = "toolbarBox";
        }
    }
}

function setFocus(objId){
    document.getElementById(objId).focus();
}

function addLineUnderComments(){
    var cmt = document.getElementById("commentSubmit");
    if (!cmt) return;
    var i = 0;
    while ((cmt.nextSibling != null) &&(cmt.nextSibling.nodeName != "DIV") && (i<5)) {
        cmt = cmt.nextSibling;
        i += 1;
    }
    if ((cmt.nextSibling != null) && (cmt.nextSibling.className == "webResult_tit")) {
        var cmt = document.getElementById("commentSubmit");
        cmt.style.marginBottom = "15px";
        cmt.className = cmt.className + " bordBottom";
    }
}

/* base64 decode */
function decode64(input) {
   var keyStr = "ABCDEFGHIJKLMNOP" +
                "QRSTUVWXYZabcdef" +
                "ghijklmnopqrstuv" +
                "wxyz0123456789+/" +
                "=";
   var output = "";
   var chr1, chr2, chr3 = "";
   var enc1, enc2, enc3, enc4 = "";
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   var base64test = /[^A-Za-z0-9\+\/\=]/g;
   if (base64test.exec(input)) {
      alert("There were invalid base64 characters in the input text.\n" +
            "Valid base64 characters are A-Z, a-z, 0-9, '+', '/', and '='\n" +
            "Expect errors in decoding.");
   }
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }

      chr1 = chr2 = chr3 = "";
      enc1 = enc2 = enc3 = enc4 = "";

   } while (i < input.length);

   return unescape(output);
}
/* base64*/

var userAgent = navigator.userAgent.toLowerCase();
var tsk = new Object;
tsk.browser = {
    version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
    safari: /webkit/.test( userAgent ),
    opera: /opera/.test( userAgent ),
    msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
    mozilla: /mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)
};