jQuery(document).ready(function() {
    initTopMenu();
});

function initTopMenu() {

    var strCurrentURL = String(location.href);
    var strFileName = strCurrentURL.substring(strCurrentURL.indexOf("/", 8) + 1, strCurrentURL.length).toLowerCase();

    var idx = -1;

    if (strFileName.indexOf("aboutus.php") >= 0)
        idx = 0;
    else if (strFileName.indexOf("service.php") >= 0)
        idx = 1;
    else if (strFileName.indexOf("portfolio.php") >= 0)
        idx = 2;
    else if (strFileName.indexOf("contact.php") >= 0)
        idx = 3;
    else if (strFileName.indexOf("clients.php") >= 0)
        idx = 4;

    if (idx >= 0) {
        jQuery(".topMenuPart img").eq(idx).css("opacity", "100");
    }
        
    jQuery(".topMenuPart img").each(function(i) {
        if(i != idx)
        {
            jQuery(this).hover(function() {
                var imageUrl = jQuery(this).attr("src");
                //if (imageUrl.indexOf("_o.") < 0) {
                    imageUrl = imageUrl.replace(".", "_o.");
                    /*
                    jQuery(this).attr("src", imageUrl);
                    */
                    jQuery(this).animate({"opacity":"1"}, 500);
                //}
            }, function() {
                /*var imageUrl = jQuery(this).attr("src");
                imageUrl = imageUrl.replace("_o.", ".");
                jQuery(this).attr("src", imageUrl);*/
                jQuery(this).animate({"opacity":"0.5"}, 500);
            });
        }
    });
}

/*
    ¼³¸í : jQuery Dialog ÃÊ±âÈ­
    ÀÛ¼ºÀÚ : hyunki lee
    ÆÄ¶ó¹ÌÅÍ
        - popupID : Dialog Ã¢ ID
        - isScrollBar : ¿É¼Ç(ÀüÃ¼ÆäÀÌÁö½ºÅ©·Ñ°¡´É¿©ºÎ)
*/
function initialPopup(popupID, isScrollBar) {
    var showOption = "";

    var isDisableScroll = true;

    if (isScrollBar == "0")
		isDisableScroll = false;

    $("#" + popupID).dialog({ modal: true, closeOnEscape: true, resizable: false, autoOpen: false, close: function() { (isDisableScroll) ? $("html").addClass("enableScroll") : ""; }, open: function() { (isDisableScroll) ? $("html").addClass("disableScroll") : ""; } });
}
/*
	¼³¸í : ¼­ºêÆäÀÌÁö ÀÌ¹ÌÁöº¯°æ ÃÊ±âÈ­
	ÀÛ¼ºÀÚ : hyunki lee
*/
function initSubPageChangeImage() {
	$(".detailImage").first().show();
	if($(".detailImage").length > 1)
		setTimeout(changeImage, 5000);
}
/*
	¼³¸í : ¼­ºêÆäÀÌÁö ÀÌ¹ÌÁöº¯°æ ÀÚµ¿ º¯°æ
	ÀÛ¼ºÀÚ : hyunki lee
*/
function changeImage() {
	var currentObj = $(".detailImage:visible");
	currentObj.fadeOut(1000);

	var nextObj = currentObj.next(".detailImage");
	if(!nextObj.is(".detailImage"))
		nextObj = $(".detailImage").first();
	nextObj.fadeIn(1000);

	setTimeout(changeImage, 5000);
}