/** $Id: jquery.main.js 199 2009-10-25 22:59:09Z norman $
 *
 * jQuery Functions
 *
 * ****************************************************************************
 *
 * @author          Norman Georg <n.georg@internet-marketing-agentur.com>
 * @copyright       (c) 2009, Norman Georg and Internet-Marketing-Agentur.
 * @license         Modified MIT License (see below!)
 *
 * @link            -
 * @filesource      /assets/js/jquery.main.js
 *
 * @package         JavaScript
 * @subpackage      jQuery
 *
 * @version         $Revision: 216 $
 * @since           10.04.2009 (12:00:00)
 * @modifiedby      $LastChangedBy: norman $
 * @lastmodified    $Date: 2009-10-25 23:59:09 +0100 (So, 25. Okt 2009) $
 *
 * ****************************************************************************
 * ****************************************************************************
 *
 * What follows is the modified MIT License that applies to all the sourcecode 
 * files developed by Norman Georg and 'IMA' (Internet-Marketing-Agentur).
 *
 * ****************************************************************************
 *     
 * 	  Sourcecode & Documentation Copyright (c) 2009, All rights reserved.
 *       
 *    (c) 2007-2009, Norman Georg <n.georg@internet-marketing-agentur.com>
 *    (c) 2009, 'IMA' Developer-Team <dev@internet-marketing-agentur.com> 
 * 
 *                http://www.internet-marketing-agentur.com              
 * 				
 *    Internet-Marketing-Agentur  -  info@internet-marketing-agentur.com
 *    Untertuerkheimer Strasse 24, 66119 Saarbruecken, Saarland, Germany
 *    fon:  +49 (0) 681 / 92 92 88 -0  | fax:  +49 (0) 681 / 92 92 88 -9
 * 
 * ****************************************************************************
 * 
 */




// ----------------------------------------------------------------------------
//  FUNCTIONS
// ----------------------------------------------------------------------------

/**
 * equalHeight()
 *
 * set columns to an equal height
 */
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
};

/**
 * collapsing_nav()
 *
 * 
 */
function collapsing_nav()
{
	$("#subnav > li:first").addClass("selected");
	
	$("#subnav > li").not(":first").find("dl").hide();
	
	$("#subnav > li a").click(function() 
	{
		if ($(this).parent().find("dl").is(":hidden")) 
		{
			$("#subnav dl:visible").slideUp("fast");
			$("#subnav > li").removeClass("selected");
		
			$(this).parent().addClass("selected");
			$(this).parent().find("dl").slideDown("fast");
		}
	});
}

/*
 * EXT:ratings
 */

/* old prototype function */
//function tx_ratings_submit(id, rating, ajaxData, check) {
//    $('tx-ratings-display-' + id).style.visibility = 'hidden';
//    $('tx-ratings-wait-' + id).style.visibility = 'visible';
//    new Ajax.Updater('tx-ratings-' + id, 'index.php?eID=tx_ratings_ajax', {
//        asynchronous: true,
//        method: 'post',
//        parameters: 'ref=' + id + '&rating=' + rating + '&data=' + ajaxData + '&check=' + check
//    });
//}

/* new jquery function */
function tx_ratings_submit(id, rating, ajaxData, check) 
{
	var data = 'ref=' + id + '&rating=' + rating + '&data=' + ajaxData + '&check=' + check;
	$("#tx-ratings-" + id).load('/magazine/?eID=tx_ratings_ajax&' + data);
	
}

/*
 * EXT:ima_panorama
 */
 /*
function setPanorama() 
{
	if ($.exists("a[rel='panorama']")) 
	{	//assign the ColorBox event to panoramas
		$("a[rel='panorama']").colorbox({iframe:false});
	}
}
*/

/**
 * flush all input/textarea fields onFocus and re-fill them onBlur (if empty)
 */
/*
jQuery('input, textarea').focus(function($){
	$(this).attr('value') = '';
});
jQuery("input").blur(function($){
	var newValue = $(this).attr('value');
	if (newValue == '') {
		$(this).attr('value') = $(this).attr('defaultValue');
	}
});
*/

function setVideoMateSorting (sort) 
{	
	$.cookie('mxs_tx_imavideomate_sorting', sort);
	
	// seite refreshen
	window.location.reload();
}

function setVideoMateItems (item) 
{	
	$.cookie('mxs_tx_imavideomate_items', item);
	
	// seite refreshen
	window.location.reload();
}

/**
 * mxsMenuHack()
 *
 * fix the typo3 tmenu problem on odd numbered items
 */
function mxsMenuHack () 
{
	var total = $(".navigation-sub").size();
	for (var i=0; i< total; i++) 
	{
		var context = $('.navigation-sub')[i];
		var myObj =  $("li", context);
		var cnt = myObj.size();

		if ((cnt > 1) && (cnt % 2 == 1)) {  
			$("li:last", context).after("<li class='last'>&nbsp;</li>"); 
		}
	}

}

function mxsMenuColumns()
{
	//$('div.navigation-sub').each(function() 
	//{
		
		var total = $("div.navigation-sub").size();
		for (var i=0; i<total; i++)
		{
			var width = $('div.navigation-sub ul')[i].width();
			var text = $("div.navigation-sub ul").text();
			
   		 	console.log(i+' - '+width+' - '+text);
		}
		//alert(total);
	//});
}




// ----------------------------------------------------------------------------
//  onDocReady
// ----------------------------------------------------------------------------

$(document).ready(function() 
{

	//jQuery.exists = function(selector) {return ($(selector).length > 0);}


	//mxsMenuHack();
	//mxsMenuColumns();
    //setPanorama ();
	//equalHeight($("#content"));
	//equalHeight($("#sidebar"));





	// PageBrowser: relations-toggle
	$("#relations > p.relations-toggle").click(function() 
	{ 
		$("#relations > dl.relations-browser").toggle(1000); 
	});

	// IMA VideoMate Single Bookmarks
	$('div.ima-videomate-single').each(function(index) {
  		$('div.tx-timtabsociable-pi1').css("margin-top","-6.5em")
  			.css("margin-left","360px")
 			.css("position", "absolute")
 			.css("padding-bottom","2em");
	});

	// ToolTips:
	$('div.tx-timtabsociable-pi1 a[title]').qtip({
	   	style: { 
	      	padding: 5,
	      	background: '#ffffff',
	      	color: 'black',
	      	textAlign: 'center',
	      	border: {
	         	width: 6,
	         	radius: 5,
	         	color: '#252525'
	      	},
	      	tip: true,
	      	name: 'dark'
	   	},
		position: {
  			corner: {
     			target: 'bottomMiddle',
     			tooltip: 'topLeft'
  			}
  		},
	
	});
	

	
	//alert("muh");

});



// --------------------------------------
//  vim:set nu ff sts=4 sw=4 ts=4 tw=80:

