$(document).ready(function() {
	
  //$('#contentWrapper').minHeight(470);
	
  $('ul#nav > li').hover(function() {
	// IE workaround

	if($.browser.msie) {
	$('ul', this).css('top',$(this).position().top + $(this).height()+200);
	$('ul', this).css('left',$(this).position().left);
	}
	$('ul', this).css('top',$(this).position().top + $(this).height());
	$('ul:first', this).show();
  },
  function() {
    $('ul:first', this).hide();
  });

  $('ul#nav li li').hover(function() {
    $('ul:first', this).each(function() {
      $(this).css('top', $(this).parent().position().top );
      $(this).css('left', $(this).parent().position().left + $(this).parent().width() );
      $(this).show();
    });
  },
  function() {
    $('ul:first', this).hide();
  });
});

function showLocation(loca)
{
	var all = '.locationItem';
	var curr= '#'+loca;
	var menu= '.leftMenu a';
	$(all).not(curr).slideUp('fast');
	$(curr).slideDown('normal');

	$(menu).each(function() {
		if($(this).attr('rel') == curr) {
			$(this).addClass('here');
		} else {
			$(this).removeClass('here');
		}
	});
	
	
	if($.browser.msie){
		$('.content').css('min-height','470px');
		//$('.content').minHeight(470);
	}
}

function survey()
{
	 this.row_number = 0;
}
var survey = new survey;

function survey_process()
{
	var process = '#surveyProcess';
	var process = '#surveyProcess';
	var processBg='#surveyProcess-bg';
	var content = '#surveyForm';
	var btn = '#button';
	var processTxt = '#surveyProcess .processTxt';
	
	var pos = $(content).position();
	var wdth= $(content).width();
	var hgt= $(content).height();
		
	$(process+', '+processBg).css('left', (pos.left-2));
	$(process+', '+processBg).css('top', (pos.top-2));
	$(process+', '+processBg).css('width', (wdth+1));
	$(process+', '+processBg).css('height', (hgt+1));
	$(process+', '+processBg).fadeIn('normal');
	$(btn).attr('disabled', 'disabled');
	$(processTxt).css('top', (hgt/2));
	 
	
	var params = $("#surveyForm").serialize();
	$.post(BASE_URL+'/testimonials/feedback/process-survey', params,
		  function(data){
			$(process+', '+processBg).fadeOut('fast');
			$(btn).removeAttr('disabled');
		
		  	if(data.faild == 1) {
		  		alert(data.message);
		  	return;
		  	}
		  	alert(data.message);
		  	window.location='';
		  },
		  'json'
	);
}


$(function(){
	var current = CURRENT_URL;
	$('.leftMenu a').each(function() {
		var page = $(this).attr('href');
		if(current == page) {
			$(this).addClass('here');
		}	
	});
});