// voting
$(function() {

/*
function recp(lid) {
  $('.lincs').load('upsast.php?id=' + lid);
}
*/

$(".vote").click(function(){

var id = $(this).attr("id");
var name = $(this).attr("name");
var dataString = 'id='+ id ;
var parent = $(this);


if(name=='up')
{

$(this).fadeIn(200).html('<img src="loading.gif" align="absmiddle">');
$.ajax({
   type: "POST",
   url: "up_vote.php",
   data: dataString,
   cache: false,

   success: function(html)
   {
    parent.html(html);
  
  }  });
  
} 
return false;
	});

});

$(document).ready(function() {
    $('#br').click( function() {
        window.open( $(this).attr('alt') );
        return false;
    });
});

// exits
$(function() {
    $(".lincs").click(function(){
        var id = $(this).attr("id");
        var dataString = 'id='+ id ;
            $.ajax({
               type: "POST",
               url: "http://uni-web.net/exits.php",
               data: dataString,
               cache: false,
                   success: function(html)
                   {
                    inner.html(html);
                   }  
               });
    	});
});


/***************************/
/*@Autor: Simeon Ivanov	*/			
/***************************/
//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#bannercontact").height();
	var popupWidth = $("#bannercontact").width();
    var popupHeight = $("#bannerbackground").height();
	var popupWidth = $("#bannerbackground").width();
	//centering
	$("#bannercontact").css({
		"position": "fixed",
		//"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
    
	//only need force for IE6
	$("#bannerbackground").css({
		"position": "fixed",
		//"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	
}

$(document).ready(function() {
    centerPopup();
 $("#bannerbackground").css({
  "opacity": "0.7"
 });
 $('#bannerbackground, #bannercontact').slideDown('slow', function() {
 });
 setTimeout(function(){
  $("#bannerbackground").slideUp("slow");
  $("#bannercontact").slideUp("slow");
 }, 3000);
});

function hideBanner () 
{
 $("#bannerbackground").stop(true, true).slideUp("slow");
 $("#bannercontact").slideUp("slow");
}


//facebook
function fbs_click() {
    u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&lt;t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
    }

// flash fix
objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++)
{
   objects[i].outerHTML = objects[i].outerHTML;
}

//popup wind
function popupwnd(url, toolbar, menubar, locationbar, resize, scrollbars, statusbar, left, top, width, height)
{
   var popupwindow = this.open(url, '', 'toolbar=' + toolbar + ',menubar=' + menubar + ',location=' + locationbar + ',scrollbars=' + scrollbars + ',resizable=' + resize + ',status=' + statusbar + ',left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
}

// objekt by id
function FindObject(id, doc)
{
   var child, elem;
   if(!doc)
      doc=document;
   if(doc.getElementById)
      elem=doc.getElementById(id);
   else
   if(doc.layers)
      child=doc.layers;
   else
   if(doc.all)
      elem=doc.all[id];
   if(elem)
      return elem;
   if(doc.id==id || doc.name==id)
      return doc;
   if(doc.childNodes)
      child=doc.childNodes;
   if(child)
   {
      for(var i=0; i<child.length; i++)
      {
         elem=FindObject(id,child[i]);
         if(elem)
            return elem;
      }
   }
   var frm=doc.forms;
   if(frm)
   {
      for(var i=0; i<frm.length; i++)
      {
         var elems=frm[i].elements;
         for(var j=0; j<elems.length; j++)
         {
            elem=FindObject(id,elems[i]);
            if(elem) return elem;
         }
      }
   }
   return null;
}


function ShowObject(id, flag)
{
   var elem=FindObject(id);
   if(elem)
      elem.style.visibility=flag?'visible':'hidden';
}



function limitText(limitField, limitCount, limitNum) {
  if (limitField.value.length > limitNum) {
    limitField.value = limitField.value.substring(0, limitNum);
  } else {
    limitCount.value = limitNum - limitField.value.length;
  }
}

//comboxes

function change(currentbox) {
	numb = currentbox.id.split("_");
	currentbox = numb[1];

    i=parseInt(currentbox)+1

// I empty all combo boxes following the current one

    while ((eval("typeof(document.getElementById(\"cat_"+i+"\"))!='undefined'")) &&
           (document.getElementById("cat_"+i)!=null)) {
         son = document.getElementById("cat_"+i);
	     // I empty all options except the first one (it isn't allowed)
	     for (m=son.options.length-1;m>0;m--) son.options[m]=null;
	     // I reset the first option
	     son.options[0]=new Option(displaywhenempty,valuewhenempty)
	     i=i+1
    }


// now I create the string with the "base" name ("stringa"), ie. "data_1_0"
// to which I'll add _0,_1,_2,_3 etc to obtain the name of the combo box to fill

    stringa='data'
    i=0
    while ((eval("typeof(document.getElementById(\"cat_"+i+"\"))!='undefined'")) &&
           (document.getElementById("cat_"+i)!=null)) {
           eval("stringa=stringa+'_'+document.getElementById(\"cat_"+i+"\").selectedIndex")
           if (i==currentbox) break;
           i=i+1
    }


// filling the "son" combo (if exists)

    following=parseInt(currentbox)+1

    if ((eval("typeof(document.getElementById(\"cat_"+following+"\"))!='undefined'")) &&
       (document.getElementById("cat_"+following)!=null)) {
       son = document.getElementById("cat_"+following);
       stringa=stringa+"_"
       i=0
       while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0)) {

       // if there are no options, I empty the first option of the "son" combo
	   // otherwise I put "-select-" in it

	   	  if ((i==0) && eval("typeof("+stringa+"0)=='undefined'"))
	   	      if (eval("typeof("+stringa+"1)=='undefined'"))
	   	         eval("son.options[0]=new Option(displaywhenempty,valuewhenempty)")
	   	      else
	             eval("son.options[0]=new Option(displaywhennotempty,valuewhennotempty)")
	      else
              eval("son.options["+i+"]=new Option("+stringa+i+".text,"+stringa+i+".value)")
	      i=i+1
	   }
       //son.focus()
       i=1
       combostatus=''
       cstatus=stringa.split("_")
       while (cstatus[i]!=null) {
          combostatus=combostatus+cstatus[i]
          i=i+1
          }
       return combostatus;
    }
}
