
	
/****************************************************************************************************
*
*	Copyright notice
*
*	This file is part of killerCMS.
*
*	killerCMS is a browser-based web content management system with in-place-editing features.
*	killerCMS was developed by Philipp Killer at web-manufaktur gmbh, Zurich from 2004 - 2011.
*
*   Copyright (C) 2004-2011 by Philipp Killer of web-manufaktur gmbh, Zurich
*	(killer@web-manufaktur.com, PhilippKiller@gmx.ch)
*
*    This program is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, version 3 of the License.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License version 3
*    along with this programm (killerCMS).  If not, see <http://www.gnu.org/licenses/>.
*
*	This copyright notice MUST APPEAR in all copies of the script and be left unchanged!
*	
****************************************************************************************************/
/*JavaScript Copyright notice*/	

	
	//
	//
	// add all js for special content here
	//
	//
	
	
	//
	// dbtal_switch_image (used first in: keller_referenzen)
	//
	$(function() {
		
		$('.dbtal_switch_image').live('click',function(evnt) {
			var rel = $(this).attr('rel');
			var relArr = rel.split(':');
			
			var src_new = $(this).attr('href');
			if (typeof(relArr)!='undefined' && relArr.length>1) {
				var id_tgt = relArr[1];
				
				var src_tgt = $('.'+id_tgt).attr('src');
				//alert('src_tgt='+src_tgt);
				//alert('src_new='+src_new);
				
					//TEMP: WORKING
				//$(this).find('>img').attr('src',src_tgt);
				//alert($('#'+id_tgt).attr('id'));
				//alert(src_new);
				
				//alert($('.'+id_tgt).length);
				
				//
				// switch image
				//
				$('.'+id_tgt).attr('src',src_new);//.before('<b>TEST</b>');
				
				
				//$('#'+id_tgt).prepend('<b>TEST</b>').remove();
				
				//alert( $('#'+id_tgt).attr('src') );
				
				//alert($('#'+id_tgt).parent().html());
				
				return false;
			}
			
		});
		
		
		//
		// dbtal_print_element (used first in: keller_referenzen)
		// - print link: <a class="dbtal_print_element" rel="cssFile|cssClassToAddToBody|printTargetClass|pageTitle">DRUCKEN</a>
		// - specifiy target <... class=".. printTargetClass" ...>
		//
		$('.dbtal_print_element').live('click',function(evnt) {
			//alert('hello');
			//alert($(this).attr('rel'));
			
			var rel = $(this).attr('rel');
			var relArr = rel.split('|');
			var cssFile = '';
			if (typeof(relArr[0])!=='undefined') cssFile=relArr[0];
			var cssClassToAddToBody = '';
			if (typeof(relArr[1])!=='undefined') cssClassToAddToBody = relArr[1];
			var printTargetClass= '';
			if (typeof(relArr[2])!=='undefined') printTargetClass= relArr[2];
			var pageTitle= '';
			if (typeof(relArr[3])!=='undefined') pageTitle= relArr[3];
			
			//alert(relArr);
			//NULL: alert( $(this).parents('.'+printTargetClass).html() );
			//alert( $('.'+printTargetClass).length );
			//alert($('.'+printTargetClass).html());
			
			// hide print link 
			//$(this).hide(); //not working
			//$(this).css('display','none'); //not working
			// --> try to hide '.dbtal_print_element' in cssFile
			
			
			// config for printing
			var printConfig = {
								  printMode:'popup'//'popup', 'iframe'
								  //,leaveOpen:true
								  ,pageTitle:pageTitle
							  };
			if (cssFile!='') printConfig['overrideElementCSS'] = [cssFile];
			if (cssClassToAddToBody!='') {
						//iframe
					printConfig['iframeElementOptions'] = {//alternative for popup: printBodyOptions
																				classNameToAdd:cssClassToAddToBody
																				//,styleToAdd:'display:block;visibility:visible;padding:10px;margin:10px;color:#ff0000 !important;'	
																			};
						//same for body
					printConfig['printBodyOptions'] = {//alternative for popup: printBodyOptions
																				classNameToAdd:cssClassToAddToBody
																				//,styleToAdd:'display:block;visibility:visible;padding:10px;margin:10px;color:#ff0000 !important;'	
																			};
			}
			var displ = $('.'+printTargetClass).css('display')
			$('.'+printTargetClass).css({display:'block'});//make lightbox content visible
			$('.'+printTargetClass).printElement(printConfig);//print
			$('.'+printTargetClass).css({display:displ});//make lightbox content hidden again
			
			// show print link again
			//$(this).show();
			
			
		});
		
	});
