﻿$j(document).ready(function() {
    var tab = getParameterByName('tab');
    var slideControls = '';
    var activeIndex = 1;
    var selectColors = new Array('Blue', 'Green', 'Red', 'Yellow');

    //$j('.mainInnerBody').css('visibility', 'hidden');

    // Hide the Europe tab
    //$j('.mapTabs .mapTabOff').css('display', 'none');

    $j('.reason').each(function() {
        $j(this).css('background-image', 'url(/images/CareerEd/list_' + ($j(this).index() + 1) + '.png)');
    });

    $j(window).load(function() {
        
        for (x = 1; x <= $j('.mainInnerBody > div').length; x++) {
            slideControls += '<div class="slideOff"></div>';
        }
        for (x = 0; x <= ($j('.contentFooter > div').length - 1); x++) {
            $j('.contentFooter div:eq(' + x + ')').hide();
        }
        $j('.contentFooter div:eq(0)').show();

        $j('#slideNumber').html(slideControls);
        $j('#slideNumber div:eq(0)').removeClass('slideOff');
        $j('#slideNumber div:eq(0)').addClass('slideOn');

        if ($j('.home .mainInnerBody').length > 0) {
            $j('.mainInnerBody').cycle({
                fx: 'fade',
                timeout: mhTimeout,
                speed: 1000,
                pause: 1,
                pager: '#slideNumber',
                pagerAnchorBuilder: function(idx, slide) {
                    return $j('#slideNumber div:eq(' + idx + ')');
                },
                before: function() {
                    $j('#slideNumber > div').each(function() {
                        if ($j(this).hasClass('slideOn')) {
                            $j(this).removeClass('slideOn');
                            $j(this).addClass('slideOff');
                        }
                    });
                },
                after: function() {
                    $j('#slideNumber > div:eq(' + $j(this).index() + ')').removeClass('slideOff');
                    $j('#slideNumber > div:eq(' + $j(this).index() + ')').addClass('slideOn');
                    $j('.contentFooter > div').each(function() {
                        $j(this).hide();
                    });
                    $j('.contentFooter > div:eq(' + $j(this).index() + ')').show();
                    activeIndex = parseInt($j(this).index()) + 1;
                }
            });
        }
        $j('#mainInnerBody .heroGroup').css('visibility', 'visible');
        $j('.mainInnerBody').css('visibility', 'visible');

        setDefaultTab();
        resizeTwoColumnPages();
    });

    //Delete the code that handles the footnotes.

    $j('.careerPath').mousedown(function() {
        $j('.mainInnerBody').cycle('stop');
    });

    $j('.txtSelected').next('ul').hide();

    $j('.customDD').toggle(
            function() {
                $j('.customDD ul').each(function() {
                    $j(this).hide();
                });

                $j('ul', this).css('background-color', eval('slide' + activeIndex)[0]);
                $j('ul li', this).css('color', eval('slide' + activeIndex)[1]);
                //$j('ul li:hover', this).css('color', eval('slide' + activeIndex)[2]);

                $j('ul li', this).mouseover(function() {
                    $j(this).css('background', eval('slide' + activeIndex)[2]);
                });
                $j('ul li', this).mouseout(function() {
                    $j(this).css('background', 'none');
                });

                $j('ul', this).show();
                $j('#slideNumber').hide();
            },
            function() {
                $j('.customDD ul').each(function() {
                    $j(this).hide();
                });
                $j('#slideNumber').show();
            }
        );

    $j('BODY').click(function() {
        $j('.customDD ul').hide();
    });

    $j('.schoolsTabContent:eq(1) .schoolListColumn ul li a').mouseover(function(e) {
        var schoolAddress = '<div>' + $j(this).attr('schoolname') + '</div>';
        schoolAddress += $j(this).attr('schoolstreet') + '<br />';
        schoolAddress += $j(this).attr('schoolcity') + '<br />';
        schoolAddress += $j(this).attr('schoolphone');
        $j('.schoolInfoWindow .left').html(schoolAddress);

        if ($j(this).attr('schoolimage').length > 0) {
            $j('.schoolInfoBody .right').html('<img src="' + $j(this).attr('schoolimage') + '" border="0" alt="" />');
        }
        else {
            $j('.schoolInfoWindow .left').addClass('wideAddress');
        }

        $j('.schoolInfoWindow').css('top', (e.pageY - $j('.schoolInfoWindow').height()));
        $j('.schoolInfoWindow').css('left', (e.pageX - $j('.schoolInfoWindow').width() - 35));
        $j('.schoolInfoWindow').show();
    });

    $j('.schoolsTabContent:eq(1) .schoolListColumn ul li a').mouseout(function() {
        $j('.schoolInfoWindow').hide();
    });
    selectOption = function(e) {
        var activeSlide = 'slide' + activeIndex; //+ selectColors[(parseInt(activeIndex) - 1)];
        var defaultText = $j('li:eq(0)', $j(e).parent()).text();

        var txtSelected = $j(e).text();
        if (txtSelected.length > 24) {
            $j(e).parent().prev('.txtSelected').attr('title', txtSelected);
            txtSelected = txtSelected.substring(0, 24) + '...';
        } else {
            $j(e).parent().prev('.txtSelected').removeAttr('title');
        }
        $j(e).parent().prev('.txtSelected').text(txtSelected);

        var lnkSelected = $j(e).find('input[type="hidden"]').val();
        $j('#goToCarPrgVal').val(lnkSelected);

        var imgSplit = $j('.careerPathSubmit.' + activeSlide + 'Button img').attr('src');
        var btnObject = $j('.careerPathSubmit.' + activeSlide + 'Button img');

        if ($j(e).parent().prev('.txtSelected').text() != defaultText) {
            changeButtonState(imgSplit, btnObject, 1);
            $j('.careerPathSubmit.' + activeSlide + 'Button a').css('cursor', 'pointer').click(function() {
                goToCarPrg();
            });

            if ($j(e).parent().parent().hasClass('careerPath') == true) {
                $j('.careerPathNext.' + activeSlide + ' .programOptions').html($j('.s_' + $j(e).attr('class').substring(2)).html());
                $j('.careerPathNext.' + activeSlide + ' .programOptions').prev('.txtSelected').text('Select A Program');
                $j('.careerPathNextInactive.' + activeSlide + 'Inactive').hide();
                $j('.careerPathNext.' + activeSlide).show();

                $j('.careerPathNext.' + activeSlide + ' .programOptions ul').css('background-color', eval('slide' + activeIndex)[0]);
                $j('.careerPathNext.' + activeSlide + ' .programOptions li').css('color', eval('slide' + activeIndex)[1]);

                $j('.careerPathNext.' + activeSlide + ' .programOptions li').mouseover(function() {
                    $j(this).css('background', eval('slide' + activeIndex)[2]);
                });
                $j('.careerPathNext.' + activeSlide + ' .programOptions li').mouseout(function() {
                    $j(this).css('background', 'none');
                });
            } else {
                //changeButtonState(imgSplit, btnObject, 1);
            }
        } else {
            if ($j(e).parent().parent().hasClass('careerPath') == true) {
                $j('.careerPathNextInactive.' + activeSlide + 'Inactive').show();
                $j('.careerPathNext.' + activeSlide).hide();
                changeButtonState(imgSplit, btnObject, 0);
            } else {
                changeButtonState(imgSplit, btnObject, 0);
            }
        }
    }

    $j('.tabInnerContainer').mouseover(function() {
        if ($j(this).children(0).attr('class') == 'tabOffLeft') {
            $j('div:eq(0)', this).addClass('tabHighLeft');
            $j('div:eq(1)', this).addClass('tabHighBody');
            $j('div:eq(2)', this).addClass('tabHighRight');
        }
    });

    $j('.tabInnerContainer').mouseout(function() {
        if ($j(this).children(0).attr('class') == 'tabOffLeft tabHighLeft') {
            $j('div:eq(0)', this).removeClass('tabHighLeft');
            $j('div:eq(1)', this).removeClass('tabHighBody');
            $j('div:eq(2)', this).removeClass('tabHighRight');
        }
    });

    $j('.tabInnerContainer').click(function() {
        $j('.tabInnerContainer').each(function() {
            if ($j(this).children(0).hasClass('tabOnLeft') == true) {
                $j('div:eq(0)', this).attr('class', 'tabOffLeft');
                $j('div:eq(1)', this).attr('class', 'tabOffBody');
                $j('div:eq(2)', this).attr('class', 'tabOffRight');
            }
        });
        if ($j(this).children(0).hasClass('tabOffLeft') == true) {
            $j('div:eq(0)', this).attr('class', 'tabOnLeft');
            $j('div:eq(1)', this).attr('class', 'tabOnBody');
            $j('div:eq(2)', this).attr('class', 'tabOnRight');
        }
        $j('.schoolsTabContent').each(function() {
            $j(this).hide();
        });
        $j('.schoolsTabContent:eq(' + $j(this).index() + ')').show();
    });

    $j('.videoOverLayContainer img').click(function() {
        $j('.videoOverlay').dialog('close');
        $j('.videoOverlay').html('');
        location.reload();
    });

    $j('.photoLowerButtons img').click(function() {
        $j('.videoOverlay').dialog({
            modal: true,
            width: 694
        });
    });

    $j('.leftNavContainer li .navImgHolder').mouseover(function() {
        if ($j(this).parent().hasClass('activeNavPage') == false) {
            if ($j(this).parent().hasClass('activeNavPage') == false) {
                var btnSrc = $j(' img', this).attr('src');
                if (btnSrc.indexOf('http') != -1) {
                    var urlPath = '';
                    var splitBtnSrc = btnSrc.split('/');
                    for (ndx = 0; ndx <= splitBtnSrc.length - 2; ndx++) {
                        if (ndx > 0) {
                            urlPath += '/' + splitBtnSrc[ndx];
                        } else {
                            urlPath += splitBtnSrc[ndx];
                        }
                    }
                    splitBtnSrc = splitBtnSrc[(splitBtnSrc.length - 1)].split('.', 2);
                    urlPath += "/" + splitBtnSrc[0] + "_on." + splitBtnSrc[1]
                    $j(' img', this).attr('src', urlPath);
                } else {
                    $j(' img', this).attr('src', '/images/CareerEd/nav_arrow_on.png');
                }
                $j(this).next().children('a').css('color', '#174255');
            }
        }
    });
    $j('.leftNavContainer li .navImgHolder').mouseout(function() {
        if ($j(this).parent().hasClass('activeNavPage') == false) {
            var btnSrc = $j(' img', this).attr('src');
            if (btnSrc.indexOf('http') != -1) {
                var urlPath = '';
                var splitBtnSrc = btnSrc.split('/');
                for (ndx = 0; ndx <= splitBtnSrc.length - 2; ndx++) {
                    if (ndx > 0) {
                        urlPath += '/' + splitBtnSrc[ndx];
                    } else {
                        urlPath += splitBtnSrc[ndx];
                    }
                }
                splitBtnSrc = splitBtnSrc[(splitBtnSrc.length - 1)].split('_on.', 2);
                urlPath += "/" + splitBtnSrc[0] + "." + splitBtnSrc[1]
                $j(' img', this).attr('src', urlPath);
            } else {
                $j(' img', this).attr('src', '/images/CareerEd/nav_arrow.png');
            }
            $j(this).next().children('a').css('color', '');
        }
    });
    $j('.leftNavContainer li a').mouseover(function() {
        if ($j(this).parent().parent().hasClass('activeNavPage') == false) {
            if ($j(this).parent().prev().children('img').attr('src') == true) {
				var btnSrc = $j(this).parent().prev().children('img').attr('src');
				if (btnSrc.indexOf('http') != -1) {
					var urlPath = '';
					var splitBtnSrc = btnSrc.split('/');
					for (ndx = 0; ndx <= splitBtnSrc.length - 2; ndx++) {
						if (ndx > 0) {
							urlPath += '/' + splitBtnSrc[ndx];
						} else {
							urlPath += splitBtnSrc[ndx];
						}
					}
				}
                splitBtnSrc = splitBtnSrc[(splitBtnSrc.length - 1)].split('.', 2);
                urlPath += "/" + splitBtnSrc[0] + "_on." + splitBtnSrc[1]
                $j(this).parent().prev().children('img').attr('src', urlPath);
            } else {
                $j(this).parent().prev().children('img').attr('src', '/images/CareerEd/nav_arrow_on.png');
            }
        }
    });
    $j('.leftNavContainer li a').mouseout(function() {
        if ($j(this).parent().parent().hasClass('activeNavPage') == false) {
            if ($j(this).parent().prev().children('img').attr('src') == true) {
				var btnSrc = $j(this).parent().prev().children('img').attr('src');
				if (btnSrc.indexOf('http') != -1) {
					var urlPath = '';
					var splitBtnSrc = btnSrc.split('/');
					for (ndx = 0; ndx <= splitBtnSrc.length - 2; ndx++) {
						if (ndx > 0) {
							urlPath += '/' + splitBtnSrc[ndx];
						} else {
							urlPath += splitBtnSrc[ndx];
						}
					}
				}
                splitBtnSrc = splitBtnSrc[(splitBtnSrc.length - 1)].split('_on.', 2);
                urlPath += "/" + splitBtnSrc[0] + "." + splitBtnSrc[1]
                $j(this).parent().prev().children('img').attr('src', urlPath);
            } else {
                $j(this).parent().prev().children('img').attr('src', '/images/CareerEd/nav_arrow.png');
            }
        }
    });

    $j('.showMoreContent').toggle(function() {
        $j(this).prev('.additionalContent').slideDown('slow');
        $j(this).text('Show Less');
    }, function() {
        $j(this).prev('.additionalContent').slideUp('slow');
        $j(this).text('Show More');
    });

    $j('input[type="checkbox"]').ezMark();

    $j('.slideShowCaption > div').each(function() {
        $j(this).hide();
    });
    $j('.slideShowCaption > div:eq(0)').show();

    $j('.twoColumnRight .columnFormFooterBody a:eq(0)').hide();
    $j('.twoColumnRight .columnFormFooterBody a:eq(1)').show();
    $j('.twoColumnRight .formRightConfirmContainer').hide();

    $j('.twoColumnRight .columnFormFooterBody a:eq(1)').click(function() {
        $j('.twoColumnRight .lowerForm').show(1, function() {
            $j('.twoColumnRight .columnFormFooterBody a:eq(1)').hide();
            $j('.twoColumnRight .columnFormFooterBody a:eq(0)').show();
        });
    });

    if ($j('.slideShowMain').length > 0) {
        $j('.slideShowMain').jCarouselLite({
            speed: 600,
            btnNext: '.slideRightArrow img',
            btnPrev: '.slideLeftArrow img',
            circular: false
        });
    }

    if ($j('.designThumbs').length > 0) {
        $j('.designThumbs').jCarouselLite({
            speed: 600,
            circular: false,
            btnPrev: '.spotlightArrowLeft',
            btnNext: '.spotlightArrowRight'
        });
    }

    //$j('.scfDropList').getSetSSValue('USA');

    $j('.slideShowMain img').click(function() {
        var slideLrg = $j(this).attr('src');
        slideLrg = slideLrg.split('_thm');
        $j('.slideShowActive img').attr('src', slideLrg[0] + slideLrg[1]);

        $j('.slideShowCaption > div').each(function() {
            $j('.slideShowCaption > div').hide();
        });
        $j('.slideShowCaption > div:eq(' + $j(this).parent().index() + ')').show();
        resizeTwoColumnPages();
    });

    $j('.leftTabContainer ul li').mouseover(function() {
        if ($j(this).attr('class') != 'tabOn') {
            $j(this).addClass('tabHigh');
        }
    });
    $j('.leftTabContainer ul li').mouseout(function() {
        if ($j(this).attr('class') != 'tabOn') {
            $j(this).removeClass('tabHigh');
        }
    });

    $j('.leftTabContainer ul li').click(function() {
        $j('.leftTabContainer ul li').each(function() {
            if ($j(this).hasClass('tabOn') == true) {
                $j(this).removeClass('tabOn');
                $j(this).addClass('tabOff');
            }
        });
        $j(this).removeClass('tabOff');
        $j(this).removeClass('tabHigh');
        $j(this).addClass('tabOn');

        $j('.programTabs .classListMenu').hide();
        $j('.programTabs .classListMenu:eq(' + $j(this).index() + ')').show();

        resizeTwoColumnPages();
    });

    $j('.flexform div input').click(function() {
        resizeTwoColumnPages();
    });

    $j('.thumbContainer').click(function() {
        $j('.thumbContainer > div').each(function() {
            $j(this).attr('class', 'inactiveOverlay');
        });
        $j('.inactiveOverlay', this).addClass('activeOverlay');
        $j('.inactiveOverlay', this).removeClass('inactiveOverlay');

        $j('.designBody > div').each(function() {
            $j(this).hide();
        });
        $j('.designBody > div:eq(' + $j(this).parent().index() + ')').show();

        resizeTwoColumnPages();
    });

    $j('.designBody > div').each(function() {
        $j(this).hide();
    });
    $j('.designBody > div:eq(0)').show();

    $j('.designThumbs li').each(function() {
        if ($j(this).index() > 0) {
            $j(' .thumbContainer .activeOverlay', this).attr('class', 'inactiveOverlay');
        }
    });

    if ($j('.designThumbs li').length <= 3) {
        $j('.moreSpotlight').hide();
    }

    $j('.schoolsTabContent').each(function() {
        $j(this).hide();
    });

    if (tab == '2') {
        $j('.schoolsTabContent:eq(2)').show();
        $j('.tabInnerContainer').each(function() {
            $j('div:eq(0)', this).attr('class', 'tabOffLeft');
            $j('div:eq(1)', this).attr('class', 'tabOffBody');
            $j('div:eq(2)', this).attr('class', 'tabOffRight');
        });
        $j('.tabInnerContainer:eq(2)').each(function() {
            $j('div:eq(0)', this).attr('class', 'tabOnLeft');
            $j('div:eq(1)', this).attr('class', 'tabOnBody');
            $j('div:eq(2)', this).attr('class', 'tabOnRight');
        });
    }
    else {
        $j('.schoolsTabContent:eq(0)').show();
    }
});
goToCarPrg = function(e) {
    window.location = $j('#goToCarPrgVal').val();
}
function resizeTwoColumnPages() {
    $j('.twoColumnLeft, .twoColumnRight').css('height', 'auto');
    if ($j('.twoColumnLeft').height() > $j('.twoColumnRight').height()) {
        $j('.twoColumnRight').height($j('.twoColumnLeft').height() + trimPadding($j('.twoColumnLeft').css('padding-top')) + trimPadding($j('.twoColumnLeft').css('padding-bottom')));
    }
    else {
        $j('.twoColumnLeft').height($j('.twoColumnRight').height() - (trimPadding($j('.twoColumnLeft').css('padding-top')) + trimPadding($j('.twoColumnLeft').css('padding-bottom'))));
    }
}
function trimPadding(paddingAmount) {
    if ($j('.twoColumnLeft').length > 0) {
        paddingAmount = paddingAmount.substring(0, paddingAmount.length - 2);
        return parseInt(paddingAmount);
    } else {
        return 0;
    }
}
function setDefaultTab() {
    $j('.programTabs .classListMenu').hide();

    $j('.leftTabContainer ul li').each(function() {
        $j(this).attr('class', 'tabOff');
    });

    $j('.leftTabContainer ul li:eq(0)').removeClass('tabOff');
    $j('.leftTabContainer ul li:eq(0)').addClass('tabOn');
    $j('.programTabs .classListMenu:eq(0)').show();

    if ($j('.slideShowMain ul li').length <= 3) {
        $j('.slideRightArrow, .slideLeftArrow').hide();
        $j('.slideShowMain').css('margin-left', '40px');
    }
    if ($j('.slideShowMain ul li').length == 1) {
        $j('.slideRightArrow, .slideLeftArrow, .slideShowMain').hide();
    }
}
/*function showOurSchoolWindow(schoolName, schoolStreet, schoolCity, schoolPhone) {
var schoolAddress = '<div>' + schoolName + '</div>';
schoolAddress += schoolStreet + '<br />';
schoolAddress += schoolCity + '<br />';
schoolAddress += schoolPhone;

$j('.schoolInfoWindow .left').html(schoolAddress);

$j('.schoolInfoWindow').css('top', (window.event.y - $j('.schoolInfoWindow').height()));
$j('.schoolInfoWindow').css('left', (window.event.x - ($j('.schoolInfoWindow').width() / 2)));
$j('.schoolInfoWindow').show();
}
function hideOurSchoolWindow() {
$j('.schoolInfoWindow').hide();
}*/
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return decodeURIComponent(results[1].replace(/\+/g, " "));
}

if ($j('#singleSchoolMap').length > 0) {
    loadSmallMap(pageSpecificSchoolName, pageSpecificSchoolAddress);
}

function loadSmallMap(pageSpecificSchoolName, pageSpecificSchoolAddress) {
    geocoder = new google.maps.Geocoder();
    var smallMap = new google.maps.Map(document.getElementById("singleSchoolMap"), { mapTypeId: google.maps.MapTypeId.ROADMAP });

    geocoder.geocode({ 'address': pageSpecificSchoolAddress }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            smallMap.setZoom(14);
            smallMap.setCenter(results[0].geometry.location);

            var imageIcon = "/images/CareerEd/darts/red1_Dart.png";
            var marker = new google.maps.Marker({
                map: smallMap,
                animation: google.maps.Animation.DROP,
                icon: imageIcon,
                title: pageSpecificSchoolName,
                position: results[0].geometry.location
            });

            var objTimer = window.setTimeout(function() {
                $j('#singleSchoolMap .gmnoprint').hide();
            }, 1000);
        }
    });
}

$j('.flexform div input').click(function() {
    resizeTwoColumnPages();
});
