var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
if (checkIt('msie')) {
if (detect.charAt(place + thestring.length) < 7) {
	document.write('<link href="includes/explorer.css" rel="stylesheet" type="text/css">');
}}
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
	alert ("Hi");
}

function buycheck(product,formname) {
if (document.buy.option.value == '') {
alert('please what type of ' + product + ' you wish to buy');
} else {
document.buy.submit();
}
}
var answer;
function quantity(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function delcheck(deltype,url) 
{ 
answer = confirm("You have selected "+deltype+"\n Is this correct?")
if (answer !=0) 
{ 
location = url; 
} 
}
function detailaddress () {
}
function popup2(url,width,height)
{
	newwindow=window.open(url,'name','height='+height+',width='+width+',scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
function checkform()
{
	if(!document.details.name.value) {
		alert ("Please fill in your name");
		document.details.name.focus()
		return false;
	} else if(!document.details.email.value) {
		alert ("Please fill in your email address");
		document.details.email.focus()
		return false;
	} else if(!document.details.address1.value) {
		alert ("Please fill in your address");
		document.details.address1.focus()
		return false;
	} else if(!document.details.city.value) {
		alert ("Please fill in your city");
		document.details.city.focus()
		return false;
	} else if(!document.details.country.value) {
		alert ("Please select a country");
		return false;
	} else if(!document.details.postcode.value) {
		alert ("Please fill in your postcode");
		document.details.postcode.focus()
		return false;
	} else { 
	return true;
	}
	return false;
}
var xmlhttp=false; 
/*@cc_on @*/ 
/*@if (@_jscript_version >= 5) 
// JScript gives us Conditional compilation, we can cope with old IE versions. 
// and security blocked creation of the objects. 
  try { 
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
  } catch (e) { 
   try { 
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
   } catch (E) { 
    xmlhttp = false; 
   } 
  } 
@end @*/ 
if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
  xmlhttp = new XMLHttpRequest(); 
} 
function quickadd(prod,sp,cat_num) {
		day = new Date();
	id = day.getTime();
	var url = "includes/quickadd.php?cartnum="+cat_num+"&prodnum="+prod+"&time="+id;
	
		 xmlhttp.open("GET", url); 
    xmlhttp.onreadystatechange = function() { 
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
	   if (!xmlhttp.responseText) {
		document.getElementById(sp).innerHTML = "<a href=\"cart.php\" style=\"text-transform:none; color:#333333;\">Added to Cart</a>";
	  }
	}	 
	}
    xmlhttp.send(null);

}
function subform1() {
	document.step1.action = "detailcollect.php?fp=1";
	submain1();
}
function subform2() {
	document.step1.action = "detailcollect.php?si=1";
	submain1();
}
function subform3() {
	document.step1.action = "detailcollect.php?su=1";
	submain1();
}
function subform3a() {
	document.step1.action = "detailcollect-admin.php?su=1";
	document.step1.submit();
}
function subform5() {
	document.step1.action = "customer.php?si=1";
	submain2();
}
function subform6() {
	document.step1.action = "customer.php?fp=1";
	submain2();
}
function submain1() {
		var emailfilter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (document.step1.action == "detailcollect.php?fp=1") {
		if (!document.step1.got_email.value) {
			alert ("Please enter an email address");
			document.step1.got_email.focus();
			return false;
		} else if (!emailfilter.test(document.step1.got_email.value)) {
		alert ("Please enter a valid email address");
		document.step1.got_email.focus();
		return false;
			} else {
			document.step1.submit();
		}
		return false;	
	} else if (document.step1.action == "detailcollect.php?si=1") {
		if (!document.step1.got_email.value) {
			alert ("Please enter an email address");
			document.step1.got_email.focus();
			return false;
		} else if (!emailfilter.test(document.step1.got_email.value) && document.step1.got_email.value != "admin") {
		alert ("Please enter a valid email address");
		document.step1.got_email.focus();
		return false;
			}else if (!document.step1.got_password.value) {
			alert ("Please enter an password");
			document.step1.got_password.focus();
			return false;
		} else{
			document.step1.submit();
		}
		
	} else if (document.step1.action == "detailcollect.php?su=1") {
		if (!document.step1.new_email.value) {
			alert ("Please enter an email address");
			document.step1.new_email.focus();
			return false;
		} else if (!emailfilter.test(document.step1.new_email.value)) {
		alert ("Please enter a valid email address");
		document.step1.new_email.focus();
		return false;
			}else if (!document.step1.new_fname.value) {
			alert ("Please enter a First Name");
			document.step1.new_fname.focus();
			return false;
		} else if (!document.step1.new_lname.value) {
			alert ("Please enter a Last Name");
			document.step1.new_lname.focus();
			return false;
		} else if (!document.step1.new_phone.value) {
			alert ("Please enter a Phone Number");
			document.step1.new_phone.focus();
			return false;
		} else if (!document.step1.new_pass.value) {
			alert ("Please enter a Password");
			document.step1.new_pass.focus();
			return false;
		}  else if (document.step1.new_pass.value != document.step1.new_confirm.value) {
			alert ("The password does not match the confirmed password");
			document.step1.new_pass.focus();
			return false;
		} else {
			document.step1.submit();
		}
	} else {
		return false;
	}
	return false;
}
function submain2() {
		var emailfilter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (document.step1.action == "customer.php?fp=1") {
		if (!document.step1.got_email.value) {
			alert ("Please enter an email address");
			document.step1.got_email.focus();
			return false;
		} else if (!emailfilter.test(document.step1.got_email.value)) {
		alert ("Please enter a valid email address");
		document.step1.got_email.focus();
		return false;
			} else {
			document.step1.submit();
		}
		return false;	
	} else if (document.step1.action == "customer.php?si=1") {
		if (!document.step1.got_email.value) {
			alert ("Please enter an email address");
			document.step1.got_email.focus();
			return false;
		} else if (!emailfilter.test(document.step1.got_email.value) && document.step1.got_email.value != "admin") {
		alert ("Please enter a valid email address");
		document.step1.got_email.focus();
		return false;
			}else if (!document.step1.got_password.value) {
			alert ("Please enter an password");
			document.step1.got_password.focus();
			return false;
		} else{
			document.step1.submit();
		}
		
	} else {
		return false;
	}
	return false;
}
function subbill() {
	if (!document.bill.street.value) {
		alert ("Please enter a House Number & Street");
		document.bill.street.focus();
		return false;
	} else if (!document.bill.town.value) {
		alert ("Please enter a Town");
		document.bill.town.focus();
		return false;
	} else if (!document.bill.county.value) {
		alert ("Please enter a County");
		document.bill.county.focus();
		return false;
	} else if (!document.bill.postcode.value) {
		alert ("Please enter a Postcode");
		document.bill.postcode.focus();
		return false;
	} else {
		return true;
	}
}
function subdel() {
var myOption
for (i=document.del.payment_type.length-1; i > -1; i--) {
if (document.del.payment_type[i].checked) {
var myOption = 1;
}
}

	if (!document.del.street2.value) {
		alert ("Please enter a House Number & Street");
		document.del.street2.focus();
		return false;
	} else if (!document.del.town2.value) {
		alert ("Please enter a Town");
		document.del.town2.focus();
		return false;
	} else if (!document.del.county2.value) {
		alert ("Please enter a County");
		document.del.county.focus();
		return false;
	} else if (!document.del.postcode2.value) {
		alert ("Please enter a Postcode");
		document.del.postcode2.focus();
		return false;
	} else if (!document.del.deliveryadd2.checked) {
		alert ("Please accept our terms and conditions");
		document.del.deliveryadd2.focus();
		return false;
	} else if (!document.del.deliveryadd2.value) {
		alert ("Please accept our terms and conditions");
		return false;
	} else if (!myOption) {
		alert("You must select a Payment Type");
		return false;
	} else {
		return true;
	} return false;
}
var newwindow;
function popimage(url, height, width,scrollbars) {
	if (scrollbars == 1) {
		var scrollba = "yes";
	} else {
		var scrollba = "no";
	}
	newWindow = window.open(url,'name','height=' + height + ',width=' + width + ',scrollbars='+scrollba);
}
function donothing() { 
}
function opacity(id, opacStart, opacEnd, millisec) { 
document.getElementById("searchLink").innerHTML = "<a href=\"javascript:donothing()\">Search</a> ";
if (opacStart == 0) {
	changeOpac(0, id);
	document.getElementById(id).style.display = "block"; 
	
}
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "','1')",(timer * speed)); 
            timer++; 
	
			
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "','2')",(timer * speed)); 
            timer++; 
						if (i == 100) {

document.getElementById("searchLink").innerHTML = "<a href=\"javascript:opacity('searchDiv', 100, 0, 500)\">Search</a> ";
			}
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id, type) { 
if (opacity == 0 && type==1) {
	document.getElementById(id).style.display = "none"; 
document.getElementById("searchLink").innerHTML = "<a href=\"javascript:opacity('searchDiv', 0, 100, 500)\">Search</a> ";
			}
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 
function changepic (picture) {
	document.getElementById("mainpic").src = "images/"+picture;
}
