﻿(function($) {

    $(document).ready(function() {
        var count = 0;
        var isFirst = true;
        var elem;
        if ($('#ctl00_rightColumn_DropZone1_updatepanel').length > 0) {
            elem = $('#ctl00_rightColumn_DropZone1_updatepanel li.PBItem');
        }
        else if ($('#DropZone1_updatepanel li.PBItem').length > 0) {
            elem = $('#DropZone1_updatepanel li.PBItem');
        }
        else if ($('#DropZone_Right_updatepanel li.PBItem').length > 0) {

            elem = $('#DropZone_Right_updatepanel li.PBItem');
        }
        if (elem != null) {

            elem.each(function(index) {
                if ($(this).find('h4').text() != "") {
                    if (index == 0) {
                        $(this).find('h4').css('border-top', '0px');
                        count = count + 1;
                        isFirst = true;
                    }

                }
                //if ($(this).find('h2.dardenVoices').text() != "") {
                //    if (index == 0) {
                //        $(this).find('h2.dardenVoices').css('border-top', '0px');
                //        count = count + 1;
                //        isFirst = true;
                //    }
                //}
                if ($(this).find('separator').text() == "") {
                    if (index == 0) {
                        $(this).find('.separator').remove();
                        count = count + 1;
                        isFirst = true;
                    }
                }
				
				//alert($('#pageLinks').length);
				if($('#columnTwo #pageLinks').length>0)
				{
					//if($('#columnTwo .dardenVoices').length>0)
					//{
					//	if ($(this).find('h2').text() != "") {
					//		if (index == 0) {
					//			$(this).find('h2').css({'border-top':'0px'});
					//			count = count + 1;
					//			isFirst = true;
					//		}
					//	}
					//}
					//else
					//{
						if ($(this).find('h2').text() != "") {
							if (index == 0) {
								$(this).find('h2').css({'border-top':'0px','padding-top':'0px'});
								$(this).find('h2.dardenVoices').css({'margin-top':'-2px'});
								count = count + 1;
								isFirst = true;
							}
						}
					//}
				}
				else
				{
					//if($('#columnTwo .dardenVoices').length>0)
					//{
					//	if ($(this).find('h2').text() != "") {
					//		if (index == 0) {
					//			$(this).find('h2').css({'border-top':'0px'});
					//			count = count + 1;
					//			isFirst = true;
					//		}
					//	}
					//}
					//else
					//{
						if ($(this).find('h2').text() != "") {
							if (index == 0) {
								$(this).find('h2').css({'border-top':'0px'});
								$(this).find('h2.dardenVoices').css({'margin-top':'-2px'});
								count = count + 1;
								isFirst = true;
							}
						}
					//}
				}
				if($('#columnOne').length>0)
				{
					if ($(this).find('h2').text() != "") {
						if (index == 0) {
							$(this).find('h2').css('border-top', '0px');
							$(this).find('h2.dardenVoices').css('margin-top', '-2px');
							count = count + 1;
							isFirst = true;
						}
					}
				}			
				
                if ($(this).find('.contNewNoteworthy').text() != "") {

                    if (index == 0) {
                        count = count + 1;
                        isFirst = true;
                    }
                }
                if ($(this).find('.contFeaturesVideos').text() != "") {
                    if (index == 0) {
                        $(this).find('h2').css('border-top', '0px');
                        count = count + 1;
                        isFirst = true;
                    }
                }
                else {

                    var c = elem.size();
                    if (c > 1) {
                        if (index == count && isFirst == true) {

                            if ($(this).find('h2.first').length > 0) {

                            } else {
                                $(this).find('h2').addClass('first');
                                isFirst = false;
                            }
                        } else {

                            $(this).find('h2').removeClass('first');
                            isFirst = false;
                        }
                    }
                }
            });
        }
        var leftElem;
        if ($('#DropZone2_updatepanel li.PBItem').length > 0) {

            leftElem = $('#DropZone2_updatepanel li.PBItem');
        }
        else if ($('#leftDropZone_updatepanel li.PBItem').length > 0) {
            leftElem = $('#leftDropZone_updatepanel li.PBItem');
        }
        else {

            leftElem = $('#DropZone_Left_updatepanel li.PBItem');
        }
        if (leftElem != null) {
            var c = leftElem.size();
            leftElem.each(function(i) {
                if (c > 1) {
                    if (i == 0) {
                        if ($('#columnOne .current').length > 0) {
                            if ($(this).find('h2').text() != "") {

                                $(this).find('h2').removeClass('first');
                            }
                        }
                        else if ($(this).find('h2.first').length > 0) {

                        } else {
                            $(this).find('h2').addClass('first');
                        }
                    }
                    else {

                        $(this).find('h2').removeClass('first');
                        $(this).find('.separator').remove();
                    }
                } else {
                    if ($('#columnOne').find('ul').length > 0) {
                        if ($(this).find('h2').text() != "") {
                            $(this).find('h2').removeClass('first');
                        }
                    }
                }
            });
        }
    });

})(jQuery)
