$(document).ready(function(){



    // NAVBAR MOVEMENT AND HIGHTLIGHTING
	
	$('.main-nav li').hover(function(){
        $(this).addClass('selected');
    }, function(){
        $(this).removeClass('selected');
    });
    
    $('.home_nav li').hover(function(){
        $(this).addClass('selected');
    }, function(){
        $(this).removeClass('selected');
    });
    
	//jquery selectbox next to searchbar
	
	$('#searchselect').sSelect();

    
    // clinic hours dropdown
    
    $('.hours2').hide();
    
    $('.hours').click(function(){
        $('.hours2').show();
        
    });
    
    $('.hours2').bind('click mouseleave', function(){
        $(this).fadeOut();
    });
    
    
    //hide symptom checker on load
    
    $('body#sympcheck #checker').hide();
    
    //enable the search selctor plugin
    
    
    //toggle symptom checker
    
    $('body#sympcheck #symp_check').toggle(function(){
        $('body#sympcheck #checker').slideDown(), $('body#sympcheck #symp_check').css('border-bottom', '0px'), $('body#sympcheck #checker').css('border-top', '0px');
        
    }, function(){
        $('body#sympcheck #checker').slideUp(), $('body#sympcheck #symp_check').css('border-bottom', 'solid 1px #c7c0a7');
    });
    
   
    
    
    
    //hide the modal symptom checker
    
    $('#checker2').hide();
    
    
    
    
    //toggle common questions
    
    
    $('.cq_answer').hide();
    
    $('#common_q li a').click(function(){
        $(this).next().slideToggle('normal');
    });
    

    
    //remove p tags around anchors in common questions that are added by Wordpress
    
   /*  $('#common_q a').unwrap(); */
	$('#preg_info_right_box img').unwrap();
    
    
    
    //add arrows to int_box
   // $('#int_box li a:first-child').addClass('rArrow').prepend("<img src='" + mypath + "arrow_right_trans.gif' class='right_arrow'>" + "&nbsp");
	
	//hilight arrows on active links in int_box
	
	//$('#int_box ul li.current_page_item .rArrow, #int_box ul li.current_page_ancestor .rArrow').children('img').attr('src', mypath + 'arrow_right_hov.gif');
    
	
	
	//remove hover effect on current page item
	
	//$('#int_box li.current_page_item a:first, #int_box li.current_page_ancestor a').removeClass('rArrow');
	
    //remove arrows on children in int_box
    
   // $('#int_box li ul li a').removeClass('rArrow');
    //$('#int_box li ul li a img').hide();
	

    
    //arrows after links on right content, main h3s
    
    //$('.right_box a, .low_cont_text a, body.page-template-about-php .row a, body.page-template-health-php .row a, .store_pop_left a, body.page-template-home-php .row a').addClass('rArrow').append("&nbsp <img src='" + mypath + "arrow_right_trans.gif' class='right_arrow'>");
    //$('#pop3 a').addClass('rArrow2').append("&nbsp <img src='" + mypath + "arrow_right_trans.png' class='right_arrow'>");
	
	
	//	$('.rArrow').hover(function(){
	//		$(this).children('img').attr('src', mypath + "arrow_right_hov.gif");
	//	}, function(){
	//		$(this).children('img').attr('src', mypath + 'arrow_right_trans.gif');
	//	});
	
    
    //arrows after links on common questions and symptom checker, change arrows
    
    $('body#sympcheck #symp_check, #common_q li a').addClass('dArrow').append("&nbsp <img src=" + mypath + "arrow_down.gif>");
    
    
    // toggle symptom check arrows
    
    $('#symp_check').toggle(function(){
        $('#symp_check img').attr("src", mypath + "arrow_up.gif");
    }, function(){
        $('#symp_check img').attr("src", mypath + "arrow_down.gif");
    });
    
    
    
    //toggle common questions and symp_check arrows, update state of arrow
    
    $('#common_q li a.topLinkClick, #symp_check').toggle(function(){
        $(this).removeClass('dArrow').addClass('uArrow');
        $(this).children('img').attr("src", mypath + "arrow_up.gif");
    }, function(){
        $(this).removeClass('uArrow').addClass('dArrow');
        $(this).children('img').attr("src", mypath + "arrow_down.gif");
    });
    
    $('#common_q li a.topLinkClick, #symp_check').hover(function(){
        $(this).removeClass('nothovered').addClass('hovered');
    }, function(){
        $(this).removeClass('hovered').addClass('nothovered');
    });
    
    
    $('#common_q li a.topLinkClick, #symp_check').live('hover', function(){
        if ($(this).hasClass('uArrow hovered')) {
            $(this).children('img').attr('src', mypath + "arrow_up_hov.gif");
        }
        else 
            if ($(this).hasClass('uArrow nothovered')) {
                $(this).children('img').attr('src', mypath + 'arrow_up.gif');
            }
            else 
                if ($(this).hasClass('dArrow hovered')) {
                    $(this).children('img').attr('src', mypath + 'arrow_down_hov.gif');
                }
                else 
                    if ($(this).hasClass('dArrow nothovered')) {
                        $(this).children('img').attr('src', mypath + 'arrow_down.gif');
                    }
        
    });
	
	$('ul.archives li a').removeClass('rArrow');
	$('ul.archives li a img').remove();
	
	
	//remove arrows on links on body text in financial & patient policies page
	
	$('.page-id-92 .row p a, .cq_answer a').removeClass('rArrow');
	$('.page-id-92 .row p a img, .cq_answer a img').remove();

	
	$('.page-template-health-php .row a').removeClass('rArrow');
	$('.page-template-health-php .row a img').remove();
	
	//add cycle functionality on gynecology page
	
	$('body.page-template-gynecology-php #pop3_img').cycle({
        prev: '.left_butt',
        next: '.right_butt',
        timeout: 6000,
		pager: '#page_nation',
		fx: 'scrollLeft'
    });
	
	//add cycle on trimester pages
	
	 $('body.page-template-first_trimester-php #trim_cycle').cycle({
		prev: '.left_butt',
        next: '.right_butt',
		pager: '#page_nation',
		nowrap: 1,
		timeout: 0
	}); 
	
	
	$('div.preg_info_right_box').cycle({
		fx: 'fade',
		slideExpr: 'img'
	});
	
	$('.page-id-57 .right_butt, .page-id-69 .right_butt').css('margin-left', '58px');
	
		
	$('.cq_answer p a').attr('class','');
	$('.cq_answer p a').addClass('linkitout');
	
    //hover arrows on trimester cycle pages
	
	/* $('.prev').hover(function(){
        $(this).attr('src', mypath + "arrow_nav_up_hov.gif");
    }, function(){
        $(this).attr('src', mypath + 'arrow_nav_up.gif');
    });
	
	$('.next').hover(function(){
        $(this).attr('src', mypath + "arrow_nav_down_hov.gif");
    }, function(){
        $(this).attr('src', mypath + 'arrow_nav_down.gif');
    }); */

    
	// SET BORDER DEPENDING ON HEIGHT OF LEFT OR RIGHT CONTENT
				//remove existing css
	

	$(window).load(function(){	
	
		var left_cont = $('#left_content').height();
		var right_cont = $('#right_content').height();
		
		
		
		setBord();
		 
		
		function setBord(){
			if (left_cont >= right_cont) {
				$('#right_content').css('border-left', 'none');
				$('#left_content').css('border-right', 'solid 1px #c7c0a7');
			}
			else {
				$('#left_content').css('border-right', 'none');
				$('#right_content').css('border-left', 'solid 1px #c7c0a7');
			}
		};
	
		
	 }); 

 //get the value of the dropdown search filter
 
	$('#searchbar').submit(function(){
		document.cookie='selected_value=' + $('#searchselect').val();
	});

	

$(".page-id-1111 #int_box").hide();


});
















