function HasQuoteAlert()
{
	return alert('WARNING: You must wait for your quote request to be returned before you can continue and pay.'+"\n"+'We will contact you once the quote is ready.');	
}

function noPaymentSystem()
{
	return alert('Sorry, we are unable to accept online payments at the moment.  Please contact us either by email or over the phone regarding the products you would like to purchase.'+"\n"+'We will be able to take online payments in the New Year.');	
}

function strtolower(str) {
    // Makes a string lowercase  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/strtolower    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Onno Marsman
    // *     example 1: strtolower('Kevin van Zonneveld');
    // *     returns 1: 'kevin van zonneveld'
	return (str+'').toLowerCase();
}

function strpos(haystack, needle, offset) {
    // Finds position of first occurrence of a string within another  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/strpos    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Onno Marsman    
    // +   bugfixed by: Daniel Esteban
    // *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
    // *     returns 1: 14   
	var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}

function delQuoteFormConfirm()
{	
	missinginfo = '';
	confim = true;
		   
	if(document.quote_form.no_height_restriction.checked == true && document.quote_form.state_height.value == '')
	{
		confim = false;
	}
	else
	{
		if(document.quote_form.state_height.value != '')
		{
			if(strpos(strtolower(' ' + document.quote_form.state_height.value),'http://') > 0 || strpos(strtolower(' ' + document.quote_form.state_height.value),'https://') > 0)
			{
				confim = false;
			}
		}
	}
	
	if(document.quote_form.no_time_restriction.checked == true && document.quote_form.no_car_park.value == 'Paper')
	{
		confim = false;
	}

	if(document.quote_form.additional_comments.value != '')
	{
		if(strpos(strtolower(' ' + document.quote_form.additional_comments.value),'http://') > 0 || strpos(strtolower(' ' + document.quote_form.additional_comments.value),'https://') > 0)
		{
			confim = false;
		}
	}
	
/*	if(document.quote_form.yes_time_restriction.checked == true && document.quote_form.state_time.value == '')
	{
		confim = false;
	}

	if(document.quote_form.no_ground_steps.checked == true && document.quote_form.ground_steps_expand.value == '')
	{
		confim = false;
	}
	
	if(document.quote_form.floor_covering.value == '')
	{
		confim = false;
	}	
	
	if(document.quote_form.ground_floor.checked == false)
	{
		if(document.quote_form.stairs.checked == true)
		{
			if(document.quote_form.stair_covering.value == '' || document.quote_form.total_stairs.value == '' || document.quote_form.construction_type.value == '' || document.quote_form.staircase_width.value == '' || document.quote_form.lintel_height.value == '' || document.quote_form.resting_place.value == '' || document.quote_form.staircase_style.value == '')
			{
				confim = false;
			}
		}
		
		if(document.quote_form.lift.checked == true)
		{
			if(document.quote_form.loading_capacity.value == '' || document.quote_form.door_aperture.value == '')
			{
				confim = false;
			}
		}
	}
*/	//confim = false;
	if(confim == true)
	{
		missinginfo = 'Are you sure you want to submit this quote?';
		if(confirm(missinginfo) == true)
		{
			return document.quote_form.submit();
		}
		else
		{
			return false;
		}
	}
	else
	{
		//return alert('tits');
		return;
	}
}

function delQuoteLicenseFormConfirm()
{	
	missinginfo = '';
	confim = true;
	
	if(document.quote_form.pub_details.value == '')
	{
		confim = false;
	}
	else
	{
		if(document.quote_form.pub_details.value != '')
		{
			if(strpos(strtolower(' ' + document.quote_form.pub_details.value),'http://') > 0 || strpos(strtolower(' ' + document.quote_form.pub_details.value),'https://') > 0)
			{
				confim = false;
			}
		}
	}
	
	if(document.quote_form.pub_type_other.checked == true && document.quote_form.pub_type_other_specs.value == '')
	{
		confim = false;
	}
	else
	{
		if(document.quote_form.pub_type_other_specs.value != '')
		{
			if(strpos(strtolower(' ' + document.quote_form.pub_type_other_specs.value),'http://') > 0 || strpos(strtolower(' ' + document.quote_form.pub_type_other_specs.value),'https://') > 0)
			{
				confim = false;
			}
		}
	}
	
	if(document.quote_form.pub_deadline_date.value == '')
	{
		confim = false;
	}
	else
	{
/*		if(document.quote_form.pub_deadline_date.value <= jsdate.getDate())
		{
			missinginfo = jsdate.getDate()+'Required information is missing: \n' +
			missinginfo + '\n' + '';
			alert(missinginfo);
			return;
			confim = false;
		}
*/	}
	
	if(document.quote_form.license_declaration.checked == false)
	{
		confim = false;
	}
	
/*	if(document.quote_form.yes_time_restriction.checked == true && document.quote_form.state_time.value == '')
	{
		confim = false;
	}

	if(document.quote_form.no_ground_steps.checked == true && document.quote_form.ground_steps_expand.value == '')
	{
		confim = false;
	}
	
	if(document.quote_form.floor_covering.value == '')
	{
		confim = false;
	}	
	
	if(document.quote_form.ground_floor.checked == false)
	{
		if(document.quote_form.stairs.checked == true)
		{
			if(document.quote_form.stair_covering.value == '' || document.quote_form.total_stairs.value == '' || document.quote_form.construction_type.value == '' || document.quote_form.staircase_width.value == '' || document.quote_form.lintel_height.value == '' || document.quote_form.resting_place.value == '' || document.quote_form.staircase_style.value == '')
			{
				confim = false;
			}
		}
		
		if(document.quote_form.lift.checked == true)
		{
			if(document.quote_form.loading_capacity.value == '' || document.quote_form.door_aperture.value == '')
			{
				confim = false;
			}
		}
	}
*/	//confim = false;
	if(confim == true)
	{
		missinginfo = 'Are you sure you want to submit this quote?';
		if(confirm(missinginfo) == true)
		{
			return document.quote_form.submit();
		}
		else
		{
			return false;
		}
	}
	else
	{
		//return alert('tits');
		return;
	}
}

function clearTextField(field_name,message) 
{	
	if(document.getElementById(field_name).value == message)
	{
		document.getElementById(field_name).value = '';
	}
	return true;
}

function checkStockLevelLink(stock_level,prd_out_of_stock_text)
{
   if(stock_level < 1)
   {
		if(prd_out_of_stock_text != '')
		{
		alert('Sorry, this product is temporarily out of stock. Please contact us on '+ prd_out_of_stock_text + ' regarding availability.');
		}
		else
		{
		alert("Sorry, this product is temporarily out of stock.");
		}
      return false;
   }
}

function checkStockLevel(tt,stock_level,phone_number)
{
   if(stock_level < 1)
   {
     if(phone_number != '')
	 {
	 	alert('Sorry, this product is temporarily out of stock. Please contact us on '+ phone_number + ' regarding availability.');
	 }
	 else
	 {
	  	alert("Sorry, this product is temporarily out of stock.");
	 }
      tt.quantity.focus();
      return false;
   }
   else if(tt.quantity.value > stock_level)
   {
     if(phone_number != '')
	 {
	  	alert('Sorry, but the quantity you entered exceeds the level of stock ('+stock_level+') available for this product, Please contact us on '+ phone_number + ' regarding availability or use a quantity no greater than '+stock_level+'.');
	 }
	 else
	 {
	  	alert('Sorry, but the quantity you entered exceeds the level of stock ('+stock_level+') available for this product, please use a quantity no greater than '+stock_level+'.');
	 }
      tt.quantity.focus();
      return false;
   }
   else if(tt.quantity.value == '' || tt.quantity.value == 0)
   {
      alert("Sorry, you have not entered a quantity, please enter a quantity before adding this product to your basket.");
      tt.quantity.focus();
      return false;
   }
}

function checkTerms() { // Check T & C box is ticked before proceding to paypal
	missinginfo = '';
	if (!document.agreement_form.agreement.checked) 
	{
		missinginfo += '\n - You must agree to the Terms and Conditions';
	}
	
	if (missinginfo != '') 
	{
		missinginfo ='Required information is missing: \n' +
		missinginfo + '\n' + '';
		alert(missinginfo);
		/*return false;*/
	}
	else 
	{
		document.checkout.submit();
		return true;
	}
}
