(function($) {

var	$form      = '';
var	$options   = '';
var	$container = '';
var	$active    = '';
var	$query     = '';


$.fn.searchBar = function(options) {


  //  extends the default option for the plugin

				var mainOptions = $.extend({}, $.fn.searchBar.defaults, options);

	    return this.each(function() {


								$form      = $('form',$(this));
								$options   = $('ul > li:has(a[title])',$(this));
								$container = $('ul',$(this));
								$active    = $('#searchAction',$form);
								$query     = $('#query',$form);


									//Deactive submit event
									$form.submit(function(e){

											if ($query.val() != ''){
												if ($form.attr('action') === 'exception'){

													for(var i=0; i < mainOptions.searchOptions.length; i++){

														if ($active.val() == mainOptions.searchOptions[i].name){

																if (!mainOptions.searchOptions[i].action())
																		e.preventDefault();
														}
													}

												}
											} else {
												alert('אנא הזן שאילתא');
												$query.focus();
												return false;
											}
											return true;
									});

									$options.each(function (index){

                                       	if ($active.val() != ''){
													if ($active.value == mainOptions.searchOptions[index].name)
																$.fn.searchBar.update(mainOptions.searchOptions[index]);
											} else {
													if ($.trim(mainOptions.defaultOption) == mainOptions.searchOptions[index].name){
																$.fn.searchBar.update(mainOptions.searchOptions[index]);
													}
											}

										$(this).click(function(e){

												$.fn.searchBar.update(mainOptions.searchOptions[index]);
												e.preventDefault();
										});
									});


			});//each plugin event

	};//end plugin function

	$.fn.searchBar.update = function(obj){

		 $container.css('backgroundPosition',obj.pos);

			$form.attr({
																	'action'  : $.type(obj.action) === 'function' ? 'exception' : obj.action ,
																	'target'  : obj.target,
																	'method'  : obj.method == '' ? 'get' : obj.method
													});
			$active.val(obj.name);
	}



	$.fn.searchBar.defaults = {
            defaultOption : 'google',
			 searchOptions: [
						{name: 'google'  , pos: '280px 0' , action:'http://www.nrg.co.il/online/search.php', target:'_top' , method:''},
      {name: 'באתר'    , pos: '239px 0' , action:'http://www.nrg.co.il/online/search.php', target:'_top' , method:''},
						{name: 'דפי זהב' , pos: '193px 0' , action: function(){
										 var url = "http://www.d.co.il/?arena=Business&callback=Form_Find&language=HEB&page=Summaries&SimpleSearch=" + encodeURI($query.val());
											url="http://www.nrg.co.il/luach_nrg/owa/count_hit?board_num=1186&url="+escape(url);
											window.open(url, "_blank","","status=1,toolbar=1,width=100%,height=100%");
											return false;
							}, target:'_top',method:'' }
				]
	};

	})(jQuery);

	//serach Plugin




	
	//slideShowPlugin
	
	
	(function($) {

		var $stock   = '';
		var $buttons = '';
		var $active  = '';
		var $next    = '';
		var $buttons = '';


$.fn.slideShow = function(options) {
    
		var mainOptions = $.extend({}, $.fn.slideShow.defaults, options);
    
		return this.each(function() {
						
					$stock   = $(mainOptions.images,$(this)).children('li');
					$buttons = $(mainOptions.buttons,$(this));
     
					$active  = $(mainOptions.images,$(this)).children('li.active');
					$active  = $active.length > 0 ? $active : $($stock[0]);
					$next    = $active.next().length ? $active.next('li') : $($stock[0]);
					$buttons = $(mainOptions.buttons,$(this)).children('li');
					
					
					$buttons.each(function(){
							$(this).click(function(e){
											e.preventDefault();
											if (!$(this).hasClass('active'))
												$.fn.slideShow.switchImage($(this).index());											
							})																				
					});
					
						$t = setTimeout('$.fn.slideShow.switchImage()',mainOptions.delay * 1000);

								
		});//each plugin event	

	};//end plugin function


	$.fn.slideShow.switchImage = function(num){
     
			

			if(typeof num != 'undefined'){
				$next.stop(true,true);
				$next	= $($stock[num]);
				clearTimeout($t);		
			} else {
				$next = $active.next().length ? $active.next('li') : $($stock[0]);
			}
			
			$index = $next.index();

				$next.addClass('first');
				$active.removeClass('first');
 			$next.css('opacity',0)
								.addClass('active')
								.animate ({opacity: 1.0}, $.fn.slideShow.defaults.timeOut * 1000, function(){
																				$active.removeClass('active');
																				$t = setTimeout('$.fn.slideShow.switchImage()',$.fn.slideShow.defaults.delay * 1000);
																				$active = $next;
																	});
				
					
				$($buttons[$index]).addClass('active');
				$($buttons[$active.index()]).removeClass('active');
}
	
	
	$.fn.slideShow.defaults = {
			images    : ''     ,
			buttons   : ''     ,
			timeOut   : .5     ,
			delay     :  5   
			
	};
	
	})(jQuery);


	//sliderPlaugin
(function($){
	$.fn.playVideo = function(options) {
	var mainOptions = $.extend({}, $.fn.playVideo.defaults, options);
	return this.each(function() {
		
		var html = $(mainOptions.html);
		var url  = $('a',$(this)).attr('href');
		var title = $('a img',$(this)).attr('title');
		
		$(this).mouseenter(function(){
			if ( $('.over',$(this)).length == 0 ){
				$(this).append(html);
				$(html).addClass('over');
			}
		});
		
		$(this).mouseleave(function(){
			$('.over',$(this)).remove();
		});
		
		if (mainOptions.goTo){				//this is a Standard link 
		$(this).click(function(){
				location.href = url; 
			});
		}else{ 								//this is a nrg video light box
			$(this).click(function(){
					$('[id^="CM8"]').css("visibility","hidden");
					$("body").append("<div id='videoLightBox'></div>");
					$("#videoLightBox").animate({opacity: 0.7 }, 500, function() {
																				
						var topPosition = 	(($(window).height()-501)/2);
						
						if(topPosition < 0){
							topPosition = 0
							
						}
						
						$("body").append('<div id="allvideoWrapper" style="top:' + topPosition +'px;">'+
						'<div class="videoWrapper"><div id="silverlightControlHost" >'+
						'<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="630" height="501">'+
						'<param name="source" value="http://nrgplayer102.casttime.net/ClientBin/CTMExternalPlayer.xap"/><param name="onload" value="onSilverlightLoad" />'+
						'<param name="onError" value="onSilverlightError" /><param name="background" value="white" />'+
						'<param name="minRuntimeVersion" value="4.0.50826.0" /><param name="autoUpgrade" value="true" />'+
                        '<param name="enableGPUAcceleration" value="true"/><param name="enableHtmlAccess" value="true" />'+
						'<param name="initParams" value="UserID=F7A6AF31-59EB-44CA-9BBF-C792262F967B, '+ url +',PlayerTheme=NRG, AutoPlay=True" />'+
						'</object></div></div></div>');
						
						$('#allvideoWrapper').css("display","block");
						$('#allvideoWrapper').animate({opacity: 1 }, 500);
						
						$("#videoLightBox, #allvideoWrapper, #videoCaption").click(function(){
							removeVideo();
						});
						
						$(document).keyup(function(e){
							if (e.keyCode == 27) {
							removeVideo();
							}			
						});					
					});
					
	
					
				
				});
		}// end else
	});
	};
	
	
					
	$.fn.playVideo.defaults = {
			html         : '',
			goTo         : true,
			linkLocation : 'a'
			
	}; 
		  
})(jQuery);

function removeVideo(){
							$('[id^="CM8"]').css("visibility","visible");
							$('#allvideoWrapper object').remove();
							$('#allvideoWrapper').remove();
							$('#videoLightBox').animate({opacity: 0.2 }, 500, function() {$(this).remove(); });
					}

	
(function($) {


$.fn.slider = function(options) {
		

	return this.each(function() {
		
		//Declare vars
		var mainOptions   = $.extend({}, $.fn.slider.defaults, options);
		
		var $container    = $(mainOptions.container,$(this));
		var parent        = $(this);
		var $buttons      = {};
		var $itemSize     = 0;
		var $windowWidth  = $container.innerWidth();
		var obj           = {};
		
		
		if ($container.length > 0) {
			
			var $content    = mainOptions.content != '' ?  $(mainOptions.content ,$container) : $('ul',$container);
			var $items        = $content.children('li');
			
			
			if (mainOptions.direction == 'horizontal') {
				
				$buttons  = {right :	$(mainOptions.buttons.right,parent),	left  : $(mainOptions.buttons.left,parent) }
				
			 $itemSize = $($items[0]).outerWidth(true);
				obj       = {
																		'css'        : 'marginRight' ,
																		'side'       : 'right',
																		'windowSize' : $container.innerWidth()																		
																}
			} else {
				$buttons  = {right :	$(mainOptions.buttons.up,parent), left  : $(mainOptions.buttons.down,parent) }
				$itemSize = $($items[0]).outerHeight(true);
				obj       = {
																		'css'        : 'marginTop' ,
																		'side'       : 'up',
																		'windowSize' : $container.innerHeight()														
															 }
			}
			
			//alert($(mainOptions.buttons.up,parent).attr('class'));
			
		
			var $totalSize    = mainOptions.direction == 'vertical' ? $content.outerHeight() : $itemSize * $items.length;


if ($totalSize / obj.windowSize < 1.1 && $totalSize / obj.windowSize > 0.99){
		$($buttons.right).css('display','none');
		$($buttons.left).css('display','none');
}
				
			
			//add buttons Event
			if(mainOptions.pressButtons != ''){
				var pressButtons = $(mainOptions.pressButtons,$(this)).children('li');
				
				if (pressButtons.length > 0){
						
					
					pressButtons.each(function(){
							$(this).click(function(e){
												
										$content.stop(true,true);									
										e.preventDefault();
										
										var margin     = Math.abs(parseInt($content.css(obj.css)));
										var goTo       = $itemSize * $(this).index();
									

									
									
										var aniArgs = {};	
																		
									aniArgs[obj.css] = -goTo + mainOptions.border;
									$content.animate(
																										aniArgs,
																										mainOptions.speed*1000,
																										mainOptions.transition,
																										function(){
																											mainOptions.endFunction($container,$content,$totalSize);
																										});
							if (goTo == 0){
								$($buttons.right).addClass('disabled');
						//	 alert('f');
							}else if(goTo == $totalSize - margin - obj.windowSize)
								$($buttons.left).addClass('disabled');
							else
								$.each([$buttons.right, $buttons.left],function(){
										$(this).removeClass('disabled');
									});
								
								$('.active',$(this).parent()).removeClass('active');
								$(this).addClass('active');
								
							
							});																									
					});										
				}
			}
			
			$.each([$buttons.right, $buttons.left],function(){
					this.bind(mainOptions.eventType, function(e){
							$content.stop(true,true);									
							e.preventDefault();
							
							var distance   = 0;
							var step       = mainOptions.slideItems * $itemSize;
							var side       = $(this).attr('class').toLowerCase().indexOf(obj.side) > -1 ? '+' : '-';
							var margin     = Math.abs(parseInt($content.css(obj.css)));
							

								
							if (side == '-'){
									distance  =  $totalSize - margin - obj.windowSize;
								 distance  = step >= distance ? distance+mainOptions.border >= $itemSize ? (Math.floor((distance+mainOptions.border)/$itemSize)*$itemSize) : $itemSize - (distance+mainOptions.border) < 10 || $itemSize/2 < (distance+mainOptions.border) ? distance : 0 : step;	         
						} else {
									distance   = step >= margin ? margin : step;									
									distance   = distance == mainOptions.border ? 0 : distance+mainOptions.border >= $itemSize ? (Math.floor((distance+mainOptions.border)/$itemSize)*$itemSize) : distance ;
						}
								
					if(mainOptions.direction == 'horizontal' && ( parseInt($content.css('paddingRight')) > 0 ) ) {
						if(margin + $windowWidth == $totalSize - distance) {
							distance  = mainOptions.marginSize + distance + (parseInt($content.css('paddingRight'))*2);
								$content.css('backgroundPosition',Math.abs(parseInt($content.css('width')) - ((margin + distance+$windowWidth)- parseInt($content.css('paddingRight'))*2 )) + 'px 0');
						} else if (Math.abs(margin) - distance == 0){							 
							 $content.css('backgroundPosition','right 0');
							}					
					} 						
							if (distance > 0){
									
									var aniArgs = {};	
																		
							
									aniArgs[obj.css] = side + '=' + distance;
									$content.animate(
																										aniArgs,
																										mainOptions.speed*1000,
																										mainOptions.transition,
																										function(){
																											mainOptions.endFunction($container,$content,$totalSize);
																											
																												var margin     = Math.abs(parseInt($content.css(obj.css)));
																												if (typeof pressButtons != 'undefined')
																												{
																													
																													$('.active',$(pressButtons[0]).parent()).removeClass('active');
																													
																													if (!$(pressButtons[Math.floor(margin / $itemSize)]).hasClass('active'));
																														$(pressButtons[Math.floor(margin / $itemSize)]).addClass('active');
																												}
																												
																											
																										}
										);//end function, end Animate	
									
									$buttons.right.removeClass('disabled');
									$buttons.left.removeClass('disabled');
									
								} else {
									$(e.target).addClass('disabled');
								}// end if distance > 0

						});		//end bind																																										
				}); // end each element
			} // end if find an element
		});//each plugin event
	};//end plugin function

	$.fn.slider.endFunction = function(){}

	$.fn.slider.defaults = {
		 container        : '',
			buttons          : {left: '.left-arrow',right: '.right-arrow',up: '.up-arrow',down: '.down-arrow'},
			content          : 'ul',
			direction        : "horizontal",
			speed            : .5,
			slideItems       : 1,
			transition       : 'swing',
			eventType        : 'click',
			border           : 0,
			pressButtons     : '',
		 endFunction      : function(){}
	};
	
})(jQuery);
	

(function($) {

$.fn.tabs = function(options) {
	
	var mainOptions = $.extend({}, $.fn.tabs.defaults, options);
	
	return this.each(function() {
			var tabs = $(mainOptions.tabs, $(this)).children('li');
			var par  = this;
			
			tabs.each(function(){
				$(this).click(function(e){
						e.preventDefault();
						$('.active',$(this).parent()).removeClass('active');
						$(this).addClass('active');
						
						$('.items:visible',par).each(function(){ $(this).addClass('hide') });
						$($('.items',par)[$(this).index()]).removeClass('hide');
						//morph($('.items:visible',par),$($('.items',par)[$(this).index()]),1);
						
				});			
			});
	});
			
	};

	$.fn.tabs.defaults = {
		tabs      : '',
		content   : ''
	};
	
	})(jQuery);




(function($) {

$.fn.over = function(options) {
	
	var mainOptions = $.extend({}, $.fn.over.defaults, options);
	
	return this.each(function() {
		var html = $(mainOptions.html);
		var url  = $('a',$(this)).attr('href');
		

		$(this).mouseenter(function(){
			if ( $('.over',$(this)).length == 0 ){
				$(this).append(html);
				$(html).addClass('over');
			}
		});
		
		$(this).mouseleave(function(){
			$('.over',$(this)).remove();
		});
		
		if (mainOptions.goTo){
		$(this).click(function(){
				location.href = url; 
			});
		}

	});
			
	};

	$.fn.over.defaults = {
			html         : '',
			goTo         : true,
			linkLocation : 'a'
			
			
	};
	
	})(jQuery);








(function($) {

$.fn.openMenu = function(options) {
	
	var animationTypes = ["fade","slide"];  
	var mainOptions   = $.extend({}, $.fn.openMenu.defaults, options);
	//add close btn handle
	
	return this.each(function() {
			if (mainOptions.button != '' ){
				var btn  = $(mainOptions.buttons);
				var div  = $(this); 
				
				btn.each(function(){
					if ($.inArray(mainOptions.animation, animationTypes) > -1){
						btn.bind(mainOptions.event, 
							function () {
									switch(mainOptions.animation){
											case "fade":											
											  div.fadeToggle(mainOptions.speed*1000,"swing");													
											break;												
											case "slide":
													div.slideToggle(mainOptions.speed*1000,"swing");
											break;
											
											}
																						
						});
					 }
						
				});
				
			}
			
	});

}

	$.fn.openMenu.defaults = {
		 speed          : .5,
		 buttons        : '',
			outBtn         : '',
			event          : 'click',
			animation      : 'slide'
			
	};
	
	})(jQuery);


function goToLink(a) { 
    var url = "http://www.nrg.co.il/luach_nrg/owa/count_hit?board_num="+ $(a).attr('class') +"&url=" + $(a).attr('href');
    window.open(url);
    return false;
}


	
function runClock(){
	$.get('/cache/banners/gettime.php',
							
							function(data){ 
						  //alert(data);
								var serverDate = new Date();
						  data = eval('(' + data + ')');
																
								
								serverDate.setHours(data[0]);
								serverDate.setMinutes(data[1]);
								serverDate.setSeconds(data[2]);
													
								$('#date').html('<span></span>&nbsp;' + data['heb_date']+', '+data['foreign_date']);
								$('#foreignDate').html((data['foreign_date'].replace(/\//gi,'.')));
								updateClock(serverDate.getTime());
						
					});
}

function updateClock(time){
	
	var clock = new Date(time);
	
	var hours   = clock.getHours();
	var minutes = clock.getMinutes();
	
	hours   = hours    <  10  ?  "0" +  hours   :  hours;
	minutes = minutes  <  10  ?  "0" +  minutes :  minutes;

	
	$('#date > span').html(hours + ":" + minutes+ "&nbsp;&middot;");	
	setTimeout(function(){updateClock(time + 1000)},1000);

}



var tools = {
				URLEncode : 
							function (clearString){ 
								clearString = escape(clearString);
								clearString = clearString.replace(/(\%(u05[A-Z0-9]{2}))/g, 
		            function(full, m1, m2) { return "%"+(parseInt(m2.replace('u',''),16) - 1264).toString(16).toUpperCase();})
								return clearString;
				},
				
					URLDecode   : 
							function (clearString) 
		          {    
								clearString = unescape(clearString);
					   var retval='';
					   for (a=0;a<clearString.length;a++)
						 			if (clearString.charCodeAt(a)>=224&&clearString.charCodeAt(a)<=(224+26) )   // Hebrew
						   		retval=retval+String.fromCharCode(clearString.charCodeAt(a)+1264);
						 			else if (clearString.charCodeAt(a)==43) // Space
						   		retval=retval+' ';
						 			else
						   		retval=retval+clearString.substr(a,1);
					  
							return retval;
				  }
}

var userAuthentication = {
	  
			verifyUser    :	function () {return !($.cookie('maariv_nrg') === null )},
			getUserName	  : function () { return	tools.URLDecode(($.cookie('maariv_nrg')).substr(0,($.cookie('maariv_nrg')).lastIndexOf('%'))); },
			getUserEncrId : function () { return	tools.URLDecode(($.cookie('maariv_nrg')).substr(($.cookie('maariv_nrg')).lastIndexOf('%')+1)); },   
   
			init : function(firstTime){
				if (this.verifyUser()) {
					var bloggerHtml = '';
	if ($.cookie('maariv_nrg_blogger') !== null) { bloggerHtml = '<li id="blogsMember"><a href="http://www.nrg.co.il/app/?do=blog">בלוגים</a></li>'}
					$("#login").html('שלום <span class="strong">' + this. getUserName() + '</strong>')					
					.attr({'class':'icons','href' : '#','id':'helloUser'})					
					.parent().css('position','relative').attr('id','members')
					.append($('<div id="userControl"><ul>'+ bloggerHtml +'<li><a class="iframe" href="/app/index.php?do=members&op=change_pass_page&ver=2011">שינוי סיסמא</a></li><li><a class="iframe" href="/app/index.php?do=members&op=change_email_page&ver=2011">שינוי דוא"ל</a></li><li><a class="iframe" href="#">יציאה</a></li></ul></div>'));
     $('#register').parent().remove();
				  var ctrl = $("#userControl > ul > li a");
      $(ctrl).each(function(){
							switch($(this).html()){
								case 'שינוי סיסמא':
									$(this).fancybox({
	 										 width  : 300,
											 height : 0

										});
								break;
								case 'שינוי דוא"ל':
								$(this).fancybox({
	 										 width  : 300,
											 height : 0
										});
								break;
								case 'יציאה':
									$(this).click(function(){ userAuthentication.logout() });
								break;
							}	
						});


					} else{
							var elm = firstTime ? $("#login") : $("#helloUser") ;

							$(elm).html('כניסה').attr({'class':'iframe','href' : '/app/?do=members&op=login&ver=2011','id': 'login'});
                            if ($('#register').length == 0)
                            $('<li><a id="register" class="iframe" href="/app/?do=members&op=register&ver=2011">הרשמה</a></li>').insertAfter($('#login').parent());
                            $('#userControl').remove();
							$("#login").fancybox({
	  							width  : 274,
                                height:  0

							});
                            $("#register").fancybox({
	                            width  : 274,
                                height:  0
                            });
							 
					}
					
			},
			
			logout : function(){
						$.cookie('maariv_nrg', 'null', { expires: -1, path: '/',domain: 'nrg.co.il', secure: false });
						$.cookie('maariv_nrg_un', 'null', { expires: -1, path: '/',domain: 'nrg.co.il', secure: false });
						$.cookie('maariv_nrg_forum', 'null', { expires: -1, path: '/',domain: 'nrg.co.il', secure: false });
						$.cookie('maariv_nrg_blogger', 'null', { expires: -1, path: '/',domain: 'nrg.co.il', secure: false });

userAuthentication.init();

					
			}
			
  
		}

function ScoopMail() {
	window.open("/Scripts/ScoopMail/scoopmail.html?c="+appl,"_blank", "toolbar=no,location=no,scrollbars=yes,resizable=yes,width=570,height=700,top=20,left=20");
}

function ScoopMailGreen() {
 window.open("/Scripts/ScoopMail/greenscoopmail.html?c=459","_blank", "toolbar=no,location=no,scrollbars=yes,resizable=yes,width=976,height=756,top=20,left=20");
}

function openContactWin(x){

  window.open("/online/nrg/contact_us.html?c="+x,"_blank", "toolbar=no,location=no,scrollbars=no,width=482,height=415"); 

return false;

}

function reloadPage(m){
	setTimeout(function(){location.reload()},(60*1000)*m);
}
function reloadBanners(m){
	setTimeout(function(){CM8AjaxRefresh('!Plasma_935x180,elyon_960x90,MegaPlasma_935x300,Maavaron_960x400,Count');},(60*1000)*m);
}


function setTraklinCount(){
 $.post('/luach_nrg/owa/count_hit',{board_num: "2016" ,URL: "#footerPlazma"});
	
	var dest = $('#CM8ShowAd_FooterPlasma_960x200');
if (dest.length > 0)
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: (dest.position().top - ($(window).height()/2 - dest.outerHeight()) )}, 500 );

}

function setBanners(){
	var _bannersElements = $('[id^="ban"]').not('[id^="banner"]');
	
	if (typeof banners != "undefined" ){
	
		$(_bannersElements).each(function(){
			var num = ($(this).attr('id')).substring(3,($(this).attr('id')).length);
   if(typeof  banners[num] != 'undefined')
				$('#ban'+ num).append($('<iframe src="/cache/banners/ban_m.php?vnum=111&vpage='+ banner_page +'&loc='+ num+'" width="'+ banners[num][1] +'" height="'+ banners[num][0] +'" id="'+ num +'" marginwidth="0" marginheight="0"  hspace="0" vspace="0" scrolling="no" frameborder="0"></iframe>'));
		});
	}
}

$.fn.loadContent = function(placeHolderId,callBack){
	var placeHolders = $(placeHolderId,this);
	$(placeHolders).each(function(index){
		if ($(this)[0].tagName.toLowerCase() === 'a')
				var url    = $(this).attr('href');
				var _this  = $(this);
				var _index = index;
				$.get(url,
					function(data){
						if (data !== '') 
								_this.replaceWith(data);								
								if (_index == placeHolders.length-1) 
									$(document).trigger('loadContentCompleted');
					});
 });	
}

var pp_gemius_identifier = '';
function loadGemius(){		

 pp_gemius_identifier = new String("zaA1xON8FcWviUKBWrMiuMdRnOjw.BhXWYwZSUHclV..h7");
	$.getScript('/online/nrg/include/js/xgemius.js');

}

function isEmail(string){
	if(!string) return true;
		else return (/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/).test(string);
}

function sendDealsEmail(f){
	var email = $('#email',f).val();
	if(email != ''){
		if (isEmail(email)){
			$.get('/online/nrg/include/send_deal_email.php?email='+ email, function(d) {
					alert(d);
			});
		}else
			alert('האימייל שהזנת אינו תיקני');
	} else
			alert('לא הוזן אימייל');																																							
	return false;
}

//
function sendNewDealsEmail(f){
	var myemail = $('#email',f).val();
	if(myemail != ''){
		if (isEmail(myemail)){
			$.post('/Scripts/hachizol/index.php', {email: myemail}, function(d) {
					alert(' תודה על הרשמתך ');
			});
		}else
			alert('האימייל שהזנת אינו תיקני');
	} else
			alert('לא הוזן אימייל');																																							
	return false;
}

function fixbannergap(){
 if ($('#ban500').css('display') == 'none'){
		$('#topUserBar').css('width','655px');	
		$('#topUserBar').css('zoom','1');
		if( $.browser.msie){
			$('#topUserBar').css('overflow','hidden');
		}
	} else {
	  setTimeout(function(){fixbannergap();},100);
	}	
}

/*
*  jobzone
*/
function setField(input)
{
	if( $.trim( $(input).val() ) == 'חיפוש חופשי')
	{
		 $(input).val('');
	} 
}

function validJobzoneForm(frm){
	var fs =  $('input[name="freeText"]',$(frm) ).val();
	if ($.trim(fs) ==  'חיפוש חופשי'  )
	{
		$('input[name="freeText"]', $(frm) ).val('');
	}
	frm.submit();
	setTimeout( function(){ $('input[name="freeText"]', $(frm) ).val('חיפוש חופשי'); },1);
	return false;
}
	
function updateJobzonePrice()
{
	
	var m  = $('select[name="nmwa"]', $('form[name="jobzoneAdv"]') ).val(),
		am = $('select[name="ajwa"]', $('form[name="jobzoneAdv"]') ).val();
	if (m > 0 && am > 0){					
		$.post('/online/jobzone_box_ajax.php', 
		{
			month: m,
			amount: am
		},
		function(data) {							
			if (data)
			{
				if ($('#jobzonePrice').length > 0) {
					$('#jobzonePrice').html('עלות: '+ data + ' &#8362;');
					$('#w_price').val(data);
				}
			}
		}
		);
	} else
	{
		if ($('#jobzonePrice').length > 0) {
			$('#jobzonePrice').html('עלות:');
			$('#w_price').val('0');
		}
	
	}
}





	
//main
$(document).ready(function(){

setBanners();
runClock();																												
loadGemius();
fixbannergap();

$('#todayBefore > a').click(function(e){  
								$('#weather > .moreCities').slideUp();		
								$('#todayBefore > .moreBefore').slideToggle();	
								 e.preventDefault();
    });


$('#searchBar').searchBar();
userAuthentication.init(true);
/*$("#sethomePage > a, #setHomepageFF > p > a").click(function(){
		$("#setHomepageFF").slideToggle("slow");

});*/

$("#sethomePage > a, #setHomepageFF > p > a").click(function(){
		if( $.browser.msie){
			document.getElementById("sethomePage").style.behavior='url(#default#homepage)'; 
			document.getElementById("sethomePage").setHomePage("http://www.nrg.co.il/");
		}
		else{
		$("#setHomepageFF").slideToggle("slow");
		}
});



$('#mainStoryDiv').slideShow({images: '.imgStock', buttons: $('ul','#mainStoryDiv > #imgStrip')});

$('#newVideoBox #videoHolder div.nrgVideo').playVideo({html:'<div class="vidOver"><span class="playIcn"></span><div class="overlayBg"></div></div>', goTo:false});
$('#newVideoBox #videoHolder div.linkVideo').playVideo({html:'<div class="vidOver"><span class="playIcn"></span><div class="overlayBg"></div></div>', goTo:true});

if ($('#makoBoxNew').length > 0 ){
			$('#makoBoxNew ul li').over({html:'<div class="vidOver"><span class="playIcn"></span><div class="overlayBg"></div></div>'});
		}


	$('#videoBox ul li').over({html:'<div class="vidOver"><span class="playIcn"></span><div class="overlayBg"></div></div>'});
	$('#videoBox').slider({
		container        : '.horizontalSlide',
		slideItems       : 1,
		marginSize       : 1

		});

		
		if ($('#makoBox').length > 0 ){
			$('#makoBox ul li').over({html:'<div class="vidOver"><span class="playIcn"></span><div class="overlayBg"></div></div>'});
			$('#makoBox').slider({
				container        : '.horizontalSlide',
				slideItems       : 1,
				marginSize       : 1

				});
		}
		
			$('.imgOrdering').slider({
				container        : '.horizontalSlide',
				slideItems       : 1,
				marginSize       : 1

		});

		$('.channelBox').slider({
				direction:        'vertical',
				container        : '.slideDiv',
				slideItems       : 1,
				border:           29

		});

		$('#magazine').slider({
				container        : '.rightColumnInner',
				slideItems       : 1,
				pressButtons     : '.buttons'
		});
		$('#moreMagazine').slider({
				container        : '.horizontalSlide',
				slideItems       : 1

		});

$(document).bind('loadContentCompleted',function(){

		$('.leftBox').tabs({
			tabs:'.tabs',
			content: '.items'
	});



   $('#weather > .moreCities .close').click(function(e){
        $('#weather > .moreCities').slideUp();
								e.preventDefault();
   })
   $('#weather > a').click(function(e){ 
								$('#todayBefore > .moreBefore').slideUp();
								$('#weather > .moreCities').slideDown();	
								 e.preventDefault();
    });

	/* ie tab width fix*/
	
	 if ($.browser.msie) {
		$('.leftBox ul.tabs').each(function(index) {
				$(this).css("width",$('li:first-child',this).innerWidth() * ($(this).children('li').length) + ($(this).children('li').length*2));							
 		 });
  }
reloadBanners(2.5);
reloadPage(5);
});

$(document).loadContent('.placeHolder');

});
