/**
 * @name main.js
 * @fileOverview
 * @version 1.1
 * @description
 * <p>(c) FOURDIGIT Inc. Licensed <a href="http://ja.wikipedia.org/wiki/GNU_General_Public_License">GNU General Public License</a>.</p>
 */

//jQuery.noConflict();

/**
 * config
 */
(function($){
	$(function() {
	// addClassUA
		$.addClassUA();
	// easyOver
		$("img.ahover, .ahoverArea img,input.ahover, #cmn_btn").easyOver();
	// autoEnablePNG
		$.autoEnablePNG();
	// easyPop
		$(".commonPop").easyPop();

    /* opacityHover link */
    $(".opacityHover a").each(function(){
  	  $(this).hover(
  	    function(){
  	      $(this).css('opacity','0.7');
  	    },
  	    function(){
  	      $(this).css('opacity','1.0');
  	    }
  	  )
	  });

    $('iframe#myId').load(function()  
    { 
        callback(this); 
    }); 

    /* MainContentsThickBox link */
    $('#MainContentsThickBox a[target!=_blank]').each(function(){
    	var $href = $(this).attr('href');
     	var $hrefParent = parent;
     	var $hrefParentURL = parent.location.href;
    	if($href.indexOf('#') > 0){
    	  var $hashHref = $href.split('#')[0];
      	if($hrefParentURL.indexOf('about') > 0){
          $(this).click(function(){
            $('#TB_window', window.parent.document).fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect', window.parent.document).trigger("unload").unbind().remove();});
            $('#TB_load', window.parent.document).remove();
            $('body', window.parent.document).removeClass('TB_windowImg');
          	if (typeof parent.document.body.style.maxHeight == "undefined") {//if IE 6
          		$('body',window.parent.document).css({height: "auto", width: "auto"});
          		$('html',window.parent.document).css("overflow","");
          	}
            $('object,embed', window.parent.document).css('visibility','visible');
          });
      	}
    	}
    	else
    	if($href.indexOf("?TB_iframe=true") < 0){
        $(this).attr('target','_parent');
    	}
    	else {
    	  $href = $href.substring(0,$href.length-15);
    		$(this)
    		  .removeClass('thickbox')
    		  .attr('href',$href);
    	}
    });

    if($('.page').attr('id') == 'faqPage'){
      $('#faqToggle .faqList').find('dl').each(function(){
        var $thisQues = $(this);
        $(this)
          .find('dd')
            .hide()
          .end()
          .find('dt')
            .toggle(
              function(){
                $(this).addClass('on');
                $thisQues.find('dd').slideDown(200);
              },
              function(){
                $(this).removeClass('on');
                $thisQues.find('dd').slideUp(200);
              }
            )
            .hover(
              function(){
                $(this).addClass('hover');
              },
              function(){
                $(this).removeClass('hover');
              }
            )
          .end()
        .end();
      });
    }

    // index - innerfade
    if($('.page').attr('id') == 'indexPage'){
      $('#btnApply').hover(
        function(){
          $(this).addClass('btnApplyOn');
        },
        function(){
          $(this).removeClass('btnApplyOn');
        }
      );
      if($.browser.msie && $.browser.version <= 6) {
        true;
      }else{
        $('#ActionArea')
          .append('<img src="/index/imgs/bg-actionarea.png" alt="" class="bg">')
          .css('background-image','none');
      }
      $('#BrandPanel').innerFade({
				speed: 2000,
				timeout: 4000,
        loop: true,
				containerheight: '400'
			});
    }

	});
})(jQuery);
