﻿$(document).ready(function() {
  $('.random_ads').cycle({
 	fx:'scrollLeft',
    speed: 300,
    timeout: 4000
   }); 
   
   	$("#fb_popup").fancybox({
	'titleShow' : true,
	'titlePosition' : 'inside',
	'titleFormat'		: formatTitle,
	'showCloseButton'	: false,
	'showNavArrows'     : false,
         'autoScale'                : false
         
	});
	
	function formatTitle(title, currentArray, currentIndex, currentOpts) 
	{
        return '<div id="tip7-title"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="./new_images/safga_close_button.png" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' )+'</div>';
    }
   
 // safga poller start here
//	var loader=$('#loader');
//	var pollcontainer=$('#pollcontainer');
//	loader.fadeIn();
//	//Load the poll form
//	$.get('./poll.php', '', function(data, status){
//		pollcontainer.html(data);
//		animateResults(pollcontainer);
//		pollcontainer.find('#viewresult').click(function(){
//			//if user wants to see result
//			loader.fadeIn();
//			$.get('./poll.php', 'result=1', function(data,status){
//				pollcontainer.fadeOut(1000, function(){
//					$(this).html(data);
//					animateResults(this);
//				});
//				loader.fadeOut();
//			});
			//prevent default behavior
//			return false;
//		}).end()
//		.find('#pollform').submit(function(){
//			var selected_val=$(this).find('input[name=poll]:checked').val();
//			if(selected_val!= undefined){
//			    loader.addClass('clear_object');
//				//post data only if a value is selected
//				loader.fadeIn();
//				$.post('./poll.php', $(this).serialize(), function(data, status){
//					$('#formcontainer').fadeOut(100, function(){
//						$('#pollcontainer').html("<p style='font-family: Simplified Arabic; font-weight:bold; font-size:1.2em; color: #0C0;'>شكرا لتصويتك</p><a style='cursor:pointer;' id='viewresult_2' dir='rtl'>النتيجة »</a>").fadeIn();
//						//animateResults(this);
//						loader.fadeOut();
//						
//					});
//				});
//			}
//			else
//			{
//			    loader.html("الرجاء اختيار اجابه").css({display: 'block',
//			                                                color: '#C00',
//			                                                margin: '5px 15px 5px 5px',
//			                                                width: '200px'});
//			}
//			//prevent form default behavior
//			return false;
//		});
//		loader.fadeOut();
//	});
	
	
function animateResults(data){
		$(data).find('.bar').hide().end().fadeIn('slow', function(){
							$(this).find('.bar').each(function(){
								var bar_width=$(this).css('width');
								$(this).css('width', '0').animate({ width: bar_width }, 1000);
							});
						});
}
	
// safga poller ends here

$('#viewresult_2').live('click', function() {
		var title = "www.safga.net";
		$.fancybox.showActivity();
		$.ajax({
		url:  './poll.php',
		data: 'result=1',
		type: 'GET',
		success: function(responseText){
			$.fancybox(responseText);
		
}
  
  
    });
}); 

 
   
  
 });
