/*
 submits a set of fields to a given page via query string.
 the function takes unlimited arguments. The first argument
 is the destination URL and all remaining arguments are IDs
 of form fields to append to the query string.
 */
function submitFields(){
	if(document.getElementById("searchType").value == "web"){
		window.location.href = "http://search.yahoo.com/search?fr=yscpb&p=" + document.getElementById("searchText").value
	}
	else{
		window.location.href = "/search?keywords=" + document.getElementById("searchText").value
	}    	
}

function changeFontSize(parent, direction){
    var parentElement = document.getElementById(parent);
    if (parentElement != null) {
        resizeFont(parentElement, "p", 1.0, 2, .8, direction);
        resizeFont(parentElement, "h1", 2.0, 3, 1.2, direction);
        resizeFont(parentElement, "h2", 1.2, 2.6, 1.0, direction);
    }
    
}

function resizeFont(parentElement, tag, defaultSize, maxSize, minSize, direction){
    var items = parentElement.getElementsByTagName(tag);
    // alert(items);
    for (i = 0; i < items.length; i++) {
        if (items[i].style.fontSize) {
            var s = parseFloat(items[i].style.fontSize.replace("em", ""));
        }
        else {
            var s = defaultSize
        }
        if ((s < maxSize) && (direction == "grow")) {
            s *= 1.1
        }
        if ((s > minSize) && (direction == "shrink")) {
            s *= 0.9;
        }
        items[i].style.fontSize = s + "em"
        
    }
    
}

// an empty function to capture events and do nothing with them
function nullFunction(){
}

function PrintPage(){
    window.print
}

function showhide(id){
    if (document.getElementById) {
        obj = document.getElementById(id);
        if (obj.style.display == "none") {
            obj.style.display = "";
        }
        else {
            obj.style.display = "none";
        }
    }
}

function poppoll(url, name, rs, w, h) {
  var resize = "resizable=no,";
  if (rs) {
    resize = "resizable=yes,";
  }
  popupWin = window.open(url, name, 'location=no,menubar=no,toolbar=no,scrollbars=no,status=no,' + resize + 'width=' + w + ',height=' + h);
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function createXMLHttpRequest()
{
    // activeX versions to check for in IE
    //var activeXs = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
    var activeXs = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
            
    //test if IE first (XMLHttpRequest in IE7 is broken)
    if (window.ActiveXObject) 
    { 
        for (var i=0; i < activeXs.length; i++) {
            try {
                //alert("Returning ActiveXObject " + activeXs[i]);
                return new ActiveXObject(activeXs[i]);
            } catch(e) {
                displaySliderContentError("<span class='text_size'>Can't create " + activeXs[i] + " Object</span>");
            }
        }
    }
    // Mozilla, Safari etc
    else if (window.XMLHttpRequest) {
        var request = new XMLHttpRequest();
        
        //Override the mime type returned by the server (if any)
        if(request.overrideMimeType) {
            request.overrideMimeType('text/xml');
            return request;
        }
    }
    else {
        displaySliderContentError("<span class='text_size'>Your browser does not support XMLHttpRequest</span>");
    }
    
    return null;
}


function launchpopup(url,target,showtoolbar,width,height)
{
	var newWindow = window.open(url,target,"width=" + width + ", height=" + height)
	if(newWindow.focus)
		newWindow.focus()
}

