/**
 * @bk
 * 09.08.2011
 * 
 */

if ('undefined' != typeof cEasyJs) {
	cEasyJs.load('jQuery', function() {
		jQuery(document).ready(function() {
			
			var aktiveState ="";
			
			if(document.cookie){
					aktiveState = readCookie('madChickCssAdd')
					//console.log("Aktive:", aktiveState);
			} 
			
			displayControl(aktiveState);
			
			});
	});
}

displayControl = function(state) {
	// = state
	jQuery('#displayControlArea a').click(function() { 
		clickedId = jQuery(this.parentNode).attr("id");
		if(clickedId == "zoomMinus" && state != ''){
			if(state == 'xlarge'){
				madChickCss.swap('large', 'xlarge|bow');
			}else{
				madChickCss.remove('large');
			}
		}
		
		if(clickedId == "zoomPlus" && state != 'xlarge'){
			if(state == ''){
				madChickCss.add('large');
			}else{
				madChickCss.swap('xlarge', 'large|bow');
			}
		} 
		
		if(clickedId == "wob"){
			if(state == 'wob'){
				madChickCss.remove('wob');
			}else{
				madChickCss.swap('wob', 'xlarge|large|bow');
			}
		} 
		
		if(clickedId == "bow"){
			if(state == 'bow'){
				madChickCss.remove('bow');
			}else{
				madChickCss.swap('bow', 'xlarge|large|wob');
			}
		} 
		
	});
	
}

function readCookie(n){
 var a = document.cookie;
 var res = '';
// console.log('cookie:',a)
	while(a != ''){
		while(a.substr(0,1) == ' '){
			a = a.substr(1,a.length);
	  }
	  cookieName = a.substring(0,a.indexOf('='));
	//  console.log('name:',cookieName);
	  if(a.indexOf(';') != -1){
	  	cookieValue = a.substring(a.indexOf('=')+1,a.indexOf(';'));
	  } else{
	  	cookieValue = a.substr(a.indexOf('=')+1,a.length);
	  }
	  if(n == cookieName){
	  	res = cookieValue;
	  }
	  i = a.indexOf(';')+1;
	  if(i == 0){
	  	i = a.length
	  }
	  a = a.substring(i,a.length);
	}
	return(res)
}

