
function Sendtofriend(){
		
			$("#frm_sendtofriend").find("[name=friendMail],[name=userMail],[name=submit]").attr('disabled',true);
			$('#sendToFriendDialogMessageFailure,#sendToFriendDialogMessagesuccess').hide();
			$('#sendToFriendDialogLoader').show();
					$.ajax({
					url: "index.php?pg=sendtofriend&disable_rewrite=1&plain=1",
					type:"POST",
					async: true,
					dataType:'json',
					data: {
						friendMail:$("#frm_sendtofriend").find("[name=friendMail]").val(),
						userMail  :$("#frm_sendtofriend").find("[name=userMail]").val(),
						cur_url   :document.URL
					},
					beforeSend: function(XMLHttpRequest) {
					},
					success: function(json){
								if(json.err) {
								   $('#sendToFriendDialogMessageFailure').html(json.msg).show();
								}else{
									$('#sendToFriendDialogMessagesuccess').html(json.msg).show();
									$('#sendToFriendDialogLoader').hide();
								    $("#frm_sendtofriend").find("[name=friendMail],[name=userMail],[name=submit]").attr('disabled',false);	
									setTimeout ("closeWin();", 5000 ); 
								}

					},
					error: function (XMLHttpRequest, textStatus, errorThrown) {
						alert('Server Error') ;
						$('#sendToFriendDialogLoader').hide();
						$("#frm_sendtofriend").find("[name=friendMail],[name=userMail],[name=submit]").attr('disabled',false);
					}
				});
		}	
/////////////////////////////////////////////////////////


 function print_content(){
				
					var prtContent = document.getElementById('print_div');
					var WinPrint =
					window.open('','','left=0,top=0,width=800px,height=500px,toolbar=0,scrollbars=1,status=0');
					WinPrint.document.write(prtContent.innerHTML);
					WinPrint.document.close();
					WinPrint.focus();
					WinPrint.print();
					WinPrint.close();
					prtContent.innerHTML=strOldOne;

			   
	}
	
	
		$(document).ready(function () {  
            if($('.print').length)$('.print').click(function(){print_page();});
           // if user clicked on button, the overlay layer or the dialogbox, close the dialog    
			 $('#dialog-overlay').click(function () {       
				 $('#dialog-overlay, #dialog-box').hide();         
				 return false;  
			 });  
       
			 // if user resize the window, call the same function again  
			 // to make sure the overlay fills the screen and dialogbox aligned to center      
			 $(window).resize(function () {      
					 //only do it if the dialog box is not hidden  
					 if (!$('#dialog-box').is(':hidden')) popup();  
		            $('.send-to-friend').click(function(){popup();});  
             });   
			 
			 if($('.gallery-container').length)$('.gallery-container').MySlider();
      });  
   
	 function closeWin(){
		  $('#dialog-box ,#dialog-overlay').hide(); 
	 }

	 //Popup dialog  
	 function popup() {  
		 // get the screen height and width    
		 var maskHeight = $(document).height();    
		 var maskWidth = $(window).width();  
		   
		 // calculate the values for center alignment  
		 var dialogTop =  (maskHeight/3) - ($('#dialog-box').height());    
		 var dialogLeft = (maskWidth/2) - ($('#dialog-box').width()/2);   
		 
		// assign values to the overlay and dialog box  
		 $('#dialog-overlay').css({height:maskHeight, width:maskWidth}).show();  
		 $('#dialog-box').css({top:dialogTop, left:dialogLeft}).show();  
		   
		 // display the message  
		 $('#dialog-message').html('<h1 align="center" style="clear:both;">Send to friend'+
								   '<a href="javascript:return false" onclick="closeWin()">'+
								   '<img src="'+g_templatepath+'/cdn/ecaru/images/closeWin.png" align="right" />&nbsp;</a>'+
								   '</h1>'+
								   '<form name="frm_sendtofriend" id="frm_sendtofriend" method="POST" onSubmit="Sendtofriend();return false;" >'+
								   '<p style="clear:both;">'+
								   '<label>Friend email</label><input type="text" name="friendMail" width="10px"  />'+
								   '</p>'+
								   '<p style="clear:both;">'+
								   '<label>Your email</label><input type="text" name="userMail"  />'+
								   '</p>'+
								   '<p style="clear:both;">'+
								   '<input type="submit" name="submit" value="submit" class="button"/>'+
								   '</p>'+
								   '<br />'+
								   '<div id="sendToFriendDialogMessageFailure"></div>'+
								   '<div id="sendToFriendDialogMessagesuccess"></div>'); 
		 
	 } 
	
	




	function print_page(){
			
					var disp_setting= "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=900, height=900, left=0, top=0"; 
					var content_value= $('.content').html(); 
					var docprint=window.open("","",disp_setting); 
					docprint.document.open(); 
					docprint.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Entag </title><link rel="stylesheet" type="text/css" href="'+g_templatepath+'/cdn/ecaru/css/style.css" media="all" />');				
					docprint.document.write('</head><body onLoad="self.print()" style="margin:20px 20px 20px 20px;"><center><div><div style="width:100%;margin-left:0px; clear:left;float:left;"><img src="'+g_templatepath+'/cdn/ecaru/images/27.png" align="left"/></div><div style="clear:left;float:left;">');          
					docprint.document.write('<table class="print-page"><thead></thead><tfoot valign="bottom" ></tfoot><tbody><tr><td class="page-tbody-container">'+content_value+'</td></tr></tbody></table></div>');          
					docprint.document.write('</div></center></body></html>'); 
					 
					docprint.focus(); 
					docprint.document.close();
	}
		

	
	
	
	
	
	
	
	
	
	
			$.fn.extend({		
			homeNewsBlock				: function(){
				element = $(this);
				var step= parseInt($(this).children('div:first').height()) + 10;
				if($(element).children('div').length > 2){
					setInterval	(function(){
									$(element).children('div:first').animate({marginTop:'-'+step+'px'},
																		function(){
																			$(this).appendTo($(this).parent()).css({marginTop:'8px'});
																		});
										}
										,4000);
							
							}
					},
					
					MySlider:function(){
						new MySlider().init(
									{
										element : $(this) 	,
										speed	: 500   	,
										VItems	: 3
									}
							  );
						},
						
						popup	: 	function(){
							$(this).click(function(){
																							
												
								$(document.body).append(($('.popup-bg').length ? "" : "<div class='popup-bg'></div><img src='"+LoaderPath+"' class='popup-loader' />"));	
												
								$('.popup-loader').css({'position':'fixed', 'left':'10px', 'top':'95%', 'z-index':20000});
								var me = $(this);   
								var pic = $(this).attr('pic');
								var img = new Image();
								
								$(img).load(function () {														
									$(document.body).append(($('.popup-bg').length ? "" : "<div class='popup-bg'>")+"</div>");
									$(document.body).append(this);
									var width		= 	$(me).width();
									var height		= 	$(me).height();
																						
									var top			= 	$(me).parent().offset().top;
									var left		= 	$(me).parent().offset().left;
									
									$(this).addClass('popup-image');
																										
									$('.popup-bg,.popup-image,.popup-loader').click(function(){$('.popup-bg,.popup-image,.popup-loader').remove();});	
																						
									var scrollTop 	= 	$(window).scrollTop();
									var realWidth 	= 	$(".popup-image").width();
									var realHeight 	= 	$(".popup-image").height();
									var pageHeight 	= 	$('.popup-bg').height();
									var pageWidth 	= 	$('.popup-bg').width();	
													
									$(this).css({visibility:'visible', border:"#276B9F solid 10px", "-webkit-border-radius":"10px", "-moz-border-radius": "10px", "border-radius": "10px", width:width+"px", height:height+"px", top:(parseInt(top) - parseInt(scrollTop))+"px", left:left+"px"}).animate({width:realWidth+"px", height:realHeight+"px", left:(	((parseInt(pageWidth) - parseInt(realWidth) )/ 2)	)+"px",  	top:(	((parseInt(pageHeight) - parseInt(realHeight) )/ 2)	)+"px"	});		
													
									setTimeout(function(){ $('.popup-loader').remove();}, 200);
											
								}).error(function () {
												
								}).attr('src', pic);
												  
								});								
						}
				});
		
		
		
	
	
	
	
	
	
	
	
	
	/* SLIDER */
	function MySlider(){
		
		this.element 	= '';
		this.interval	= null;
		this.delay		= 2000;
		this.speed	 	= 1000;
		this.step		= 0;
		this.leftArrow	= '';
		this.rightArrow	= '';
		this.itemsContainer= '';
		this.DMarginLeft= 0;
		this.activeImage= '';
		
		var me = this;
		
		
		this.init 		= function(settings){
			this.element 		= settings.element;
			this.speed			= settings.speed != undefined ? settings.speed : this.speed;
			this.itemsContainer	= $(this.element).find('ul');
			this.leftArrow		= $(this.element).find('.left-arrow');
			this.rightArrow		= $(this.element).find('.right-arrow');			
			this.step			= parseInt(this.itemsContainer.children('li').width());
			this.DMarginLeft	= parseInt(this.itemsContainer.children('li').css('margin-left'));
			this.minItemsToStart= settings.VItems != undefined ? settings.VItems : 3 ;

			if(this.itemsContainer.children('li').length >= this.minItemsToStart){
				this.leftArrow.click(function(){	me.moveLeft();	});
				this.rightArrow.click(function(){  	me.moveRight();	});			
				this.start();
			}
			
			this.itemsContainer.children('li').each(
				function(index, element){																
				$(this).children('a').children('img')
					.mousemove(function(){	
						me.stop();
						//$(this).css({'position': 'absolute',"width":(140+36)+"px", "height":"auto", "left":"-18px", "top":"-12px"});
					})
					.mouseout(function(){													   
						//$(this).css({'position': 'static',"width":"140px", "height":"100px", "left":"0px", "top":"0px"});
						me.start();				   	
					}).popup();
								
				});						
			
			//* SET Container Width for specific LIMIT Of images to display */
			$(this.element).width( 
								parseInt
								(
								  	(
									 	(parseInt(this.itemsContainer.children('li:first').width()) + 
										(parseInt(this.itemsContainer.children('li:first').css('margin-left')) * 2 )
										)
										*									
										this.minItemsToStart
									)
									+
									(parseInt(this.itemsContainer.find('.items').css('margin-left')) * 2)
								)	
							);
		
		}
		
		this.start 		= function(){
			if(this.itemsContainer.children('li').length  >= this.minItemsToStart)this.interval = setTimeout(function(){me.moveLeft();}, me.delay);
		}
		
		this.stop 		= function(){
			clearTimeout(me.interval);
		}
		
		this.moveLeft 	= function(){			
			this.stop();
			this.itemsContainer.children('li:first').stop().animate({marginLeft:"-"+me.step+"px"},me.speed, function(){
				$(this).appendTo(me.itemsContainer).css({marginLeft:me.DMarginLeft+'px'}); me.start(); 
																											  });
		}
		
		this.moveRight 	= function(){
			this.stop();
			this.itemsContainer.children('li:first').before(me.itemsContainer.children('li:last').css({marginLeft:"-"+me.step+'px'}));
			this.itemsContainer.children('li:first').animate({marginLeft:"+"+me.DMarginLeft+"px"}, me.speed, function(){ me.start();});
		}
		
		return this;
		
	}




