String.prototype.trim = function(){return this.replace(/^\s+|\s+$/, '');};

String.prototype.queryStringToJSON = function () {
	href = this;
	qStr = href.replace(/(.*?\?)/, '');
	qArr = qStr.split('&');
	stack = {};
	for (var i in qArr) {
	    var a = qArr[i].split('=');
	    var name = a[0],
	        value = isNaN(a[1]) ? a[1] : parseFloat(a[1]);
	    if (name.match(/(.*?)\[(.*?)]/)) {
	        name = RegExp.$1;
	        name2 = RegExp.$2;
	        //alert(RegExp.$2)
	        if (name2) {
	            if (!(name in stack)) {
	                stack[name] = {};
	            }
	            stack[name][name2] = value;
	        } else {
	            if (!(name in stack)) {
	                stack[name] = [];
	            }
	            stack[name].push(value);
	        }
	    } else {
	        stack[name] = (typeof(value)=='number' && isNaN(value))?'':value;
	    }
	}
	return stack;
};
todayDateTime = function(isYear, yearSp, isMonth, monthSp, isDate, dateSp, isHours, hoursSp, isMinutes, minutesSp, isSeconds){
	var date1 = new Date();
	var year = "";
	var month = "";
	var date = "";
	var hours = "";
	var minutes = "";
	var seconds = "";
	if (isYear){
		year = year + date1.getFullYear();
	}
	if (isMonth){
		month = month + (date1.getMonth()+1);
		if(month.toString().length < 2)
			month = "0"+month;
	}
	if (isDate){
		date = date + date1.getDate();
		if(date.toString().length < 2)
			date = "0"+date;
	}
	if (isHours){
		hours = hours + date1.getHours();
		if(hours.toString().length < 2)
			hours = "0"+hours;
	}
	if (isMinutes){
		minutes = minutes + date1.getMinutes();
		if(minutes.toString().length < 2)
			minutes = "0"+minutes;
	}
	if (isSeconds){
		seconds = seconds + date1.getSeconds();
		if(seconds.toString().length < 2)
			seconds = "0"+seconds;
	}
	return year+yearSp+month+monthSp+date+dateSp+hours+hoursSp+minutes+minutesSp+seconds;
};


openAnsQEditButton = function(){
	var select = $("table.question[answered=true]");
	for( i=0; i < select.length; i++){
		$("div.webti-question-overlayer[forquestion="+select[i].id+"]").find(".webti-question-overlayer-edit-button").show();
	}
};

function timeCount()
{
$('#today').html(todayDateTime(true, '-', true, '-', true, ' ', true, ':', true, ':', true));
t=setTimeout("timeCount()",1000);
}

var ckeditorDefToolbar=
[
	 ['Source', 'Undo', 'Redo']
	,['Bold','Italic','Underline','Strike','-','Subscript','Superscript']
	,['NumberedList','BulletedList']
	,['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock']
	,['Link','Unlink','Anchor']
	,['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak']
	,'/'
	,['Styles','Format','Font','FontSize']
	,['TextColor','BGColor']
	,['Maximize', 'ShowBlocks']
];
