/**
 * @author Stefan Heckler
 */

/* shadow plugin */
(function($){
    $.fn.cshadow = function(){
		//console.log($(this).parent().attr('href'));
		if($(this).parent().attr('href')){
			$(this).parent('a').wrap("<div class='shadow1'><div class='shadow2'><div class='shadow3'><div class='shadow4'></div></div></div></div>");
		} else {
			$(this).wrap("<div class='shadow1'><div class='shadow2'><div class='shadow3'><div class='shadow4'></div></div></div></div>");
		}
	}
})(jQuery);


/* dropshadow plugin */
/*(function($){
    $.fn.dropshadow = function(){

		console.log($(this).attr('class') + ' has ' + $(this).parent('a').attr('href'));
		if($(this).parent('a').attr('href')){
			$(this).parent('a').wrap("<div class='shadow1'><div class='shadow2'><div class='shadow3'><div class='shadow4'></div></div></div></div>");
		} else {
			$(this).wrap("<div class='shadow1'><div class='shadow2'><div class='shadow3'><div class='shadow4'></div></div></div></div>");
		}		
	}
})(jQuery);*/

/* text resize */
(function($){
	$.fn.textresize = function(){

		var $cookie_name = "textsize";
		var originalFontSize = "13";
		function write(n,w,e)
		{
			var a = new Date();
			a = new Date(a.getTime() +e);
			document.cookie = n+'='+w+'; expires='+a.toGMTString()+';';
		}

		function read(n)
		{
			a = document.cookie;
			res = '';
			while(a != '')
			{
		  		while(a.substr(0,1) == ' '){a = a.substr(1,a.length);}
	  			cookiename = a.substring(0,a.indexOf('='));
	  			if(a.indexOf(';') != -1)
	  			{cookiewert = a.substring(a.indexOf('=')+1,a.indexOf(';'));}
	  			else{cookiewert = a.substr(a.indexOf('=')+1,a.length);}
	  			if(n == cookiename){res = cookiewert;}
	  			i = a.indexOf(';')+1;
	  			if(i == 0){i = a.length}
	  			a = a.substring(i,a.length);
		 	}
			return(res)
		}

		if(document.cookie && read($cookie_name)){
			var $getSize = read($cookie_name);
			$("body").css({fontSize : $getSize+'px'});
		} else{
			write($cookie_name, originalFontSize, 100*60*60*24);
		}

		$("div.fontresize a.resize").bind("click",function(){
				$("body").css({fontSize : originalFontSize+'px'});
				write($cookie_name, originalFontSize, 100*60*60*24);
		});

		// increase font size
		$("div.fontresize a.increase").bind("click",function(){
				var currentFontSize = $("body").css("font-size");
				var currentFontSizeNum = parseFloat(currentFontSize, 10);
				var newFontSize = currentFontSizeNum+2;
				if (newFontSize < 20) {
					$("body").css({fontSize : newFontSize});
					write($cookie_name, newFontSize, 100*60*60*24);
				}
				return false;
		});

		// Decrease Font Size
  		$("div.fontresize a.decrease").click(function(){
  			var currentFontSize = $('body').css('font-size');
 			var currentFontSizeNum = parseFloat(currentFontSize, 16);
			var newFontSize = currentFontSizeNum-2;
			if (newFontSize > 12){
				$('body').css('font-size', newFontSize);
				write($cookie_name, newFontSize, 100*60*60*24);
			}
			return false;
  		});
	}
})(jQuery);


var $j = jQuery.noConflict();


$j(document).ready(function(){
      	/*
      	$('#intGallery').ajaxGallery({
      	    currentPage: 1,
      	    itemsPerPage: 6,
      	    totalPages: 1
      	});
      	*/
      	$j(".smallImages li:even").css("clear", "both");
      	
	// content round shadow
	//$("img.cshadow").cshadow();

	// rightcol dropshadow
	$j(".dropshadow, .cshadow, .flashshadow, .tx-swfobject-pi1").each(function(i) {


		// map hack
		if($j(this).children().attr('id') != null){

			$j(this).parent().css('height','135px');		

		}
		// farsi hack -.-
		if(document.getElementById('farsi') && $j(this).parents('.list_container').html() != null){
		
		} else {
			$j(this).cshadow();
		}
	});


	// flashmap shadow
	//$("div.flashshadow").cshadow();

	// text resize
	$j('body').textresize();
});

