jQuery(document).ready(function($){
if (getElementsByClassName('rounded').length>0){
$('.rounded').corners("5px 5px");
 jQuery('a[rel*=facebox]').facebox();
 						   
}
  
});
jQuery.fn.slideFadeToggle = function(speed, easing, callback) {
  return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
};

function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

function startToggle(e,speed) {
	    $(e).slideFadeToggle((speed != null) ? speed : null);
}

function startToggleCal(e,speed, refID) {
		$(refID).hide();
	    $(e).slideFadeToggle((speed != null) ? speed : null);
}


function winpop(url,w,h) {
window.open(url,'Özyeğin Üniversitesi','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,top='+Math.floor(screen.height/2-h/2)+',left='+Math.floor(screen.width/2-w/2)+',resizable=1,width='+w+',height='+h);
}
function showItem(id){
	$("#"+id).show("fast");
	
}
function hideItem(id){
	$("#"+id).hide("fast");
}

function shareThisPage(destSite,id,title){
	var shareTitle="";
	var siteURL = "http://www.ozyegin.edu.tr/";
	var targetURL = "";
	var thisUrl = "";

	if (shareTitle == '') {shareTitle = "Özyeğin Üniversitesi Etkinlik Takvimi | " + title;}
	
	var thisUrl = siteURL + "?id=" + id;
	var description = "";
	try{
		description += "Özyeğin Üniversitesi Etkinlik Takvimi";
	}catch(err){	
	}


	switch (destSite){
		case "Del.icio.us":
			targetURL = "http://del.icio.us/post?url=" + thisUrl + "&title="+ shareTitle;
		break;
		case "Digg":
			targetURL = "http://digg.com/submit?url=" + thisUrl + "&title=" + shareTitle;
		break;
		case "Myspace":
			targetURL = "http://www.myspace.com/Modules/PostTo/Pages/?c="+ thisUrl + "&t=" + shareTitle;
		break;
		case "Facebook":
			targetURL = "http://www.facebook.com/sharer.php?u=" + thisUrl + "&t=" + shareTitle;
		break;
		case "Google Bookmarks":
			targetURL = "http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=" + thisUrl +"&title=" + shareTitle;
		break;
		case "Yahoo Myweb":
			targetURL = "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=" + thisUrl + "&t=" + shareTitle;
		break;
		case "StumbleUpon":
			targetURL = "http://www.stumbleupon.com/refer.php?url=" + thisUrl + "&title=" + shareTitle;
		break;
		case "Reddit":
			targetURL = "http://reddit.com/submit?url=" + thisUrl + "&title=" + shareTitle;
		break;
		case "Newsvine":
			 targetURL = "http://www.newsvine.com/_tools/seed&save?u=" + thisUrl + "&h=" + shareTitle;
		break;
		case "Live Bookmarks":
			targetURL = "https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url=" + thisUrl + "&title="+ shareTitle;
		break;
		case "Technorati":
			targetURL = "http://www.technorati.com/faves?add=" + thisUrl;
		break;
		case "Twitter":
			targetURL = "http://twitter.com/home?status="+ shareTitle + " - " + thisUrl;
		break;
		case "Yahoo Bookmarks":
			targetURL = "http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u=" + thisUrl + "&title="+ shareTitle;
		break;
		case "myAOL":
			targetURL = "http://favorites.my.aol.com/ffclient/webroot/0.4.1/src/html/addBookmarkDialog.html?url="+ thisUrl + "&title="+ shareTitle;
		break;
		case "FriendFeed":
			targetURL = "http://friendfeed.com/?url=" + thisUrl + "&title="+ shareTitle;
		break;
		
	}
	if(targetURL != ""){
		window.open(targetURL,"_blank");
	}	
}


function getElementsByClassName(needle)
{
   var my_array = document.getElementsByTagName("*");
   var retvalue = new Array();
   var i;
   var j;

   for (i=0,j=0;i<my_array.length;i++)
   {
      var c = " " + my_array[i].className + " ";
      if (c.indexOf(" " + needle + " ") != -1) retvalue[j++] = my_array[i];
   }
   return retvalue;
}

var tooltip=function(){
	var id = 'tt';
	var top = 1;
	var left = 10;
	var maxw = 125;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();
