/* begin Page */

/* Generated with Artisteer version 2.3.0.20258, file checksum is 6204CD61. */

cssFix = function(){
var u = navigator.userAgent.toLowerCase(),
addClass = function(el, val){
	if(! el.className) {
		el.className = val;
	} else {
		var newCl = el.className;
		newCl+=(' '+val);
		el.className = newCl;
	}
},
is = function(t){return (u.indexOf(t)!=-1)};
addClass(document.getElementsByTagName('html')[0],[
(!(/opera|webtv/i.test(u))&&/msie (\d)/.test(u))?('ie ie'+RegExp.$1)
: is('firefox/2')?'gecko firefox2'
: is('firefox/3')?'gecko firefox3'
: is('gecko/')?'gecko'
: is('chrome/')?'chrome'
: is('opera/9')?'opera opera9':/opera (\d)/.test(u)?'opera opera'+RegExp.$1
: is('konqueror')?'konqueror'
: is('applewebkit/')?'webkit safari'
: is('mozilla/')?'gecko':'',
(is('x11')||is('linux'))?' linux'
: is('mac')?' mac'
: is('win')?' win':''
].join(' '));
}();

var artEventHelper = {
	'bind': function(obj, evt, fn) {
		if (obj.addEventListener)
			obj.addEventListener(evt, fn, false);
		else if (obj.attachEvent)
			obj.attachEvent('on' + evt, fn);
		else
			obj['on' + evt] = fn;
	}
};

var userAgent = navigator.userAgent.toLowerCase();
var browser = {
	version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
	safari: /webkit/.test(userAgent) && !/chrome/.test(userAgent),
	chrome: /chrome/.test(userAgent),
	opera: /opera/.test(userAgent),
	msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
	mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
};

var artLoadEvent = (function() {
	

	var list = [];

	var done = false;
	var ready = function() {
		if (done) return;
		done = true;
		for (var i = 0; i < list.length; i++)
			list[i]();
	};

	if (document.addEventListener && !browser.opera)
		document.addEventListener('DOMContentLoaded', ready, false);

	if (browser.msie && window == top) {
		(function() {
			try {
				document.documentElement.doScroll('left');
			} catch (e) {
				setTimeout(arguments.callee, 10);
				return;
			}
			ready();
		})();
	}

	if (browser.opera) {
		document.addEventListener('DOMContentLoaded', function() {
			for (var i = 0; i < document.styleSheets.length; i++) {
				if (document.styleSheets[i].disabled) {
					setTimeout(arguments.callee, 10);
					return;
				}
			}
			ready();
		}, false);
	}

	if (browser.safari || browser.chrome) {
		var numStyles;
		(function() {
			if (document.readyState != 'loaded' && document.readyState != 'complete') {
				setTimeout(arguments.callee, 10);
				return;
			}
			if ('undefined' == typeof numStyles) {
				numStyles = document.getElementsByTagName('style').length;
				var links = document.getElementsByTagName('link');
				for (var i = 0; i < links.length; i++) {
					numStyles += (links[i].getAttribute('rel') == 'stylesheet') ? 1 : 0;
				}
				if (document.styleSheets.length != numStyles) {
					setTimeout(arguments.callee, 0);
					return;
				}
			}
			ready();
		})();
	}
	artEventHelper.bind(window, 'load', ready);
	return ({
		add: function(f) {
			list.push(f);
		}
	})
})();

(function() {
	// fix ie blinking
	var m = document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand;
	try { if (!!m) { m('BackgroundImageCache', false, true); } }
	catch (oh) { };
})();

function xGetElementsByClassName(clsName, parentEle, tagName) {
	var elements = null;
	var found = [];
	var s = String.fromCharCode(92);
	var re = new RegExp('(?:^|' + s + 's+)' + clsName + '(?:$|' + s + 's+)');
	if (!parentEle) parentEle = document;
	if (!tagName) tagName = '*';
	elements = parentEle.getElementsByTagName(tagName);
	if (elements) {
		for (var i = 0; i < elements.length; ++i) {
			if (elements[i].className.search(re) != -1) {
				found[found.length] = elements[i];
			}
		}
	}
	return found;
}

var styleUrlCached = null;
function GetStyleUrl() {
    if (null == styleUrlCached) {
        var ns;
        styleUrlCached = '';
        ns = document.getElementsByTagName('link');
        for (var i = 0; i < ns.length; i++) {
            var l = ns[i];
            if (l.href && /style\.ie6\.css(\?.*)?$/.test(l.href)) {
                return styleUrlCached = l.href.replace(/style\.ie6\.css(\?.*)?$/, '');
            }
        }

        ns = document.getElementsByTagName('style');
        for (var i = 0; i < ns.length; i++) {
            var matches = new RegExp('import\\s+"([^"]+\\/)style\\.ie6\\.css"').exec(ns[i].innerHTML);
            if (null != matches && matches.length > 0)
                return styleUrlCached = matches[1];
        }
    }
    return styleUrlCached;
}

function fixPNG(element) {
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
		var src;
		if (element.tagName == 'IMG') {
			if (/\.png$/.test(element.src)) {
				src = element.src;
				element.src = GetStyleUrl() + 'images/spacer.gif';
			}
		}
		else {
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
			if (src) {
				src = src[1];
				element.runtimeStyle.backgroundImage = 'none';
			}
		}
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "')";
	}
}

function artHasClass(el, cls) {
	return (el && el.className && (' ' + el.className + ' ').indexOf(' ' + cls + ' ') != -1);
}
/* end Page */

/* begin Menu */
function gTranslateFix() {
	var menus = xGetElementsByClassName("art-menu", document);
	for (var i = 0; i < menus.length; i++) {
		var menu = menus[i];
		var childs = menu.childNodes;
		var listItems = [];
		for (var j = 0; j < childs.length; j++) {
			var el = childs[j];
			if (String(el.tagName).toLowerCase() == "li") listItems.push(el);
		}
		for (var j = 0; j < listItems.length; j++) {
			var item = listItems[j];
			var a = null;
			var gspan = null;
			for (var p = 0; p < item.childNodes.length; p++) {
				var l = item.childNodes[p];
				if (!(l && l.tagName)) continue;
				if (String(l.tagName).toLowerCase() == "a") a = l;
				if (String(l.tagName).toLowerCase() == "span") gspan = l;
			}
			if (gspan && a) {
				var t = null;
				for (var k = 0; k < gspan.childNodes.length; k++) {
					var e = gspan.childNodes[k];
					if (!(e && e.tagName)) continue;
					if (String(e.tagName).toLowerCase() == "a" && e.firstChild) e = e.firstChild;
					if (e && e.className && e.className == 't') {
						t = e;
						if (t.firstChild && t.firstChild.tagName && String(t.firstChild.tagName).toLowerCase() == "a") {
							while (t.firstChild.firstChild) t.appendChild(t.firstChild.firstChild);
							t.removeChild(t.firstChild);
						}
						a.appendChild(t);
						break;
					}
				}
				gspan.parentNode.removeChild(gspan);
			}
		}
	}
}
artLoadEvent.add(gTranslateFix);

function Insert_Separators() {
	var menus = xGetElementsByClassName("art-menu", document);
	for (var i = 0; i < menus.length; i++) {
		var menu = menus[i];
		var childs = menu.childNodes;
		var listItems = [];
		for (var j = 0; j < childs.length; j++) {
			var el = childs[j];
			if (String(el.tagName).toLowerCase() == "li") listItems.push(el);
		}
		for (var j = 0; j < listItems.length - 1; j++) {
			var item = listItems[j];
			var span = document.createElement('span');
			span.className = 'art-menu-separator';
			var li = document.createElement('li');
			li.appendChild(span);
			item.parentNode.insertBefore(li, item.nextSibling);
		}
	}
}
artLoadEvent.add(Insert_Separators);

function Menu_IE6Setup() {
	var isIE6 = navigator.userAgent.toLowerCase().indexOf("msie") != -1
    && navigator.userAgent.toLowerCase().indexOf("msie 7") == -1;
	if (!isIE6) return;
	var aTmp2, i, j, oLI, aUL, aA;
	var aTmp = xGetElementsByClassName("art-menu", document, "ul");
	for (i = 0; i < aTmp.length; i++) {
		aTmp2 = aTmp[i].getElementsByTagName("li");
		for (j = 0; j < aTmp2.length; j++) {
			oLI = aTmp2[j];
			aUL = oLI.getElementsByTagName("ul");
			if (aUL && aUL.length) {
				oLI.UL = aUL[0];
				aA = oLI.getElementsByTagName("a");
				if (aA && aA.length)
					oLI.A = aA[0];
				oLI.onmouseenter = function() {
					this.className += " art-menuhover";
					this.UL.className += " art-menuhoverUL";
					if (this.A) this.A.className += " art-menuhoverA";
				};
				oLI.onmouseleave = function() {
					this.className = this.className.replace(/art-menuhover/, "");
					this.UL.className = this.UL.className.replace(/art-menuhoverUL/, "");
					if (this.A) this.A.className = this.A.className.replace(/art-menuhoverA/, "");
				};
			}
		}
	}
}
artLoadEvent.add(Menu_IE6Setup);
/* end Menu */

/* begin Button */


function artButtonsSetupJsHover(className) {
	var tags = ["input", "a", "button"];
	for (var j = 0; j < tags.length; j++){
		var buttons = xGetElementsByClassName(className, document, tags[j]);
		for (var i = 0; i < buttons.length; i++) {
			var button = buttons[i];
			if (!button.tagName || !button.parentNode) return;
			if (!artHasClass(button.parentNode, 'art-button-wrapper')) {
				if (!artHasClass(button, 'art-button')) button.className += ' art-button';
				var wrapper = document.createElement('span');
				wrapper.className = "art-button-wrapper";
				if (artHasClass(button, 'active')) wrapper.className += ' active';
				var spanL = document.createElement('span');
				spanL.className = "l";
				spanL.innerHTML = " ";
				wrapper.appendChild(spanL);
				var spanR = document.createElement('span');
				spanR.className = "r";
				spanR.innerHTML = " ";
				wrapper.appendChild(spanR);
				button.parentNode.insertBefore(wrapper, button);
				wrapper.appendChild(button);
			}
			artEventHelper.bind(button, 'mouseover', function(e) {
				e = e || window.event;
				wrapper = (e.target || e.srcElement).parentNode;
				wrapper.className += " hover";
			});
			artEventHelper.bind(button, 'mouseout', function(e) {
				e = e || window.event;
				button = e.target || e.srcElement;
				wrapper = button.parentNode;
				wrapper.className = wrapper.className.replace(/hover/, "");
				if (!artHasClass(button, 'active')) wrapper.className = wrapper.className.replace(/active/, "");
			});
			artEventHelper.bind(button, 'mousedown', function(e) {
				e = e || window.event;
				button = e.target || e.srcElement;
				wrapper = button.parentNode;
				if (!artHasClass(button, 'active')) wrapper.className += " active";
			});
			artEventHelper.bind(button, 'mouseup', function(e) {
				e = e || window.event;
				button = e.target || e.srcElement;
				wrapper = button.parentNode;
				if (!artHasClass(button, 'active')) wrapper.className = wrapper.className.replace(/active/, "");
			});
		}
	}
}

artLoadEvent.add(function() { artButtonsSetupJsHover("art-button"); });
/* end Button */ 


 function validateEmail(email)
		  	{
							if (email == ""){return false;}
							
							
							badStuff = ";:/,' \"\\";
							for (i=0; i<badStuff.length; i++)
							{
							badCheck = badStuff.charAt(i)
							if (email.indexOf(badCheck,0) != -1){return false;}
							}
							
							posOfAtSign = email.indexOf("@",1)
							if (posOfAtSign == -1){return false;}
							
							
							if (email.indexOf("@",posOfAtSign+1) != -1){return false;}
							
							posOfPeriod = email.indexOf(".", posOfAtSign)
							if (posOfPeriod == -1){return false;}
							
							if (posOfPeriod+2 > email.length){return false;}
							
							return true;
					}
function trimString(str)
{
	  while (str.charAt(0) == ' ')
	    str = str.substring(1);
	  while (str.charAt(str.length - 1) == ' ')
	    str = str.substring(0, str.length - 1);
	  return str;
}


function UserForm()
{   
  
        if(document.userReg.forename.value=="")
        {
            document.userReg.forename.select();
            alert("Please enter firstname");
            return false;
        }
        
        if(document.userReg.surname.value=="")
        {
            document.userReg.surname.select();
            alert("Please enter lastname");
            return false;
        }
        if(!validateEmail(document.userReg.email.value))
        {
            document.userReg.email.select();
            alert("Not a valid Email");
            return false;
        }
        if(document.userReg.password.value=="")
        {
           document.userReg.password.select();
            alert("Please enter password");
            return false;
        }
           if(document.userReg.password2.value=="")
        {
           document.userReg.password2.select();
            alert("Please enter confirmation password");
            return false;
        }
        if(document.userReg.password.value!=document.userReg.password2.value)
        {
            document.userReg.password2.select();
            alert("Password and confirmation password are not same");
            return false;
        }
}

function LoginForm()
{
    if(!validateEmail(document.userReg.username.value))
    {
        document.userReg.email.select();
        alert("Not a valid Email");
        return false;
    }
    if(document.userReg.password.value=="")
    {
        document.userReg.password.select();
        alert("Please enter password");
        return false;
    }
}

function ProfileForm()
{   
  
        if(document.userReg.forename.value=="")
        {
            document.userReg.forename.select();
            alert("Please enter firstname");
            return false;
        }
        
        if(document.userReg.surname.value=="")
        {
            document.userReg.surname.select();
            alert("Please enter lastname");
            return false;
        }
        
}

function PasswordForm()
{
    if(document.userReg.password.value=="")
        {
           document.userReg.password.select();
            alert("Please enter password");
            return false;
        }
           if(document.userReg.password2.value=="")
        {
           document.userReg.password2.select();
            alert("Please enter confirmation password");
            return false;
        }
        if(document.userReg.password.value!=document.userReg.password2.value)
        {
            document.userReg.password2.select();
            alert("Password and confirmation password are not same");
            return false;
        }
    
}


function single_double_pd(cntrl)
{
	var obj_dist=document.getElementById('spec_distance');
	var obj_near=document.getElementById('spec_near');
	var obj_single=document.getElementById('spec_pd');
	
	var dist_tr=document.getElementById('distpd');
	var near_tr=document.getElementById('nearpd');
	var single_tr=document.getElementById('singlepd');
	
	if(cntrl.checked)	
	{
		obj_dist.disabled=true;
		obj_dist.value="";
		dist_tr.style.visiblity="hidden";
		dist_tr.style.display="none";
		
		obj_near.disabled=true;
		obj_near.value="";
		near_tr.style.visibility="hidden";
		near_tr.style.display="none";
		
		obj_single.disabled=false;
		single_tr.style.visiblity="visible";
		single_tr.style.display="";
	}
	else
	{
		obj_dist.disabled=false;
		dist_tr.style.visiblity="visible";
		dist_tr.style.display="";
		
		obj_near.disabled=false;
		near_tr.style.visibility="visible";
		near_tr.style.display="";
		
		obj_single.disabled=true;
		obj_single.value="";
		single_tr.style.visiblity="hidden";
		single_tr.style.display="none";
	}
}
function markAllRows(container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

	    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
                         checkbox.checked = true;
              
           
        }
    }

    return true;
}

function applyformula(val)
{
	var flag=false;
	if(val>=2)
	{
		var rows = document.getElementById('frm').getElementsByTagName('tr');
		var checkbox;

	    for ( var i = 0; i < rows.length; i++ ) 
	    {

	        checkbox1 = rows[i].getElementsByTagName( 'input' )[0];
	
	        if ( checkbox1 && checkbox1.type == 'radio' && checkbox1.name=="lens_type") 
	        {
	             if(checkbox1.checked== true)
	             	flag=true;
	        }
    	    }
    	    if(!flag)
    	    {
    	    	alert("Please select lens type first");
    	    	return false;
    	    }
	}
	var flag=false;
	if(val==3)
	{
		var rows = document.getElementById('frm').getElementsByTagName('tr');
		var checkbox;

	    for ( var i = 0; i < rows.length; i++ ) 
	    {

	        checkbox1 = rows[i].getElementsByTagName( 'input' )[0];
	
	        if ( checkbox1 && checkbox1.type == 'radio' && checkbox1.name=="lens_design") 
	        {
	             if(checkbox1.checked== true)
	             	flag=true;
	        }
    	    }
    	    if(!flag)
    	    {
    	    	alert("Please select lens design first");
    	    	return false;
    	    }
	}
	var obj=document.getElementById('Formula');
	obj.value=val;
	var frm=document.getElementById('frm');
	frm.action="instant_selection.php#1";
	frm.submit();
}

function lensformula(val)
{
	var flag=false;
	if(val>=2)
	{
		var rows = document.getElementById('frm').getElementsByTagName('tr');
		var checkbox;

	    for ( var i = 0; i < rows.length; i++ ) 
	    {

	        checkbox1 = rows[i].getElementsByTagName( 'input' )[0];
	
	        if ( checkbox1 && checkbox1.type == 'radio' && checkbox1.name=="lens_type") 
	        {
	             if(checkbox1.checked== true)
	             	flag=true;
	        }
    	    }
    	    if(!flag)
    	    {
    	    	alert("Please select lens type first");
    	    	return false;
    	    }
	}
	var flag=false;
	if(val==3)
	{
		var rows = document.getElementById('frm').getElementsByTagName('tr');
		var checkbox;

	    for ( var i = 0; i < rows.length; i++ ) 
	    {

	        checkbox1 = rows[i].getElementsByTagName( 'input' )[0];
	
	        if ( checkbox1 && checkbox1.type == 'radio' && checkbox1.name=="lens_design") 
	        {
	             if(checkbox1.checked== true)
	             	flag=true;
	        }
    	    }
    	    if(!flag)
    	    {
    	    	alert("Please select lens design first");
    	    	return false;
    	    }
	}
	var obj=document.getElementById('Formula');
	obj.value=val;
	var frm=document.getElementById('frm');
	frm.action="lens-selection.php#1";
	frm.submit();
}

function chk_instant(thisform)
{
	with(thisform)
	{
		if((isNaN(spec_right_axis.value)) || (spec_right_axis.value < 0 || spec_right_axis.value > 180))
		{
			alert("Right Axis should be between 0 and 180");
			spec_right_axis.focus();
			return false;
		}
		if((isNaN(spec_left_axis.value)) || (spec_left_axis.value < 0 || spec_left_axis.value > 180))
		{
			alert("Left Axis should be between 0 and 180");
			spec_left_axis.focus();
			return false;
		}
		if(one_pd2.checked)
		{
	/*
		   if(trimString(spec_pd.value)=="" || (isNaN(spec_pd.value)))
		  {
		 	alert("Test Prob");	
		 	spec_pd.focus();
		 	return false;
		 	}
	 */
			if(spec_pd.value < 0 || spec_pd.value > 76)
			{
				alert("Valid range for PD is between 50 - 76");	
				spec_pd.focus();
				return false;
			}
		}
		else
		{
		/*
		 	if(trimString(spec_distance.value)=="" || (isNaN(spec_distance.value)))
       	{
				alert("Valid range for disatance PD is between 50 - 76");	
				spec_distance.focus();
				return false;
		 	}
	 */
			if(spec_distance.value < 0 || spec_distance.value > 76)
			{
				alert("Valid range for distance PD is between 50 - 76");	
				spec_distance.focus();
				return false;
			}
	/*
			if(trimString(spec_near.value)=="" || (isNaN(spec_near.value)))
			{
				alert("Valid range for near PD is between 50 - 76");	
				spec_near.focus();
				return false;
			}
  */
			if(spec_near.value < 0 || spec_near.value > 76)
			{
				alert("Valid range for near PD is between 50 - 76");	
				spec_near.focus();
				return false;
			}
		}
		/*
		if(trimString(pres_name.value)=="")
		{
			alert("Please Enter the name of Prescribing Optometrist or Ophthalmologist");
			pres_name.focus();
			return false;
		}
		if(trimString(pres_phone.value)=="")
		{
			alert("Please Enter the Phone Number of Prescribing Optometrist or Ophthalmologist");
			pres_phone.focus();
			return false;
		}	
		if(pres_date.selectedIndex==0)
		{
			alert("Please select the date of prescription");
			pres_date.focus();
			return false;
		}
		if(pres_month.selectedIndex==0)
		{
			alert("Please select the month of prescription");
			pres_month.focus();
			return false;
		}
		if(pres_year.selectedIndex==0)
		{
			alert("Please select the year of prescription");	
			pres_year.focus();
			return false;
		}
		*/
	}
}

function chk_selection()
{
	var type_checked=false;
	var design_checked=false;
	var tint_checked=false;
	var rows = document.getElementById('frm').getElementsByTagName('tr');
	var checkbox;

	    for ( var i = 0; i < rows.length; i++ ) 
	    {
	        checkbox1 = rows[i].getElementsByTagName( 'input' )[0];
	        if(checkbox1 && checkbox1.type == 'radio')
	        {
		        if(checkbox1.name=="lens_type") 
		        {
		             if(checkbox1.checked== true)
		             	type_checked=true;
	        	}
	        	if(checkbox1.name=="lens_design") 
		        {
		             if(checkbox1.checked== true)
		             	design_checked=true;
	        	}
	        	if(checkbox1.name=="features") 
		        {
		             if(checkbox1.checked== true)
		             	tint_checked=true;
	        	}
	        }
        }
        if(type_checked==false)
        {
        	alert("Please Select a Lens Type");	
        	return false;
        }
        if(type_checked==false)
        {
        	alert("Please Select a Lens Design");	
        	return false;
        }
        if(tint_checked==false)
        {
        	alert("Please Select a Tints and Coatings");	
        	return false;
        }
}

function chk_getquote(thisform)
{
	var type_checked=false;
	var tint_checked=false;
	var rows = document.getElementById('frm').getElementsByTagName('tr');
	var checkbox;

	    for ( var i = 0; i < rows.length; i++ ) 
	    {
	        checkbox1 = rows[i].getElementsByTagName( 'input' )[0];
	        if(checkbox1 && checkbox1.type == 'radio')
	        {
		        if(checkbox1.name=="used_for") 
		        {
		             if(checkbox1.checked== true)
		             	type_checked=true;
	        	}
	        	
	        	if(checkbox1.name=="features") 
		        {
		             if(checkbox1.checked== true)
		             	tint_checked=true;
	        	}
	        }
        }
        if(type_checked==false)
        {
        	alert("Please Select What will you be using the glasses for?");	
        	return false;
        }
       
        if(tint_checked==false)
        {
        	alert("Please Select a Features");	
        	return false;
        }
	
	
	with(thisform)	
	{
		/*if(trimString(used_for.value)=="")
		{
			alert("Please Enter What will you be using the glasses for?");
			used_for.focus();
			return false;
		}
		if(trimString(design.value)=="")
		{
			alert("Please Enter What Lens Design would you like on the lenses?");
			design.focus();
			return false;
		}
		if(trimString(features.value)=="")
		{
			alert("Please Enter What features would you like on the lenses?");
			features.focus();
			return false;
		}
		if(trimString(tint_colour.value)=="")
		{
			alert("Please Enter Tint Colour?");
			tint_colour.focus();
			return false;
		}*/
		
		if(trimString(firstname.value)=="")
		{
			alert("Please Enter FirstName");	
			firstname.focus();
			return false;
		}
		if(trimString(surname.value)=="")
		{
			alert("Please Enter SurName");
			surname.focus();
			return false;
		}
		if(trimString(address.value)=="")
		{
			alert("Please Enter Address");
			address.focus();
			return false;
		}
		if(trimString(city_town.value)=="")
		{
			alert("Please Enter City-town");
			city-town.focus();
			return false;
		}
		if(trimString(state.value)=="")
		{
			alert("Please Enter State");
			state.focus();
			return false;
		}
		
		if(trimString(postcode.value)=="")
		{
			alert("Please Enter Postcode");
			postcode.focus();
			return false;
		}
		
		if(!validateEmail(email.value))
		{
			alert("Please Enter Valid Email");
			email.focus();
			return false;
		}
		if(bdate.selectedIndex==0)
		{
			alert("Please select date of your birth");
			bdate.focus();
			return false;
		}
		if(bmonth.selectedIndex==0)
		{
			alert("Please select the month of your birth");
			bmonth.focus();
			return false;
		}
		if(byear.selectedIndex==0)
		{
			alert("Please Enter the year of your month");
			byear.focus();
			return false;
		}
	}
}


//Function to check quote number
function chk_quote_no()
{
	var obj=document.getElementById('pricing3');
	var cntrl=document.getElementById('quote');
	if(obj.checked)	
	{
		if(trimString(cntrl.value)=="")
		{
			alert("Please Enter Quote number");
			cntrl.focus();
			return false;
		}
		if(isNaN(cntrl.value))
		{
			alert("Pleas Enter a number for Quote number");
			cntrl.focus();
			return false;
		}
	}
}

function pd_check(cntrl)
{
	if(cntrl.value!="" && !isNaN(cntrl.value))
	{
		if(parseFloat(cntrl.value)>=25 && parseFloat(cntrl.value)<=38)
		{
			cntrl.value=parseFloat(cntrl.value)*2;
		}
	}
}

function chk_quoteno(thisform)
{
	with(thisform)	
	{
		if(bdate.selectedIndex==0)
		{
			alert("Please Select Your Date of Birth");
			bdate.focus();
			return false;
		}
		if(bmonth.selectedIndex==0)
		{
			alert("Please Select Your Month of Month");	
			bmonth.focus();
			return false;
		}
		if(byear.selectedIndex==0)
		{
			alert("Please Select Your Year of Birth");
			byear.focus();
			return false;
		}
		if(!validateEmail(email.value))
		{
			alert("Please Enter a valid Email address");	
			email.focus();
			return false;
		}
	}
}


function final_submit()
{
	var type_checked=false;
	var design_checked=false;
	var tint_checked=false;
	var clr_checked=false;
	var rows = document.getElementById('frm').getElementsByTagName('tr');
	var tint_clr=document.getElementById('tint_colour');
	var checkbox;

	    for ( var i = 0; i < rows.length; i++ ) 
	    {
	        checkbox1 = rows[i].getElementsByTagName( 'input' )[0];
	        if(checkbox1 && checkbox1.type == 'radio')
	        {
		        if(checkbox1.name=="lens_type") 
		        {
		             if(checkbox1.checked== true)
		             	type_checked=true;
	        	}
	        	
	        	if(checkbox1.name=="lens_design") 
		        {
		             if(checkbox1.checked== true)
		             	design_checked=true;
	        	}
	        	
	        	if(checkbox1.name=="features") 
		        {
		             if(checkbox1.checked== true)
		             	tint_checked=true;
	        	}
	        }
        }
        if(type_checked==false)
        {
        	alert("Please Select a Lens Type.");	
        	return false;
        }
       
       	if(design_checked==false)
       	{
       		alert("Please Select a Lens Design");	
       		return false;
       	}
       	
        if(tint_checked==false)
        {
        	alert("Please Select a Tints & Coatings");	
        	return false;
        }
        
        if(tint_clr.length > 1)
        {
        	if(tint_clr.value=='0')
        	{
        		alert("Please Select a Tint Colour");
        		return false;
        	}
        }
        document.frm.action="cart.php";
	
}

function lens_selected()
{
	var type_checked=false;
	var design_checked=false;
	var tint_checked=false;
	var clr_checked=false;
	var rows = document.getElementById('frm').getElementsByTagName('tr');
	var tint_clr=document.getElementById('tint_colour');
	var checkbox;

	    for ( var i = 0; i < rows.length; i++ ) 
	    {
	        checkbox1 = rows[i].getElementsByTagName( 'input' )[0];
	        if(checkbox1 && checkbox1.type == 'radio')
	        {
		        if(checkbox1.name=="lens_type") 
		        {
		             if(checkbox1.checked== true)
		             	type_checked=true;
	        	}
	        	
	        	if(checkbox1.name=="lens_design") 
		        {
		             if(checkbox1.checked== true)
		             	design_checked=true;
	        	}
	        	
	        	if(checkbox1.name=="features") 
		        {
		             if(checkbox1.checked== true)
		             	tint_checked=true;
	        	}
	        }
        }
        if(type_checked==false)
        {
        	alert("Please Select a Lens Type.");	
        	return false;
        }
       
       	if(design_checked==false)
       	{
       		alert("Please Select a Lens Design");	
       		return false;
       	}
       	
        if(tint_checked==false)
        {
        	alert("Please Select a Tints & Coatings");	
        	return false;
        }
        
        if(tint_clr.length > 1)
        {
        	if(tint_clr.value=='0')
        	{
        		alert("Please Select a Tint Colour");
        		return false;
        	}
        }
        document.frm.action="mycart.php";
	
}

function same(e)
{
	if(e.chk.checked)
	{
		e.sfristname.value = e.bfristname.value;
		e.slastname.value = e.blastname.value;		
		e.saddress.value = e.baddress.value;
		e.spostcode.value = e.bpostcode.value;
		e.scity.value = e.bcity.value;	
		e.sregion.value = e.bregion.value;
		e.stelephone.value = e.btelephone.value;
		e.scountry.selectedIndex = e.bcountry.selectedIndex ;
	}
}

function chk_checkout(thisform)
{
	with(thisform)	
	{
		if(trimString(bfristname.value)=="")	
		{
			alert("Please Enter First Name for billing information");	
			bfristname.focus();
			return false;
		}
		if(trimString(blastname.value)=="")	
		{
			alert("Please Enter Last Name for billing information");	
			blastname.focus();
			return false;
		}
		if(trimString(baddress.value)=="")	
		{
			alert("Please Enter billing address");	
			baddress.focus();
			return false;
		}
		if(trimString(btelephone.value)=="")	
		{
			alert("Please Enter Telephone for billing information");	
			btelephone.focus();
			return false;
		}
		if(trimString(bcity.value)=="")	
		{
			alert("Please Enter city/town for billing information");	
			bcity.focus();
			return false;
		}
		if(trimString(bregion.value)=="")	
		{
			alert("Please Enter Region/State/Province for billing information");	
			bregion.focus();
			return false;
		}
		if(trimString(bpostcode.value)=="")	
		{
			alert("Please Enter postcode for billing information");	
			bpostcode.focus();
			return false;
		}
		
		
		if(trimString(sfristname.value)=="")	
		{
			alert("Please Enter First Name for shipping information");	
			sfristname.focus();
			return false;
		}
		if(trimString(slastname.value)=="")	
		{
			alert("Please Enter Last Name for shipping information");	
			slastname.focus();
			return false;
		}
		if(trimString(saddress.value)=="")	
		{
			alert("Please Enter shipping address");	
			saddress.focus();
			return false;
		}
		if(trimString(stelephone.value)=="")	
		{
			alert("Please Enter Telephone for shipping information");	
			stelephone.focus();
			return false;
		}
		if(trimString(scity.value)=="")	
		{
			alert("Please Enter city/town for shipping information");	
			scity.focus();
			return false;
		}
		if(trimString(sregion.value)=="")	
		{
			alert("Please Enter Region/State/Province for shipping information");	
			sregion.focus();
			return false;
		}
		if(trimString(spostcode.value)=="")	
		{
			alert("Please Enter postcode for shipping information");	
			spostcode.focus();
			return false;
		}
	}
}

function chk_forgot(thisform)
{	
	with(thisform)
	{
		if(!validateEmail(username.value))	
		{
			alert("Please Enter a valid Email Address");
			username.focus();
			return false;
		}
	}
}

function chk_payonline(thisform)
{	return true;	/*
	with(thisform)	
	{
		if(!terms.checked)	
		{
			alert("You must accept the terms and conditions to continue");
			return false;
		}
	}	*/
	
}

function change_details(cntrl)
{
	var obj=document.getElementById('state');
	var obj1=document.getElementById('city');
	if(cntrl.value=="AUS")
	{
		obj.innerHTML="State/Territory";
		obj1.innerHTML="City/Town";
	}
	else if(cntrl.value=="NZ")
	{
		obj.innerHTML="Town or City";
		obj1.innerHTML="Suburb or RD No.";
	}	
	else if(cntrl.value=="US")
	{
		obj.innerHTML="State";
		obj1.innerHTML="Suburb/City";
	}
	else if(cntrl.value=="UK")
	{
		obj.innerHTML="Post Town";
		obj1.innerHTML="Locality";
	}	
	else if(cntrl.value=="CA")
	{
		obj.innerHTML="Town or City";
		obj1.innerHTML="Suburb/City";
	}	
}

function change_quotedetails(cntrl)
{
	var obj=document.getElementById('state');
	var obj1=document.getElementById('city');
	if(cntrl.value=="AUS")
	{
		obj.innerHTML="State/Territory*";
		obj1.innerHTML="City/Town*";
	}
	else if(cntrl.value=="NZ")
	{
		obj.innerHTML="Town or City*";
		obj1.innerHTML="Suburb or RD No.*";
	}	
	else if(cntrl.value=="UK")
	{
		obj.innerHTML="Post Town*";
		obj1.innerHTML="Locality*";
	}	
	else if(cntrl.value=="US")
	{
		obj.innerHTML="State*";
		obj1.innerHTML="Suburb/City*";
	}	
	else if(cntrl.value=="CA")
	{
		obj.innerHTML="State*";
		obj1.innerHTML="Suburb/City*";
	}	
}


function chk_opthinfo(thisform)
{
	with(thisform)
	{
		if(trimString(pres_name.value)=="")
		{
			alert("Please Enter the name of Prescribing Optometrist or Ophthalmologist");
			pres_name.focus();
			return false;
		}
		if(trimString(pres_phone.value)=="")
		{
			alert("Please Enter the Phone Number of Prescribing Optometrist or Ophthalmologist");
			pres_phone.focus();
			return false;
		}	
		if(pres_date.selectedIndex==0)
		{
			alert("Please selcct the date of prescription");
			pres_date.focus();
			return false;
		}
		if(pres_month.selectedIndex==0)
		{
			alert("Please select the month of prescription");
			pres_month.focus();
			return false;
		}
		if(pres_year.selectedIndex==0)
		{
			alert("Please select the year of prescription");	
			pres_year.focus();
			return false;
		}
	}
}

//Function for checking balance entry in sphere drop down
function chk_BAL(cntrl)
{
	
	var cnindex=cntrl.selectedIndex;
	var cnval=cntrl.options[cnindex].value;
	
	var rold=document.getElementById('sp_r_sph');
	var lold=document.getElementById('sp_l_sph');
	
	
	if(cnval != "bal")
	{
		if(cntrl.id=="spec_right_sphere")
			rold.value=cnval;
		else if(cntrl.id=="spec_left_sphere")
			lold.value=cnval;
	}
	
	var left_sphere=document.getElementById('spec_left_sphere');
	var left_cyl = document.getElementById('spec_left_cyl');
	var left_axis = document.getElementById('spec_left_axis');
	
	var right_cyl = document.getElementById('spec_right_cyl');
	var right_axis = document.getElementById('spec_right_axis');
	var right_sphere=document.getElementById('spec_right_sphere');

	
	if(cnval=="bal")
	{
		if(cntrl.id == "spec_right_sphere")
		{
			index=left_sphere.selectedIndex;
			var vl=left_sphere.options[index].value;
			
			if(vl=="bal")
			{
				alert("Sphere for both the eyes cannot be BAL");
				//cntrl.focus();
				if(rold.value!="")
					cntrl.value=rold.value;
				else
					cntrl.selectedIndex=32;
				return false;
			}
			else
			{
				
				right_cyl.selectedIndex=24;
				right_cyl.disabled=true;
				
				right_axis.value="0";
				right_axis.disabled=true;
				
				return true;
			}
		}
		else if(cntrl.id=="spec_left_sphere")
		{
			
			index=right_sphere.selectedIndex;
			var vl=right_sphere.options[index].value;
			if(vl=="bal")
			{
				alert("Sphere for both the eyes cannot be BAL");
				if(lold.value!="")
					cntrl.value=lold.value;
				else
					cntrl.selectedIndex=32;
				//cntrl.focus();
				return false;
			}
			else
			{
				
				
				left_cyl.selectedIndex=24;
				left_cyl.disabled=true;
				
				left_axis.value="0";
				left_axis.disabled=true;
				
				return true;
			}
			
		}
	}
	else
	{
		if(cntrl.id == "spec_right_sphere")
		{
			
			right_cyl.disabled=false;
			right_axis.disabled=false;
			
			return true;

		}
		else if(cntrl.id == "spec_left_sphere")
		{
			
			left_cyl.disabled=false;
			left_axis.disabled=false;
			
			return true;
			
		}
	}
}

