// searchPostcode function
// Open a window with postcode search results or displays error

function searchPostcode (obj)
{
	
	// Set postcode
	
	var strPostcode	= obj.value;
	
	// If the postcode has been entered
	
	if (strPostcode != '' && strPostcode != 'enter postcode')
	{
		
		// Check the postcode length is valid
		
		if (strPostcode.length >= 5 && strPostcode.length <= 10) 
		{
			
			// Open window with postcode search results
			
			window.open ('/book-eye-exam/search_postcode.php?postcode=' + escape (strPostcode), 'postcodesearch', 'height=435,width=650,resizable=1,scrollbars=1,status=1,titlebar=1', true);
			
		}
		
		// Else the postcode length is not valid
		
		else
		{
			
			// Display message
			
			alert ('Invalid postcode length!');
			
			// Focus postcode field
			
			obj.focus ();
			
		}
		
	}
	
	// Else the postcode has not been entered
	
	else
	{
		
		// Display message
		
		alert ('You did not enter your postcode!');
		
		// Focus postcode field
		
		obj.focus ();
		
	}
	
}

// setStore function
// Sets the store element

function setStore (intStore)
{
	
	// Set parent store element
	
	var objStore	= opener.document.getElementById ('eyeexam_booking_store_id');
	
	// Iterate through store options
	
	for (var x = 0; x < objStore.options.length; x++)
	{
		
		// If the option value is the same as the store id
		
		if (objStore.options[x].value == intStore)
		{
			
			// Set the option to be selected
			
			objStore.selectedIndex	= x;
			
			// Stop looping
			
			break;
			
		}
		
	}
	
	// Close window
	
	window.close ();
	
}

function checkStore(ref)
{
	opener.document.getElementById ('eyeexam_booking_digital').checked = false;
	var enhanced_stores = ['40','39','38','37','36','35','34','33','32','31','30','29','28','27','26','25','24','23','22','21','20','19','18','17','16','15','14','13','12','11','10','9','8','7','6','5','4','3','2','1','41','42','43','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','96','97','98','99','100','101','102','103','104','105','106','107','108','109','210','214','213','184','224','190','221','226','167','227','229','234','233','232','238','305','260','207','245','263','312','196','110','111','112','113','114','115','116','117','118','119','120','121','122','123','125','126','127','128','129','130','131','132','133','134','135','136','137','138','139','140','141','142','143','144','145','146','147','148','149','150','151','152','153','154','155','156','157','158','159','160','162','163','164','165','166','168','169','170','171','172','173','174','175','176','177','178','179','180','181','182','183','185','186','187','189','191','192','193','194','195','197','198','45','208','209','211','216','212','218','215','217','219','220','225','222','223','230','228','240','239','235','237','243','236','244','270','246','249','258','290','251','252','256','291','298','303','299','315','201','203','231','307','124'];
	for ( var i in enhanced_stores )
	{
		if(ref == enhanced_stores[i])
		{
			opener.document.getElementById ('eyeexam_booking_digital').checked = true;
		}
	    
	} 
    
}