// JavaScript Document
$(document).ready(function(){
        
        $("#donors").salah_slider({
        "width":253,
        'easing':'easeOutElastic',
        'next' :'#next',
        'prev' :'#back',
        'interval':5000,
        'speed':2000
    });
    
function animate_poll(){
                    $('.survey_image').each(
                        function(){
                            var o_width=$(this).attr("width");
                            $(this).attr("width","0");
                            $(this).animate({width:o_width+"px"},1500);
                    });
                }
                animate_poll();
                var survey;
                $("input[type='submit'][name='survey']").bind('click',survey_click);
                function survey_click(){
                    if($(this).val()=="Results")
                        survey="show_results";
                    else
                        survey="send_vote";
                    }
                function submit_function(e){
                        var option1;
                        var survey_id;
                        survey_id= $(this).children("input[name='survey_id']").val();
                        option1=$(this).children(".poll_option").children("input[name='check_option'][checked='true']").val();
                        var sub_data="survey_id="+survey_id+"&check_option="+option1+"&survey="+survey;
                        //alert(survey);
                        $("#survey_overlay").fadeIn(300);
                        $.ajax({
                           type: "POST",
                           contentType:"application/x-www-form-urlencoded; charset=windows-1256",
                           scriptCharset:"windows-1256",
                           dataType:"html",
                           processData:false,
                           type:"post",
                           url: "survey/survey.php",
                           data: sub_data,
                           success: function(msg){
                             //alert( "Data Saved: " + msg );

                            $("#serv .survey").remove();
                            $("#serv #votes").remove();
                            $('#serv').append(msg);
                            $("#survey_overlay").fadeOut(800);
                            //$('#serv').append(msg);
                            //$(this).css("display","none");
                            //alert(msg);
                            animate_poll();
                            $('.survey').bind('submit',submit_function);
                            $("input[type='submit'][name='survey']").bind('click',survey_click);
                            //alert(msg);
                           }
                         });
                        //return false;
                        return false;
                    }
                $('.survey').bind('submit',submit_function);
		 	$(".main_news_snippet").stop().animate({ bottom:-200,opacity:0.7 }, 1 );
			$('ul.superfish').superfish();
			$('#s3').cycle({				   
				   fx: 'fade',
				   sync: 1,
				   timeout: 6000,
				   speed:2000,
				   /*easing:'easeOutQuint',*/
				   cssBefore: {top:0,left: -335,display: 'block','background':'none'},
				   cssAfter: {'background':'none'},
				   animIn:{left:0},
				   animOut:{top: 260},
				   /*delay: 4000 ,*/
				   before: function () {$(".main_news_snippet").stop().animate({ bottom:-200,opacity:0.7 }, 100 );},
				   after: function (){$(".main_news_snippet").stop().animate({ bottom:0,opacity:0.7 }, 500 );},
				   pager:'#nav',pagerEvent:'mouseover',pauseOnPagerHover:true,	pagerAnchorBuilder: function(idx, slide){
            return '#nav li:eq(' + (idx) + ') a';}	});	
			});
