﻿var cibi ={
	init: function(){
		this.showTitle();
		this.accordion();
		this.subMenu()
		this.sampleSize();
		this.resisterEventHandlers();
	},
	
	showTitle: function() {
		$("#locationLink").css({
			"padding-bottom": "30px"						
		});
		if($("#title").text() == "Definition of Affiliates CI BI and Other Marks" || $("#title").text() == "Usage Rules for Affiliates CI BI and Other Marks" ){
			$("#title").css({
				"backgroundImage": "url(images/title.gif)",
				"height": "109px"
			});
		}else{
			$("#title").css({
				"backgroundImage": "url(images/title.gif)"
			});
		}
	},
	
	accordion: function() {
		$.each($(".gnb ul"), function() {
			$(this).css('display','none')
    });
		
		$(".gnb ul a[href='" + location.pathname + "']").
			addClass("selected").
			parent().parent().css('display','block').parent().addClass("openMenu");
		
		$(".gnb h5 a").click(function() {
			$(this).parent().next().slideToggle('fast');
			$(this).parent().parent().toggleClass('openMenu');
			return false;
		});
		
		$(".gnb ul a").click(function() {							
			if($(".gnb .selected")[0]){
				$(".gnb .selected")[0].classNmame = "";
				$(this).addClass('selected')
			}
		});
	},
	
	oneDepthMenu: function(){
		return false;
		$(".gnb h5 a").focus(function(){	
			$(this).parent().next().slideToggle('fast');
			$(this).parent().parent().toggleClass('openMenu');
			return false;
		})
	},
	
	resisterEventHandlers: function(){
		document.onkeydown = function(e) {
			if(e.keyCode === 9) cibi.oneDepthMenu();
		}
	},
	
	subMenu: function() {
		if($("#subTabMenu")[0]){
			$("#subTabMenu a").click(function() {			
				$('#content').load($(this).attr('href'), function() {
					$(this).show();
				});																
																					
				$("#subTabMenu .selected").removeClass('selected');
				$(this).addClass('selected');
				
				return false;
			});
		}
	},
	
	sampleSize: function() {
		if($("area")[0]){	
			$("area").click(function() {
				var img_link = '/module/popup.asp?send='+location.pathname+$(this).attr('href')
				var winName = "popup"
				var winWidth = $(this).attr("title").split('_')[1].split('*')[0];
				var winHeight = $(this).attr("title").split('_')[1].split('*')[1];
				var winSize = "width="+ winWidth +", height="+ winHeight
 				var winLeftPost = (screen.width) ? (screen.width-winWidth)/2 : 0;
				var winTopPost = (screen.height) ? ((screen.height-winHeight)/2)-100 : 0;
				var winLocation = "top="+ winTopPost +", left="+ winLeftPost
				var winOpt = winSize+","+winLocation+", menubar=No, resizable=No, status=No, toolbar=No";
				var Wins = window.open(img_link, winName, winOpt + "");
				
				Wins.focus();
				return false;
			});
		}
	}
}



$(function() {	 
	cibi.init()	
});
