
$(function() {
	
	$('#show_dev_log').click(function(ev) {
		
		ev.preventDefault();
		$('#dev_log').slideToggle('slow');
		
	});
	
	if(DataBridge.module != ""){
		$("#" + DataBridge.module + "-link").addClass('selected-menu-item');
	}
	
	$(".collapse-link").click(function(ev){
		ev.preventDefault();
		ev.target.blur();
		id = $(this).getId();
		
	
		if($('#' + id).hasClass('closed')){
			$('#' + id).removeClass('closed');
			$('#' + id).addClass('open');
			$(this).find(".collapse").html("[+]");
		}else{
			$('#' + id).addClass('closed');
			$('#' + id).removeClass('open');
			$(this).find(".collapse").html("[-]");
		}
		
		$('#' + id).slideToggle();
	
		
	});
	
	$(".main-option-fade").hover(function(){
	   
		$(this).stop().animate({
			opacity: "0"
		},'slow');

	   },
	   function(){
	   	$(this).stop().animate({
			opacity: "1"
		},'slow');
		
		});

	
	$('#cms-logout').click(function(ev){
		ev.preventDefault;
		ev.target.blur();
		SIV.ajaxCall({
			url: '/sivcms/login/index/logout',
			handler: 'logout',
			postData: {'logout':true}
		});
		document.location.href='/sivcms/login/';
	});
		
	
	
	
	
})

function Set_Cookie( name, value, expires, path, domain, secure ) 
	{
	// set time, it's in milliseconds
		var today = new Date();
		today.setTime( today.getTime() );
		
		/*
		if the expires variable is set, make the correct 
		expires time, the current script below will set 
		it for x number of hours, for minutes, delete * 60 
		*/
		if ( expires )
		{
		expires = expires * 1000 * 60 * 60;
		}
		var expires_date = new Date( today.getTime() + (expires) );
		
		document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
	}
	
	function in_array(needle, haystack, strict) {
	
	    var found = false, key, strict = !!strict;
	
	    for (key in haystack) {
	        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
	            found = true;
	            break;
	        }
	    }
	
	    return found;
	}// }}}
	
function adjustMceHeight() {
	var frame, doc, docHeight, frameHeight;
	frame = document.getElementById("article-content_ifr");
	if ( frame != null ) {
		//get the document object
		if (frame.contentDocument) { 
			doc = frame.contentDocument; 
		} else if (frame.contentWindow) { 
			doc = frame.contentWindow.document; 
		} else if (frame.document) { 
			doc = frame.document; 
		}
		
		if ( doc == null )
			return;
		
		//prevent the scrollbar from showing
		doc.body.style.overflow = "hidden";
	
		docHeight;
		frameHeight = parseInt(frame.style.height);
		
		//Firefox
		if ( doc.height ) { docHeight = doc.height; }
		//MSIE
		else { docHeight = parseInt(doc.body.scrollHeight); }
		
		//MAKE BIGGER
		if ( docHeight > frameHeight-20 ) { frame.style.height = (docHeight+20) + "px"; }
		//MAKE SMALLER
		else if ( docHeight < frameHeight-20 ) { frame.style.height = Math.max((docHeight+20), 332) + "px"; }
		
		//only repeat while editor is visible
		setTimeout("adjustMceHeight()", 1);
	}
}