﻿// ready function to handle product detail page
$(document).ready(function() {
	$(".bar2_button_act a").hover(function() { 
		var currentImg = $(this).children("img").attr('src'); 
		$(this).children("img").attr('src', $(this).children("img").attr('hover')); 
		$(this).children("img").attr('hover', currentImg); 
	}, function() { 
		var currentImg = $(this).children("img").attr('src'); 
		$(this).children("img").attr('src', $(this).children("img").attr('hover')); 
		$(this).children("img").attr('hover', currentImg); 
	}); 
	
//	$("a[rel='login_popup']").colorbox();
//	$("a[rel='login_popup1']").colorbox();

	$("a[rel='login_popup']").colorbox({innerWidth:460, innerHeight:290, inline:true, 
		onClosed:function(){ requestXmlGET3('login_op.php', 'pdisplay=display_login_form', '#inline_login', '#reset_form', 99); },
		href:"#inline_login"
	});
	$("a[rel='login_popup1']").colorbox({innerWidth:460, innerHeight:290, inline:true, 
		onClosed:function(){ requestXmlGET3('login_op.php', 'pdisplay=display_login_form', '#inline_login', '#reset_form', 99); },
		href:"#inline_login"
	});
	$("a[rel='privacy_popup']").colorbox();
	
	$('ul.sf-menu').superfish({
		delay:  500,
		autoArrows:  false,                           // disable generation of arrow mark-up 
		speed:  'normal',
		dropShadows: false 
	});
	
	$("#login_form").submit(function() {
		var mErrorFlag = false;
		
		// get form values
		if($('[name=luserid]').val() == '') {
			mErrorFlag = true;
			$('[name=luserid]').css('background-color', "red");
		}else {
			$('[name=luserid]').css('background-color', "white");
		}

		if($('[name=lpassword]').val() == '') {
			mErrorFlag = true;
			$('[name=lpassword]').css('background-color', "red");
		}else {
			$('[name=lpassword]').css('background-color', "white");
		}

		if(mErrorFlag == true) {
			$('#msg_content').css('color', "red");
		}else {
/*			
			$('#msg_content').css('color', "gray");
*/
			requestXmlPOST3('login_op.php', 'pdisplay=display_processing', '#msg_content', this);
		}
		return false;
	});
	
	$("#login_form").keypress(function(e) {
		if (e.which == 13) {
			return false;
		}
	});

	$("a[rel='exec_ajax']").click(function() {
		eval($(this).attr('href'));
		return false;
	});
	
});

