/* - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
* Filename: mc-bizz.js
* Version: 1.0.0 (2010-04-25)
* Website: http://www.mc-bizz.de/
* Author: Andreas S. / typotemp.com
* Description: 
* - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - */


jQuery(document).ready(function(){ 
	
	//domains
	if (window.location.hostname != 'www.w-fforte.at') {
		$('#header_top .left li a').each(
				function() {
					var domain = 'http://www.w-fforte.at/';
					var linkitem = $(this).attr('href');
					$(this).attr('href',domain+linkitem);
				}
		);
	}
	 
	
	//screen resulution
	var screen_width = screen.width;
	if (screen_width < '1030') {
		var rl = $.cookie('relaod');
		if (rl == null) {
					$.cookie('relaod', '1', { expires: 100 });
					location.reload(); // to use the stylesheet need to relaod or set in header itself
				} else {
				}
	} else {
		var rl = $.cookie('relaod');
		if (rl) {
			$.cookie('relaod', null);
			location.reload(); // to use the stylesheet need to relaod or set in header itself
			} 
		}
	
	//close by default
	$('#content .right .level_1').each(function(i){
			
			if ($(this).hasClass('menuopen1')){ //if sublevel has menuopen1
			} else {
				if ($(this).parents().is(".openmenu") || $(this).hasClass('act')) { //close only if #navigation is not openmenu or is act
					} else {
						$(this).find('ul').removeAttr("style");
						$(this).find('ul').addClass('hidden');
					}
			};
	});	
	
	//show menu items
	$("#content .right .level_1").hover(function() {
				$(this).find('ul').fadeIn("fast");
 	});
	
	//close by default
	$('#content .right #navigation').mouseleave(function(i){
			$('#content .right .level_1').each(function(i){
				if ($(this).hasClass('menuopen1')){ //if sublevel has menuopen1
				
				} else {
					
					if ($(this).parents().is(".openmenu") || $(this).hasClass('act')) { //close only if #navigation is not openmenu or is act
						
						} else {
							$(this).find('ul').fadeOut("fast");
						}
				};
			});	
	});	
	
	//load news_browse_menu
	var news_menu_id = 414;
	$('#navigation .item_'+news_menu_id).each(function(i){
			if ($(this).hasClass('act')){ 
				var content_item = '';
				$(this).after('<div id="news_browse_menu"><ul></ul></div>'); //add a  div
				$('.news-list-container .news-list-item').each(function(i){
					var content_item = $(this).find('h1').html();
					var content_url = window.location;
					var content_base = window.location.pathname;
					var content_link = $(this).find('a.anker').attr('name');
					$('#news_browse_menu ul').append('<li><a href="'+content_url+'#'+content_link+'" alt="'+content_item+' target="_top">'+content_item+'</a></li>');
					$(this).append('<div class="toplink"><a href="'+content_url+'#" alt="'+content_item+' target="_top">Nach oben</a></div>');
					//$('.news-list-browse .header').html('<a href="'+content_base+'" alt="'+content_item+' target="_top">Views from Work &gt;</a>');
					$('.news-list-browse .header').html('');
				});
			}
	 });
	
	 
	 
	 //hover social icons
	$(".tx-timtabsociable-pi1 img").hover(
			function() {
  				this.src = this.src.replace("_off","_act");
 			},
 			function() {
  			this.src = this.src.replace("_act","_off");
 			}
	);
	
	// Font-size
	// default
	var get_fontsize =  $.cookie('fontsize');
	$(".fontsize").addClass(get_fontsize);
	$("#content").addClass(get_fontsize);
	if ($("#content").hasClass ('middle')) {
		   $(".csc-frame-frame1").css("min-height", "255px");
		   $(".csc-frame-frame2").css("min-height", "155px");
		} else if ($("#content").hasClass ('big')) {
		   $(".csc-frame-frame1").css("min-height", "295px");
		   $(".csc-frame-frame2").css("min-height", "195px");
		} else {
	}
	// set
	$(".fontsize").click(
			function() {
				
				elem = $(this);
				if (elem.hasClass ('middle')) {
				   $.cookie('fontsize', 'big', { expires: 1 });
				   $(this).removeClass('middle').addClass('big');
				   $("#content").removeClass('middle').addClass('big');
				   $(".csc-frame-frame1").css("min-height", "295px")
				   $(".csc-frame-frame2").css("min-height", "195px");
				} else if (elem.hasClass ('big')) {
					$.cookie('fontsize', null);
					$(this).removeClass('middle').removeClass('big');
				   $("#content").removeClass('middle').removeClass('big');
				   $(".csc-frame-frame1").css("min-height", "235px");
				   $(".csc-frame-frame2").css("min-height", "135px");
				} else {
					$.cookie('fontsize', 'middle', { expires: 1 });
					$(this).removeClass('big').addClass('middle');
				   $("#content").removeClass('big').addClass('middle');
				}
				
 			}
	);
	$(".fontsize").hover(
			function() {
				$(this).addClass('red');
 			},
			function() {
  				$(this).removeClass('red');
 			}
	);
	
	
	// Login-Form
	var clearMePrevious = "";
	// clear input on focus
	$('.clearFocus').focus(function() {
		if($(this).val()==$(this).attr('title')) {
			clearMePrevious = $(this).val();
			$(this).val('');
		}
	});
	// if field is empty afterward, add text again
	$('.clearFocus').blur(function() {
		if($(this).val()=='') {
			$(this).val(clearMePrevious);
		}
	});	 
	
	
	
});


//read url params // http://ajaxcssblog.com/jquery/url-read-request-variables/
;(function($){$.url={};$.extend($.url,{_params:{},init:function(){var paramsRaw="";try{paramsRaw=(document.location.href.split("?",2)[1]||"").split("#")[0].split("&")||[];for(var i=0;i<paramsRaw.length;i++){var single=paramsRaw[i].split("=");if(single[0])this._params[single[0]]=unescape(single[1]);}}catch(e){alert(e);}},param:function(name){return this._params[name]||"";},paramAll:function(){return this._params;}});$.url.init();})(jQuery);


 /**
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

 
 

