function get_content(idc)
{
   var url      = $.url();
   var data_url = "idc=" + idc + "&" + url.attr('query');
   $.ajax(
   {
       type: "POST",
       url:  "includes/handle_url.php",
       data: data_url,
       success: function(content)
       {
           if(content==-1)
           {
               $.colorbox({ transition:"elastic",
                            html: "<div style='color: red; width: 100%; text-align: center;'>Ocorreu um erro! <br><br> Tente mais tarde ou reporte a situa&ccedil;&atilde;o!</div>" });
           }
           else
           {
               try
               {
                   var splitted     = new Array(); var i = 0;
                   var novoTotal_je = eval('(' + content + ')');
                   for(var key in novoTotal_je)
                   {
                       splitted[i] = novoTotal_je[key];
                       i++;
                   }

		   if(splitted[0]!="")
/*			$.colorbox({ height: "80%", width: "50%", transition:"elastic", overlayClose:true, html: splitted[0] });*/
                        $.colorbox({ transition:"elastic", overlayClose:true, html: splitted[0] });
		   if(splitted[1]!="")
			eval(splitted[1]);
               }
               catch(err)
               {

               }
           }
       }
    });
}

function get_comment(idc)
{
   var url      = $.url();
   var data_url = "comment=" + idc + "&" + url.attr('query');
   $.ajax(
   {
       type: "POST",
       url:  "includes/handle_url.php",
       data: data_url,
       success: function(content)
       {
           if(content==-1)
           {
               $.colorbox({ transition:"elastic",
                            html: "<div style='color: red; width: 100%; text-align: center;'>Ocorreu um erro! <br><br> Tente mais tarde ou reporte a situa&ccedil;&atilde;o!</div>" });
           }
           else
           {
               try
               {
                   var splitted     = new Array(); var i = 0;
                   var novoTotal_je = eval('(' + content + ')');
                   for(var key in novoTotal_je)
                   {
                       splitted[i] = novoTotal_je[key];
                       i++;
                   }

		   if(splitted[0]!="")
/*			$.colorbox({ height: "80%", width: "50%", transition:"elastic", overlayClose:true, html: splitted[0] });*/
                        $.colorbox({ transition:"elastic", overlayClose:true, html: splitted[0] });

		   if(splitted[1]!="")
			eval(splitted[1]);
               }
               catch(err)
               {

               }
           }
       }
    });
}

function get_image(img)
{
   open_colorbox("<img class='syslbimage' src='"+img+"' />");
}

function get_content_url()
{
   var url      = $.url();
   var data_url = url.attr('query');
   $.ajax(
   {
       type: "POST",
       url:  "includes/handle_url.php",
       data: data_url,
       success: function(content)
       {
           if(content==-1)
           {
               $.colorbox({ transition:"elastic",
                            html: "<div style='color: red; width: 100%; text-align: center;'>Ocorreu um erro! <br><br> Tente mais tarde ou reporte a situa&ccedil;&atilde;o!</div>" });
           }
           else
           {
               try
               {
                   var splitted     = new Array(); var i = 0;
                   var novoTotal_je = eval('(' + content + ')');
                   for(var key in novoTotal_je)
                   {
                       splitted[i] = novoTotal_je[key];
                       i++;
                   }
/*                   $.colorbox({ height: "80%", width: "50%", transition:"elastic", overlayClose:true, html: splitted[0] });*/
                   $.colorbox({ transition:"elastic", overlayClose:true, html: splitted[0] });

               }
               catch(err)
               {
                   $.colorbox({ transition:"elastic", html: "<div style='color: red; width: 100%; text-align: center;'>Ocorreu um erro! <br><br> Tente mais tarde ou reporte o problema!</div>" });
               }
           }
       }
    });
}

function open_colorbox(html)
{
    $.colorbox({transition:'elactic', html: "<div style='color: green; width: 100%; text-align: center;'>" + html + "</div>" });
}

function jq_URLEncode(c)
{
    var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
    while(x<c.length){var m=r.exec(c.substr(x));
    if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
    }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
    o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}
    return o;
}

function jq_URLDecode(s)
{
    var o=s.replace(/\+/g,' ');var binVal,t;var r=/(%[^%]{2})/;
    while((m=r.exec(o))!=null && m.length>1 && m[1]!=''){b=parseInt(m[1].substr(1),16);
    t=String.fromCharCode(b);o=o.replace(m[1],t);}
    return o;
}

function urlDecode(str)
{
    return jq_URLDecode(str);
}

var Utf8 = {
 // public method for url encoding
 encode : function (string) {
 string = string.replace(/\r\n/g,"\n");
 var utftext = "";
 
 for (var n = 0; n < string.length; n++) {
  var c = string.charCodeAt(n);
  if (c < 128) {
   utftext += String.fromCharCode(c);
  }
  else if((c > 127) && (c < 2048)) {
   utftext += String.fromCharCode((c >> 6) | 192);
   utftext += String.fromCharCode((c & 63) | 128);
  }
  else {
   utftext += String.fromCharCode((c >> 12) | 224);
   utftext += String.fromCharCode(((c >> 6) & 63) | 128);
   utftext += String.fromCharCode((c & 63) | 128);
  }
 }
 return utftext;
},

 // public method for url decoding
 decode : function (utftext) {
  var string = "";
  var i = 0;
  var c = c1 = c2 = 0;
  
  while ( i < utftext.length ) {
   c = utftext.charCodeAt(i);
   if (c < 128) {
    string += String.fromCharCode(c);
    i++;
   }
   else if((c > 191) && (c < 224)) {
    c2 = utftext.charCodeAt(i+1);
    string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
    i += 2;
   }
   else {
    c2 = utftext.charCodeAt(i+1);
    c3 = utftext.charCodeAt(i+2);
    string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
    i += 3;
   }
  }
  return string;
 }
}

function open_colorbox_2(html)
{
    var html2 = urlDecode(html);
/*    $.colorbox({ height: "80%", width: "50%", transition:'elactic', html: "<div style='color: green; width: 100%; text-align: center;'>" + html2 + "</div>" });*/
    $.colorbox({ transition:'elactic', html: "<div style='color: green; width: 100%; text-align: center;'>" + html2 + "</div>" });
}

