//---------------------------------------------------------- Center DIV
function CenterItem(theItem){
    var winWidth=$(window).width();
    var winHeight=$(window).height();
    var windowCenter=winWidth/2;
    var itemCenter=$(theItem).width()/2;
    var theCenter=windowCenter-itemCenter;
    var windowMiddle=winHeight/2;
    var itemMiddle=$(theItem).height()/2;
    var theMiddle=windowMiddle-itemMiddle;
    if(winWidth>$(theItem).width()){ //horizontal
        $(theItem).css('left',theCenter);
    } else {
        $(theItem).css('left','0');
    }
    if(winHeight>$(theItem).height()){ //vertical
        $(theItem).css('top',theMiddle);
    } else {
        $(theItem).css('top','0');
    }
}
$(document).ready(function() {
    CenterItem('.centered2');
});
$(window).resize(function() {
    CenterItem('.centered2');
});

//----------------------------------------------------------



//---------------------------------------------------------- TIMELINE SLIDER DIV
// execute your scripts when the DOM is ready. this is mostly a good habit
$(function() {

	// initialize scrollable
	$(".mainslide").scrollable({
	circular: true
	});

});



//---------------------------------------------------------- NEWS DETAIL SLIDER DIV
$(document).ready(function() {
	$('#mainslide2').cycle({
		timeout: 0,
		fx: 'scrollHorz',
		speed:  300,
		pager:  '#nav' 
	});
 
	$("#mainslide2").touchwipe({
 		wipeLeft: function() {
 	 		$("#mainslide2").cycle("next");
 		},
 		wipeRight: function() {
 	 		$("#mainslide2").cycle("prev");
 		}
	});
});



//---------------------------------------------------------- NEWS DETAIL SLIDER DIV
$(function()
{
	$('#textarea').jScrollPane();
});

//---------------------------------------------------------- FACEBOOK SLIDER DIV
$(function()
{
	$('#inner').jScrollPane({
	verticalDragMinHeight: 20,
	verticalDragMaxHeight: 20,	
	});
});
