$(document).ready(function(){

$("#videos").scrollable({ 
    size:5,
    clickable:false,
    vertical:false,
	items: '#slider ul',
	next: null,
	prev: null,
        nextPage: 'a.next',
        prevPage: 'a.prev',
	speed: 700,
	easing: 'swing'
}).circular();

$("#new-moeller-videos").scrollable({
 	size:5,
        clickable:false,
        vertical:false,
	items: '#slider ul',
	next: null,
	prev: null,
        nextPage: 'a.next',
        prevPage: 'a.prev',
	speed: 700,
	easing: 'swing'
}).circular();

$("#rhof-moeller-videos").scrollable({
 	size:5,
    clickable:false,
    vertical:false,
	items: '#slider ul',
	next: null,
	prev: null,
        nextPage: 'a.next',
        prevPage: 'a.prev',
	speed: 700,
	easing: 'swing'
}).circular();

$("#channels").scrollable({ 
 	size:6,
    clickable:false,
    vertical:false,
	items: '#slider2 ul',
	next: null,
	prev: null,
        nextPage: 'a.next',
        prevPage: 'a.prev',
	speed: 700,
	easing: 'swing'
}).circular();

$("#slider").scrollable({
 size:5,
 clickable:false,
 vertical:false,
 items: '#sliding ul',
 nextPage: 'a.next',
 prevPage: 'a.prev',
 prev: null,
 next:null,
 speed: 700,
 easing: 'swing'
}).circular(); 


if(document.getElementById('popup') != null) {$("#popup").overlay({ 
 
    // custom top position 

 
    // some expose tweaks suitable for facebox-looking dialogs 
    expose: { 
 
        // you might also consider a "transparent" color for the mask 
        color: '#000', 
 
        // load mask a little faster 
        loadSpeed: 200, 
 
        // highly transparent 
        opacity: 0.5 
    }, 
  onBeforeLoad: function() { 
 
            // grab wrapper element inside content 
              var wrap = this.getContent().find(".middle"); 
 
            // load the page specified in the trigger 
            wrap.load('http://www.nsixty.com/20/popup.html #popupcontent'); 
        } ,
    // disable this for modal dialog-type of overlays 
    closeOnClick: true, 
 
    // we want to use the programming API 
    api: true 
 
// load it immediately after the construction 
}).load();}

});



//Drag n drop starts here
$(document).ready(
	function () {
		$('a.closeEl').bind('click', toggleContent);
		$('div.groupWrapper').Sortable(
			{
				accept: 'groupItem',
				helperclass: 'sortHelper',
				activeclass : 	'sortableactive',
				hoverclass : 	'sortablehover',
				handle: 'div.itemHeader',
				tolerance: 'pointer',


				onChange : function(ser)
				{
				},
				onStart : function()
				{
					$.iAutoscroller.start(this, document.getElementsByTagName('body'));
				}, 
				onStop : function()
				{
					$.iAutoscroller.stop();

					var left_cookie = new  Array();
					var left_cookie_string  = "";
					var value_new = serialize('sort1'); 
					var brokenstring = value_new.split('&'); 
					
					for(i = 0; i < brokenstring.length; i++){
						var temp_val = brokenstring[i];
						var temp_val2  = temp_val.split('=');
						left_cookie[i] = temp_val2[1];
					}
					left_cookie_string = left_cookie.join(',') 
					//document.cookie= "left_side=" +  left_cookie_string;
					set_cookie("left_side", left_cookie_string);



// 					var t =  get_cookie("left_side");
// 					alert(t);

					

				}
			}
		);


		$('div.groupWrapper1').Sortable(
			{
				accept: 'groupItem1',
				helperclass: 'sortHelper',
				activeclass : 	'sortableactive',
				hoverclass : 	'sortablehover',
				handle: 'div.itemHeader1',
				tolerance: 'pointer',
				axis:	'vertically',
			

				onChange : function(ser)
				{
				},
				onStart : function()
				{
					$.iAutoscroller.start(this, document.getElementsByTagName('body'));
				},
				onStop : function()
				{
					$.iAutoscroller.stop();
					var right_cookie = new  Array();
					var right_cookie_string  = "";
					var value_new = serialize('sort2'); 
					var brokenstring=value_new.split('&'); 
					
					for(i = 0; i < brokenstring.length; i++){
						var temp_val = brokenstring[i];
						var temp_val2  = temp_val.split('=');
						right_cookie[i] =   temp_val2[1];
					}
					right_cookie_string = right_cookie.join(',');
					set_cookie("right_side", right_cookie_string);
					//document.cookie= "right_side=" +  right_cookie_string;
				}
			}
		);
	}
);
var toggleContent = function(e)
{
	var targetContent = $('div.itemContent', this.parentNode.parentNode);
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		$(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		$(this).html('[+]');
	}
	return false;
};
function serialize(s)
{
	serial = $.SortSerialize(s);
	return serial.hash;
	//alert(serial.hash);
};
function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}
function set_cookie(sName, sValue)
{
  document.cookie = sName + "=" + escape(sValue);
  // Expires the cookie in one month
  var date = new Date();
  date.setMonth(date.getMonth()+1);
  document.cookie += ("; expires=" + date.toUTCString()); 
}


//Drag n drop ends here
