function submitRating(ratingValue)
{
	if(ratingValue != null && questionID != null && questionID != "")
	{
		$.ajax({
			type: "GET",
			url: "/feedback/save?question_id="+questionID+"&area="+area+"&section="+section+"&page_title="+pageTitle+"&url="+title+"&rating="+ratingValue,
			dataType: "xml",
			success: function(xml) {
				var status = $(xml).find('status').text();
				if(status.replace(" ","") == "success")
				{
					$("#survey_rating").html('<span class="survey_info"><p>Thanks!</p></span>');
					$("#survey_feedback .survey_info").hide();
				}
				else
				{
					$("#survey_rating").html('<span class="survey_info"><p>Something went wrong, when submitting your rating</p></span>');
				}
			},
			error: function (XMLHttpRequest, textStatus, errorThrown) {
				$("#survey_rating").html('<span class="survey_info"><p>Something went wrong, when submitting your rating</p></span>');
			}
											
		})	
	}
}

function submitFeedback()
{

	
	var feedback = $("#ieFeedback #feedback_text").val();
	
	
	if(feedback == null || feedback == "")
	{
		$(".feedback_errors").html('Please enter text for feedback');
		$(".feedback_errors").show();
	}
	else if(feedback.length > 4000)
	{
		$(".feedback_errors").html('Feedback should be less than 4000 characters');
		$(".feedback_errors").show();
	}
	else
	{
		$(".feedback_errors").hide();
		$.ajax({
			type: "GET",
			url: "/feedback/save?question_id="+questionID+"&area="+area+"&section="+section+"&page_title="+pageTitle+"&url="+title+"&feedback="+feedback,
			dataType: "xml",
			success: function(xml) {
				var status = $(xml).find('status').text();
				if(status == "success")
				{
					$("#survey_feedback").html('<span class="survey_info"><p>Thanks!</p></span>');
					$("#survey_rating .survey_info").hide();
					hideFeedback();
				}
				else
				{
					$("#survey_feedback").html('<span class="survey_info"><p>Something went wrong, when submitting your feedback</p></span>');
					hideFeedback();
				}
			},
			error: function (XMLHttpRequest, textStatus, errorThrown) {
				$("#survey_feedback").html('<span class="survey_info"><p>Something went wrong, when submitting your feedback</p></span>');
				hideFeedback();
			}
		})
	}
}

function ___getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	var pageWidth, pageHeight;
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}
	
function ___getPageScroll() {
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	var arrayPageScroll = new Array(xScroll,yScroll);
	return arrayPageScroll;
}

function openAbout() {
	var flashvars = {};
	var attributes = {};
	var arrPageSizes = ___getPageSize();
	var arrPageScroll = ___getPageScroll();
	var topPosition = arrPageScroll[1] + (arrPageSizes[3]/2) - 200;
	var leftPosition = (arrPageSizes[0]/2) - 300;
	
	$('body').append('<div id="jquery-overlay" style="display:none;"></div>');
	$('#jquery-overlay').css({backgroundColor:'#000', width:arrPageSizes[0], height:arrPageSizes[1]});
	$('#jquery-overlay').fadeTo("", 0.3).show();

		$('body').append('<div id="ieFeedback" style="display:none;"></div>');
		$('#feedback_panel').clone().attr("id", "ie_feedback_panel").appendTo('#ieFeedback');
		$('#ie_feedback_panel').css({top: topPosition, left: leftPosition, position:'absolute', zIndex:400, display: 'block'});
		$("#ieFeedback #about_panel").show();
		$("#ieFeedback").show();
		
	
}

function openFeedback() {
	var flashvars = {};
	var attributes = {};
	var arrPageSizes = ___getPageSize();
	var arrPageScroll = ___getPageScroll();
	var topPosition = arrPageScroll[1] + (arrPageSizes[3]/2) - 200;
	var leftPosition = (arrPageSizes[0]/2) - 300;
	
	$('body').append('<div id="jquery-overlay" style="display:none;"></div>');
	$('#jquery-overlay').css({zIndex: 200, backgroundColor:'#000', width:arrPageSizes[0], height:arrPageSizes[1]});
	$('#jquery-overlay').fadeTo("", 0.3).show();
		

	$('body').append('<div id="ieFeedback" style="display:none;"></div>');
	$('#feedback_panel').clone().attr("id", "ie_feedback_panel").appendTo('#ieFeedback');
	$('#ie_feedback_panel').css({top: topPosition, left: leftPosition, position:'absolute', zIndex:400, display: 'block'});
	$("#ieFeedback #comment_panel").show();
	$("#ieFeedback").show();


}

function hideFeedback() {
									 
	  $('#ieFeedback').remove();
 
	//$('#jquery-overlay').fadeOut(500);
	$('#jquery-overlay').remove();
}

function showAboutPanel()
{
	
		$("#ieFeedback #comment_panel").hide();
		$("#ieFeedback #about_panel").show();
	
}

function showFeedbackPanel()
{
		$("#ieFeedback #about_panel").hide();
		$("#ieFeedback #comment_panel").show();
	
}