function getQueryStringValue(name) {
	var url = document.location.href;	
	var queryString = "";	
	var questionMarkIndex = url.indexOf("?");	
	if(questionMarkIndex > 0) {
		queryString = url.substring(questionMarkIndex+1, url.length);				
		var nameValues = queryString.split('&');		
		for(i=0; i<nameValues.length; i++) {
			if(nameValues[i].substring(0, name.length) == name) {
			    var lengthOfName = name.length + 1;     //and '=' sign
			    var lengthOfValue = nameValues[i].length - lengthOfName;	
			    var value = nameValues[i].substring(lengthOfName, lengthOfName + lengthOfValue);
			    return cleanUpString(value);
			}
		}
	}
	return "";		
}

function setQuestionValue() {
    var question = getQueryStringValue('question');
    if(question.length > 0) {
        
        for(i=0;i<document.forms[0].elements.length;i++) {
            var item = document.forms[0].elements[i];

            if(item.id.indexOf('Question') > 0) {
                if(item.value.length == 0) {
                    item.value = question;
                }
            }
        }        
    }
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
        if (oldonload) {
            oldonload();
        }
        func();
        }
    }
}

function cleanUpString(inputStr) {
    var s = new String(inputStr);
    s = s.replace(/%20/g," ");
    s = s.replace(/\+/g," ");
    s = s.replace(/\+/g," ");
    s = s.replace(/\%0d%0a/gi, "\n");
    s = s.replace(/\%27/g,"'");
    return s
}