function OpenQuickOrder(LoggedIn)
{
	
	if (LoggedIn == 0)
	{
		//first slide down and blink the message box
		//$("#QuickOrder").slideDown("medium").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
		
		$("#QuickOrder").slideDown("medium");
		
		//close the message box when cross red image is clicked
		$("#close_message").click(function(){
			$("#QuickOrder").slideUp("medium");
			
		});
		
		setTimeout(function(){
						$('#QuickOrder').slideUp("slow");
					}, 6000);
	}
	else
	{
		$("#QuickOrder").slideDown("medium");
	
		//close the message box when cross red image is clicked
		$("#close_message").click(function(){
			$("#QuickOrder").slideUp("medium");
			
		});
	}	
};

function checkModelNumber(ModelNumber, ItemID)
{
	//check to make sure that ModelNumber is not empty
	if (ModelNumber != "") 
	{
	
		//load AJAX call, output results, based upon passed criteria
		$.ajax({
			type: "GET",
			url: "https://www.dwyer-inst.com/ShoppingCart/checkModelNumber.cfm",
			data: "ModelNumber=" + ModelNumber,
			success: function(result){
				if (result.indexOf("invalid") != -1) {
					//alert(jQuery.trim(result));
					$("#QuickOrderStatus").show();
					$("#QuickOrderStatus").html("" + result);
					
					$("#" + ItemID + "Status").html("<img width='15' src='http://www.dwyer-inst.com/images/red_x.jpg'/>");
					$("#" + ItemID).addClass("BadModelNum");
					
					setTimeout(function(){
						$('#QuickOrderStatus').slideUp("slow");
					}, 5000);
				}
				else {
					if ($("#" + ItemID).hasClass("BadModelNum")) {
						$("#" + ItemID).removeClass("BadModelNum");
						$("#" + ItemID).addClass("GoodModelNum");
						$("#" + ItemID + "Status").html("<img width='15' src='http://www.dwyer-inst.com/images/green-check.gif'/>");
					}
					else {
						$("#" + ItemID).addClass("GoodModelNum");
						$("#" + ItemID + "Status").html("<img width='15' src='http://www.dwyer-inst.com/images/green-check.gif'/>");
					}
					
				}
			}
		});
	}
};

function validateQuickOrder()
{
	
	//run a check on all ModelNumbers, since they may put in just one, and not have an un-blur opportunity
	var count = 1;
	for (count = 1; count < 6; count++) 
	{
		if ($("#Item"+count).val() != "") {
			checkModelNumber($("#Item"+count).val(), "Item"+count);
		}
	}
	
	//check if any of the sub-rows have class of BadModelNum
	//If any are of that class, then disallow submission
	var count = 1;
	for (count = 1; count < 6; count++) 
	{
		if ($("#Item"+count).hasClass("BadModelNum") == true) {
			alert("One or more product numbers are invalid. Please correct numbers and retry");
			return false;
		}
	}

	var cookieEnabled = CheckCookies();
	if (!cookieEnabled) 
	{	
		alert ("Cookies are Required for this function. Please enable cookies in your browser and then try again"); 
		return false;
	}
	
	
};
/*
function CheckCookies(FollowURL)
{
	var cookieEnabled=(navigator.cookieEnabled)? true : False;
	if (!cookieEnabled) 
	{	
		alert ("Cookies are Required for this function. Please enable cookies in your browser and then try again"); 
		return false;
	}
	else
	{
		alert ("Cookies enabled, following supplied URL");
		window.location(FollowURL);	
	}	
};
*/

function CheckURL(ReturnURL)
{
	var cookieEnabled = CheckCookies();
	if (!cookieEnabled) 
	{	
		
	}
	else
	{	
		window.location = ReturnURL;	
		//window.location = "#APPLICATION.site.sURL#LoginInfo/Login.cfm";	
	}	
};

function CheckCookies()
{
	// CHECK IF COOKIES ARE ENABLED 
	
	var exp = new Date(); 
 	exp.setTime(exp.getTime() + 1800000); 
 
	// first write a test cookie 
 
 	setCookie("cookies", "cookies", exp, false, false, false); 
 	if (document.cookie.indexOf('cookies') == -1) { 
 		alert('Your browser does not have cookies enabled. Please enable cookies in your browser preferences.'); 
		return false;
 	} 
	else {
		//no alert if cookies are enabled, as we only care about them being disabled
		//alert('Cookies are enabled.');
		return true;
	}
 
 	// now delete the test cookie 
	exp = new Date(); 
  	exp.setTime(exp.getTime() - 1800000); 
  	setCookie("cookies", "cookies", exp, false, false, false); 

};

function setCookie(name, value, expires, path, domain, secure) { 
		var curCookie = name + "=" + escape(value) + 
		((expires) ? "; expires=" + expires.toGMTString() : "") + 
		((path) ? "; path=" + path : "") + 
		((domain) ? "; domain=" + domain : "") + 
		((secure) ? "; secure" : ""); 
		document.cookie = curCookie; 
}; 		

