var $ = jQuery.noConflict();

$(document).ready(function() {
	
	$('#gnb1, #gnb2, #gnb3, #gnb4, #gnb5').hoverIntent(function() {
		$(this).children('.subgnb').slideDown('fast');
	}, function() {		
		$(this).children('.subgnb').slideUp('normal');
	});

});

$(document).ready(function() {
	var options = {
		mode: 'fade',
		speed: 1500,
		auto: true,
		auto_direction: 'left',
		pause: 3000,
		controls: true,
		prev_text: '',
		next_text: '',
		width: '220',
		prev_img: '',
		next_img: '',
		ticker_direction: 'left',
		wrapper_class: 'twit'
	};

	var twroll = $('.aktt_tweets ul').bxSlider(options);
	var isStopped = false;

	$('.aktt_tweets').hoverIntent(function() {
		isStopped = true;
		$('.aktt_tweets ul').stop();
		twroll.clearTwitInterval(this);
	}, function() {		
		if (isStopped = true) {
			isStopped = false;
			twroll.fade('next');
			twroll.restoreTwitInterval();
		}
	});
});

//gnb
function gnbover (value, on, This) {
	if (on!="on") {
		document.getElementById("gnbimg"+value).src="/wp-content/themes/jordan/images/btn_gnb_"+value+"_on.gif";
	}
}
function gnbout (value, on, This) {
	if (on!="on") {
		document.getElementById("gnbimg"+value).src="/wp-content/themes/jordan/images/btn_gnb_"+value+"_off.gif";
	}
}

//side tab
function sidedisplay (value) {
	for (var i=1; i<=3; i++) {
		if (i==value) {
			document.getElementById("postcont"+i).style.display="";
			document.getElementById("sideimg"+i).src="/wp-content/themes/jordan/images/btn_sdtab_"+i+"_on.gif";
		}
		else {
			document.getElementById("postcont"+i).style.display="none";
			document.getElementById("sideimg"+i).src="/wp-content/themes/jordan/images/btn_sdtab_"+i+"_off.gif";
		}
	}
}

//comment
function commentOn (value, This) {
	if (value=="1") {
		This.style.background="url('/wp-content/themes/jordan/images/img_cm01_on.gif') no-repeat 11px 6px";
		This.style.backgroundColor="#fef0e5";
	}
	else if (value=="2") {
		This.style.background="url('/wp-content/themes/jordan/images/img_cm02_on.gif') no-repeat 11px 7px";
		This.style.backgroundColor="#fef0e5";
	}
	else if (value=="3") {
		This.style.background="url('/wp-content/themes/jordan/images/img_cm03_on.gif') no-repeat 11px 7px";
		This.style.backgroundColor="#fef0e5";
	}
	else if (value=="4") {
		This.style.background="url('/wp-content/themes/jordan/images/img_cm04_on.gif') no-repeat 10px 11px";
		This.style.backgroundColor="#fef0e5";
		This.style.width="94%";
	}
}

function commentOut (value, This) {
	if (value=="1") {
		This.style.background="url('/wp-content/themes/jordan/images/img_cm01.gif') no-repeat 11px 6px";
		This.style.backgroundColor="#ffffff";
	}
	else if (value=="2") {
		This.style.background="url('/wp-content/themes/jordan/images/img_cm02.gif') no-repeat 11px 7px";
		This.style.backgroundColor="#ffffff";
	}
	else if (value=="3") {
		This.style.background="url('/wp-content/themes/jordan/images/img_cm03.gif') no-repeat 11px 7px";
		This.style.backgroundColor="#ffffff";
	}
	else if (value=="4") {
		This.style.background="url('/wp-content/themes/jordan/images/img_cm04.gif') no-repeat 10px 11px";
		This.style.backgroundColor="#ffffff";
	}
}

//contact
function contact_tab (value) {
	if (value=="상담 의뢰") {
		document.getElementById("contact_tab1").src="/wp-content/themes/jordan/images/btn_cont_tab1_on.gif";
		document.getElementById("contact_tab2").src="/wp-content/themes/jordan/images/btn_cont_tab2_off.gif";
		document.getElementById("cnt1").style.display="";
		document.getElementById("cnt2").style.display="none";
	}
	else {
		document.getElementById("contact_tab1").src="/wp-content/themes/jordan/images/btn_cont_tab1_off.gif";
		document.getElementById("contact_tab2").src="/wp-content/themes/jordan/images/btn_cont_tab2_on.gif";
		document.getElementById("cnt1").style.display="none";
		document.getElementById("cnt2").style.display="";
	}
}

function chk_contact() {
	var form=document.form;
	if (form.contact1.value=="") {
		alert("이름을 입력해 주세요.");
		form.contact1.focus();
		return false;
	}
	else if (form.contact2.value=="") {
		alert("이메일 주소를 입력해 주세요.");
		form.contact2.focus();
		return false;
	}
	else if (form.contact5.value=="") {
		alert("내용을 입력해 주세요.");
		form.contact5.focus();
		return false;
	}
	else {
		return true; 
	}
}

function chk_contact2() {
	var form=document.form2;
	if (form.contact11.value=="") {
		alert("이름을 입력해 주세요.");
		form.contact11.focus();
		return false;
	}
	else if (form.contact12.value=="") {
		alert("회사상호를 입력해 주세요.");
		form.contact12.focus();
		return false;
	}
	else if (form.contact13.value=="") {
		alert("회사 전화번호를 입력해 주세요.");
		form.contact13.focus();
		return false;
	}
	else if (form.contact15.value=="") {
		alert("이메일 주소를 입력해 주세요.");
		form.contact15.focus();
		return false;
	}
	else if (form.contact17.value=="") {
		alert("내용을 입력해 주세요.");
		form.contact17.focus();
		return false;
	}
	else {
		return true; 
	}
}
