var hom = { 
/* debugger; */

init:function() {
if (!document.getElementById || !document.createTextNode){return;}
$(document.body).addClass("jsWorks");
	
	hom.evenLeftRightCols(); //make right column bcgr extend to the bottom

//Flash init
if ($('#giftCardFlash').size() > 0) {

	var so = new SWFObject("images/giftCard.swf", "slideShow1", "220", "160", "7", "#fff"); so.addParam("quality", "high"); so.write("giftCardFlash") };
	
	/* if (navigator.appVersion.match(/MSIE [0-6]\./)) */
/* 		hom.fixHeightIE6(); */

	$('#shop').hover(function() {
		$(this).addClass("over");
	}, function() {
		$(this).removeClass("over");
	}) ;
	
	$('#shop li').hover(function() { 
		$(this).toggleClass("over"); },function() {
		$(this).toggleClass("over"); }
	);
	
	$('#shop li').click(function() { 
		location = $(this).find('a').attr("href"); }
	);


	$('div.aArea').each(function() {
		$(this).hover(function() {
		$(this).addClass('blockOver');
	}, function() {
		$(this).removeClass('blockOver');
	}).click(function() {
		a=$(this).find('a')[0];
		var h = a.getAttribute("href");  
		var tt = a.getAttribute("target"); //if target -> open in new window, cancel a proper click
		!tt ? location = h : window.open(h); return false;
	})
})

	var id = document.body.getAttribute('id');
	if (id == 'bfaq') {

		$('#faqQ a').click(function(e) {
			var p = $(this).parent(); 
			hom.showFAQ($(this).attr('href'),p); // pass href of the a and it's parent as object
			hom.cancelClick(e);
		});
	};
	
	if (id == 'bcontact' || id == 'gift' || id == 'member') {
		$("#form1").validate({debug: false, focusInvalidElement: true});
	} 
	
},

/*  */
/* fixHeightIE6: function () { */
/* if ($('body').attr('id') == 'bcontact' || $('body').attr('id') == 'member' || $('body').attr('id') == 'bfaq') { */
/* $( '#contentRight' ).css('height', '600px'); */
/* } */
/* }, */

showFAQ: function(_this,p) {

scroll(0,0);
if ($('#displayed').length == 1) { // if answ exist
		$('#displayed').remove(); //delete it
		$('#hideQ').attr('id','');
	}
// show the answ:
var id = _this.substring(1);
var t = $(document.getElementById(id)); // find corresp div(answ)
divT = document.createElement( 'div' );// create container for showing answ
$(divT).attr('id','displayed').html(t.html()).insertAfter(p).show('slow');//add id and text to it, then insert it after
p.attr('id','hideQ'); //hide the question line

//add events to displayed answer's h2
var h2 = $(divT).find('h2');
		h2.click(function(e) {
			$('#displayed').remove(); //delete it
			$('#hideQ').attr('id','');
		});
		h2.hover(function() {
		$(this).addClass("over");
	}, function() {
		$(this).removeClass("over");
	}) ;
	
}, 

evenLeftRightCols: function() {

if ($('#leftCol').is() && $('#rightCol').is() && $('#rightCol').is('.even')) {
	var lCol = $('#leftCol')[0].offsetHeight;
	var rCol = $('#rightCol')[0].offsetHeight;

	if (lCol>rCol) {
		if (navigator.appVersion.match(/MSIE [0-6]\./)) {
			$('#rightCol').css('height',lCol); }
		else {
			$('#rightCol').css('height',lCol+'px'); }
	};
}
},

cancelClick:function(e){
		if (window.event){
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if (e && e.stopPropagation && e.preventDefault){
			e.stopPropagation();
			e.preventDefault();
		}
	}

}

$(document).ready(hom.init);

function asc(){
	document.add_sh_c.productId.value=arguments[0];
	document.add_sh_c.submit();
}