// JavaScript Document
var _cookie = function (key, value, options) {

    // key and value given, set cookie...
    if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = $.extend({}, options);

        if (value === null) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? String(value) : encodeURIComponent(String(value)),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
function showOverlay(post_params)
{
	$.ajax({
			type: 'POST',
			data: post_params,
			url: '/index.php?viewAjax=overlay',
			dataType:'html',
	 	 	success: function(html){ 

					// REPLACING DIV
					$('#facebox').html(html)

					// SHOWING OVERLAY
						 $("#facebox").overlay({
								top: 220,
								mask: {
									color: '#fff',
									loadSpeed: 200,
									closeOnClick: false,
									opacity: 0.4
								},
								closeOnClick: false,
								load: true
							});

					// //onClose
					// if(VeiwResult == true) showOverlay(false);
				},
	 	 	error:function(x,y,z){alert(y)}
		}); 	
}

function NoteVote()
{
	//$(document).unbind("keydown", handleEscape);
	// close
	var p = $("#vote_form_id").serialize();
	showOverlay(p);
	// sending Post Parameters
}

function CloseOverlays()
{
	$('#exposeMask').remove();
	$('#facebox').remove();
	$('#opinion').remove();
}


 var  sendOpinion = function(form)
 {
	 var ajax = {};
	  ajax.url = $(form).attr('action');
	  ajax.type = $(form).attr('method');
      ajax.data =	 $(form).serialize();
	  ajax.success =function(html)
	  { 
		  $(this).html('');
		  $(this).html(html); 
		  console.log(html);
	  };
	  ajax.context = $('#opinion');
	  
	  $.ajax(ajax);
	  
 }

