function showForm(Message){
    if($('#infoPopUpMain').is(':hidden')){
    	
    $('#infoPopUpMainInside').html(Message);
    //$('#infoPopUpMain').css({width:"600px"});
    $('#infoPopUpMain').css({height:"auto"});
    $('#infoPopUpMain').css({"margin-top":"100px"});
  //  $('#infoPopUpMain').css({"margin-left":"100px"});
   // $('#infoPopUpMain').css({float:"left"});
    $('#infoPopUpMain').fadeIn('slow');
        
    }
}

function send_form() { 
	if ($('#title').val() == '') {
	 	$('#d1').css({"border":"1px solid red"}); 
		$("#title").focus();  
	} else {
	$('#b1').hide();
	$('#b2').show();
	$.post("/pl/index/sugestion-form/posts/add_from_form" ,  { title: $('#title').val(), content: $('#content').val(), kind: $('#kind').val(), referrer: $('#referrer').val(), email: $('#email').val(), category : $('#category_id').val()  }, function(data){
		 $("#form1").hide();
		 $("#message").show();
		 
		 $('#b1').show();
	   //alert(data);
	 });  
	}
}  
//$("#title").focus();   



function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	//popUpDiv_height=blanket_height/2-150;//150 is half popup's height
	popUpDiv_height = 200;
	popUpDiv.style.top = popUpDiv_height + 'px';
}

function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-204;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}

$(document).ready(function(){
	$("#sugester_widget").click(function() {
		showSuggester();
	});
/*	 $("#mainPageSearchForm").css({"z-index":"100"});
	 $("#sugester_widget").click(function() {
		 var sugest_form =  $('#sugester');
		
		 var blanket = $("#blanket");
		   	$("#blanket").css({"z-index":"1"});
		    $('#infoPopUpMain').css({"position":"absolute"});
		    $('#infoPopUpMain').css({"z-index":"10"});
		    $('.mainSearchSelect').css({"display":"none"});
		    //$("#blanket").css({"width":"1400px"});
		    $("#blanket").show();
		 
 			
			blanket_size('sugester');
		    window_pos('sugester');
		    showForm(sugest_form.html());	
		    
		 //$('#sugester').hide();
		  
     });
	 
	 $(".close").click(function() {
		 $("#blanket").hide();
		 $('.mainSearchSelect').show();
	 });
*/	
});
