window.addEvent('load', function() {
	
	$(document.body).getElements("a[name=chat]").addEvent('click', function(){
		window.open('http://www.wizsupport.com/collect/zimerimcoil/rchat.asp?lang=he','chat','width=450,height=450,noresize,noscroll');
  	});
  	
	$(document.body).getElements("a[name=mailus]").addEvent('click', function(){
		new Request.JSON({'url': '/req.php?r=/home/contactus/', 'onComplete': function(callback) {
			
			/* data */
			$('pop_content').set('html', callback.content);
			
			/* hiders */
			$('fb-close').addEvent('click',function(e) { $('fb-modal').fade('out'); });
			window.addEvent('keypress',function(e) { if(e.key == 'esc') { $('fb-modal').fade('out'); } });
			$(document.body).addEvent('click',function(e) { 
				if($('fb-modal').get('opacity') == 1 && !e.target.getParent('.generic_dialog')) { 
					$('fb-modal').fade('out'); 
				} 
			});
			
			$('fb-send').addEvent('click',function(e) { 
				$('contract-form').set('send', {url: '/req.php?r=home/contactus/send', method: 'post', onSuccess: function(callback){
					var response = JSON.decode(callback);
					if(response.status == "ok")
					{
						$('pop_content').set('html', response.content);
						$('fb-close').addEvent('click',function(e) { $('fb-modal').fade('out'); });
							window.addEvent('keypress',function(e) { if(e.key == 'esc') { $('fb-modal').fade('out'); } });
							$(document.body).addEvent('click',function(e) { 
								if($('fb-modal').get('opacity') == 1 && !e.target.getParent('.generic_dialog')) { 
									$('fb-modal').fade('out'); 
								} 
							});
					}
					else if(response.status == "faild")
					{
						$('note-messege').setProperty('class', 'mfaild').setStyle('display', 'block').getElement('.txt').set('html', response.content); 
					}
				}});
				$('contract-form').send();
			});
			
		}}).send();
		$('fb-modal').fade('in');
  	});
	
});
