jQuery(document).ready(function (){
	jQuery("#menu").lavaLamp({
        fx: "backout", 
        speed: 700,
        click: function(event, menuItem) {
            return true;
        }              
    });   	
	
	jQuery('.testimonial_main').vTicker({
		speed: 10,
		pause: 5000,
		showItems: 1,
		animation: 'fade',
		mousePause: false,
		height: 0,
		direction: 'up'
		});
	
	jQuery('#search_field').bind('focus', function() {
        jQuery(this).val("");      
    });     
    
	jQuery('#add_working_experience_button').livequery('click', function (){
		jQuery(this).prev().after('<div class="working_experience"><label><b>Претходно работно искуство</b></label><br/><label>Компанија:</label><input type="text" size="40" name="company_name[]" /><br/><label>Област:</label><input type="text" size="40" name="company_area[]" /><br/><label>Стаж:</label><input type="text" size="40" name="company_internship[]" /><br/><label>Краток опис на работното место:</label><textarea style="height: 50px; width: 300px; vertical-align: top;" name="company_description[]"></textarea><br/></div>');
	    return false;
	});
	
	jQuery('.show_link').livequery('click', function(){
//		jQuery('.show_link').parent().parent().parent().find('.show_text').hide();
//		jQuery(this).parent().parent().parent().find('.show_text').toggle();
		if(jQuery(this).hasClass('open')){
			jQuery(this).removeClass('open');
			jQuery(this).parents('.testimonial_all').find('.show_text').hide('fast');
		}else{
			jQuery(this).parents('.about_us_text').find('.show_link').removeClass('open');
			jQuery(this).parents('.about_us_text').find('.show_text').hide('fast');
			jQuery(this).addClass('open');
			jQuery(this).parents('.testimonial_all').find('.show_text').show('fast');
		}
       return false;
	});
	
	jQuery('.show_link_1').livequery('click', function(){
//		jQuery('.show_link').parent().parent().parent().find('.show_text').hide();
//		jQuery(this).parent().parent().parent().find('.show_text').toggle();
		if(jQuery(this).hasClass('open')){
			jQuery(this).removeClass('open');
			jQuery(this).parents('.credits_tipe').find('.show_text_1').hide('fast');
		}else{
			jQuery(this).parents('.about_us_text').find('.show_link_1').removeClass('open');
			jQuery(this).parents('.about_us_text').find('.show_text_1').hide('fast');
			jQuery(this).addClass('open');
			jQuery(this).parents('.credits_tipe').find('.show_text_1').show('fast');
		}
       return false;
	});
	
		jQuery('.show_link_2').livequery('click', function(){
//		jQuery('.show_link').parent().parent().parent().find('.show_text').hide();
//		jQuery(this).parent().parent().parent().find('.show_text').toggle();
		if(jQuery(this).hasClass('open')){
			jQuery(this).removeClass('open');
			jQuery(this).parents('.codes_all').find('.show_text_2').hide('fast');
		}else{
			jQuery(this).parents('.about_us_text').find('.show_link_2').removeClass('open');
			jQuery(this).parents('.about_us_text').find('.show_text_2').hide('fast');
			jQuery(this).addClass('open');
			jQuery(this).parents('.codes_all').find('.show_text_2').show('fast');
		}
       return false;
	});
	
	jQuery('.change_img').livequery('click', function(){		
		if(jQuery(this).find("img").attr('src')=='images/design/down_1.png'){
			jQuery('.change_img').parent().parent().parent().find('.faq_text').hide('fast');
			jQuery('.change_img').find("img").attr({'src': "images/design/down_1.png", 'alt': "arrow down"});			
			jQuery(this).find("img").attr({'src': "images/design/up_1.png", 'alt': "arrow up"});
			jQuery(this).parent().parent().parent().find('.faq_text').show('fast');
			jQuery('.change_img').parents('.faq_all').find('.open_close_all a').text('отвори ги сите');
		}else if(jQuery(this).find("img").attr('src')=='images/design/up_1.png'){
			jQuery(this).find("img").attr({'src': "images/design/down_1.png", 'alt': "arrow down"});
			jQuery(this).parent().parent().parent().find('.faq_text').hide('fast', function () {
				var ok =true;
				jQuery(this).parents(".faq_tip").find('.change_img img').each(function (i, item) {            
			        if(jQuery(item).attr('src')=='images/design/up_1.png'){		 
			        	ok =false;			        	
			         }
			        });        
				if(ok){	
					jQuery(this).parents(".faq_tip").find('.open_close_all a').text('отвори ги сите');
				}
			});
			
		}		
		return false;
	});
	
	jQuery('.question_link').livequery('click', function(){		
		if(jQuery(this).next().find('.change_img img').attr('src')=='images/design/down_1.png'){	
			jQuery('.question_link').parent().parent().find('.faq_text').hide('fast');
			jQuery('.question_link').next().find('.change_img img').attr({'src': "images/design/down_1.png", 'alt': "arrow down"});
			jQuery(this).next().find('.change_img img').attr({'src': "images/design/up_1.png", 'alt': "arrow up"});
			jQuery(this).parent().parent().find('.faq_text').show('fast');			
		}else if(jQuery(this).next().find('.change_img img').attr('src')=='images/design/up_1.png'){
			
			jQuery(this).next().find('.change_img img').attr({'src': "images/design/down_1.png", 'alt': "arrow down"});			
			jQuery(this).parent().parent().find('.faq_text').hide('fast', function(){
				var ok =true;
				jQuery(this).parents(".faq_tip").find('.change_img img').each(function (i, item) {            
			        if(jQuery(item).attr('src')=='images/design/up_1.png'){
			           ok =false;
			         }
			     });
				if(ok){				
					jQuery(this).parents(".faq_tip").find('.open_close_all a').text('отвори ги сите');
				}
			});
		}
		return false;
	});
	
	jQuery('#open_general_lending').livequery('click', function(){
		if(jQuery(this).text()=='отвори ги сите'){
			jQuery(this).parent().parent().find('.change_img img').attr({'src': "images/design/up_1.png", 'alt': "arrow up"});;
			jQuery(this).parent().parent().find('.faq_text').show('fast');
			jQuery(this).text('затвори ги сите');
		}else if(jQuery(this).text()=='затвори ги сите'){
			jQuery(this).parent().parent().find('.change_img img').attr({'src': "images/design/down_1.png", 'alt': "arrow down"});;
			jQuery(this).parent().parent().find('.faq_text').hide('fast');
			jQuery(this).text('отвори ги сите');	
		}		
		return false;
	});
	
	jQuery('#open_lending_horizonti').livequery('click', function(){
		if(jQuery(this).text()=='отвори ги сите'){
			jQuery(this).parent().parent().find('.change_img img').attr({'src': "images/design/up_1.png", 'alt': "arrow up"});;
			jQuery(this).parent().parent().find('.faq_text').show('fast');
			jQuery(this).text('затвори ги сите');
		}else if(jQuery(this).text()=='затвори ги сите'){
			jQuery(this).parent().parent().find('.change_img img').attr({'src': "images/design/down_1.png", 'alt': "arrow down"});;
			jQuery(this).parent().parent().find('.faq_text').hide('fast');
			jQuery(this).text('отвори ги сите');	
		}		
		return false;
	});
	
	jQuery('#show_internship_form').livequery('click', function(){
		jQuery('#internship_form').toggle();
		return false;
	});
//	jQuery("#vote_button").livequery('click', function (){
//		jQuery("#form input").each(function (i, item) {			
//			if(jQuery(item).attr('checked')!=true){
//				jQuery(this).attr('disabled');
//			}
//		});		
//		return false;
//	});
});

//var ajax_vote = function (data){
//	var response;
//	jQuery.ajax({
//	type: "POST",
//	url: "_vote.php",
//	data: data,
//	cache: false,
//	dataType: "json",
//	success: function(html){            
//            console.log(html);
//            jQuery(window.location).attr('href', 'home.html');
////            for(var i=0; i<html.length; i++ )
////            {
////                if(html[i].value == profession_id)
////                {
////                    jQuery('#direction_high_school').append('<option value='+direction_registration[i].direction_id+'>'+direction_registration[i].direction_name+'</option>');
////                }
////            }
//		}	
//	});
//	return response;
//}
