/**
 * Current parameter list
 * a = search term.  Ex: ipad
 * b = site to restrict search to. Ex: business.maktoob.com
 * c = html iframe width
 * d = html iframe height
 * e = refined search path within the domain sent Ex: business.maktoob.com/stocks
 * f = additional parameters
 */

var search=function(a,b,c,d,e,f){
    try{

        term = a.replace(/[&#"']/g," ");

        //trim resulting string
        term = term.replace(/^\s+|\s+$/g, "");

        var divWidth = 620;
        var divHeight = 1050;
        var parentPadding = 20;
        var refinedPath = "";
	var additionalParams = "";
	
        if(c!==undefined){
            
            //YThe -parentPadding is the added padding on the content on the results page
            divWidth = parseInt(c,10) - parentPadding;

            if(d!==undefined){
                divHeight = parseInt(d,10);

                if(e!==undefined){
                    refinedPath = e;

		    if(f!==undefined){
			additionalParams = f;
		    }
                }
            }
        }

        var frameDiv = document.getElementById("searchResultDiv");

        //dont make request on empty string
        if(term.length>0){

            var iframe=document.getElementById("searchResultFrame");

            if(!iframe){

                iframe=document.createElement("IFRAME");
                iframe.frameBorder = 0;
                iframe.setAttribute("bordercolor","#FFFFFF");
                iframe.setAttribute("scrolling","no");
                iframe.setAttribute("id","searchResultFrame");
                iframe.style.width=(divWidth + parentPadding)+"px";
                iframe.style.height=divHeight+"px";
                frameDiv.style.textAlign = "right";
                frameDiv.appendChild(iframe);
            }

            iframe.setAttribute("src","http://s.yb.search.maktoob.com/central/results.php?p="+term+"&site="+b+"&wi="+divWidth+"&dir="+refinedPath+"&ap="+encodeURIComponent(additionalParams));
        }
    }
    catch(error){}
};



