function getHeaderMenu(){
	var html = '', submenu = '';
	$.getJSON("http://www.ipevo.com.tw/ajaxfun/getHeaderMenu/?jsoncallback=?", function(data){
		$.each(data, function(i, hh){
			/*munique = hh.unique_url;			
			$.each(hh.prods, function(j, p){									 
				submenu += '<li class="subNav"><a href="http://www.ipevo.com.tw/category/'+munique+'/'+p.unique_url+'" title="'+p.prod_name+'"><span class="dotlist">&nbsp;</span>'+p.prod_name+'</a></li>\n';
			});
			html = '<li><a href="http://www.ipevo.com.tw/category/'+hh.unique_url+'" id="menu_'+i+'" title="'+hh.cate_name+'"><img src="http://www.ipevo.com.tw/files'+hh.pic_normal+'" alt="" source="http://www.ipevo.com.tw/files'+hh.pic_over+'" name="menu_'+i+'" class="alltitle" /></a>';
			html += '<ul class="subhide">'+submenu+'</ul></li>\n';			
			$('.sf-menu.sf-navbar').append(html);
			html = '';
			submenu ='';*/
			
			$.each(hh.submenu, function(j, ss){
				submenu += '';						  
			});
			
			
			
			$('.apex-nav.jsddm').append();
			
		}); 		
	});
}
function getFooterProd(){
	$.getJSON("http://www.ipevo.com.tw/ajaxfun/getFooterProd/?jsoncallback=?", function(data){
		$.each(data, function(i, pp){
			$('#prods').append('<li><a href="http://www.ipevo.com.tw/prods/'+ pp.unique_url +'" title="' + pp.prod_name + '">' + pp.prod_name + '</a></li>');
		});   
	});
}
function getFooterFAQ(){
	$.getJSON("http://www.ipevo.com.tw/ajaxfun/getFooterFAQ/?jsoncallback=?", function(data){
		$.each(data, function(i, ff){
			$('#faqs').append('<li><a href="http://www.ipevo.com.tw/ec_faq/faqList/'+ ff.faq_id +'" title="' + ff.faq_title + '">' + ff.faq_title + '</a></li>');
		});   
	});
}
/*function _dosubscribe(){
	if($('#newsletter_email').val() != '' && $('#newsletter_email').val() != $('#newsletter_email').attr('title')){		
		$.ajaxSetup({ async: false });
		var post_url = 'http://www.ipevo.com.tw/mailing/subscription?jsoncallback=?';
		alert($("#frmNewsletter").serialize());
		$.post(post_url, $("#frmNewsletter").serialize(), function(result){ showMsg(_ge('newsletter'), result.msg); $.ajaxSetup({ async: true }); }, 'jsonp');	
	}
	else{ showMsg(_ge('newsletter'), _ge('msg_email_required')); }
}*/
function showMsg(title, msg){			
	var div_obj = '<div title="' + title + '">' + msg + '</div>';
	var buttons = {};
	buttons[_ge('closed')] = function() { $(this).focus().dialog('close'); };
	$(div_obj).dialog({
		width: 400,	resizable: false, modal: true, buttons: buttons, open: function(){ $(this).parents('.ui-dialog-buttonpane button:eq(0)').focus(); }
	});
}

jQuery.extend(jQuery.easing,{
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	}
});

$(function(){	
	$(document).click(function(e) { if (e.button == 0) { $("#cart").slideUp(300); } });

	if( $('.astro-attached').val() != '' && $('.astro-attached').val() != $('.astro-attached').attr('title') ){
		$('.attached-astro').hide();
	}

	$('input').click(function(){
		if($(this).val() == $(this).attr('title')){
			$(this).val('');
			if( $(this).is('.astro-attached') ){
				$('.attached-astro').hide();
			}
    	}
	}).blur(function(){
		if($(this).val() == ''){
			$(this).val($(this).attr('title'));
			if( $(this).is('.astro-attached') ){
				$('.attached-astro').show();
			}
		}
	})

	// added to enhance the hovering effects for submit buttons in ie6
	if($.browser.msie && $.browser.version==6){
		$('input[type="submit"]').each(function(){
			var motherClass = $(this).attr('class') + '_ie6';
			$(this).hover(function(){
				$(this).addClass(motherClass);
			},function(){
				$(this).removeClass(motherClass);
			});
		});
	} //end if

	// For Drop Down Menu Effects:
	// $('li.stayed').find('a').addClass('pointed');

	$('.apex-nav').each(function(){
		$(this).find('li').bind('mouseover', function(){
			$(this).find('.jsddm-son').show();
			if( $(this).is('.stayed') ){
				$(this).find('.jsddm-son').find('li:last > a').addClass('tail');
			}
		}).bind('mouseout', function(){
			$(this).find('.jsddm-son').hide();
		});
	}); //end each

  // Execute 'go-to-top' anchor at the bottom of the webpage	
	$('#go-to-top').show();
	$('#go-to-top').click(function(){
		$('html, body').animate({'scrollTop' : -10}, {
					'duration':900,
					'easing':'easeOutExpo',
					'queue':false,
					'complete':function(){
					$('#go-to-top').show();}
		});
		$(this).hide();
		return false;
	});

});
