function showItemDiv(){
	
	document.getElementById('layerDiv').style.visibility='visible';
	
	
	return false;
}

function hideItemDiv(){
	
	window.parent.document.getElementById('layerDiv').style.visibility='hidden';
	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') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}


function radar(id,col_id){
	url="/items/getItemYearSizes.php?id="+id+"&col_id="+col_id;
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState== 4) {
			if(xmlhttp.status == 200){
				radarResponse = xmlhttp.responseText;
				//alert(radarResponse);
				document.getElementById('dd4').innerHTML='';
				document.getElementById('dd4').innerHTML=radarResponse;
				document.getElementById('sizesm_id').value='';
				document.getElementById('sizesy_id').value='';
			}
		}
	}
	xmlhttp.send(null);
	return false;
}



function addToShopCart(item_id){
	
	url="/shop_cart/insertItem.php?item_id="+item_id;
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState== 4) {
			if(xmlhttp.status == 200){
				radarResponse = xmlhttp.responseText;
				alert(radarResponse);
				ajaxCart(radarResponse);
			}
		}
	}
	xmlhttp.send(null);
	return false;
}



var xmlhttp1=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 {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp1 = false;
}
}
@end @*/
if (!xmlhttp1 && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp1 = new XMLHttpRequest();
	} catch (e) {
		xmlhttp1=false;
	}
}
if (!xmlhttp1 && window.createRequest) {
	try {
		xmlhttp1 = window.createRequest();
	} catch (e) {
		xmlhttp1=false;
	}
}

var xmlhttp2=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 {
xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp2 = false;
}
}
@end @*/
if (!xmlhttp2 && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp2 = new XMLHttpRequest();
	} catch (e) {
		xmlhttp2=false;
	}
}
if (!xmlhttp2 && window.createRequest) {
	try {
		xmlhttp2 = window.createRequest();
	} catch (e) {
		xmlhttp2=false;
	}
}

function ajaxCart(resp){
	url1="/shop_cart/ajax_cart.php";
	
	xmlhttp1.open("GET",url1,true);
	xmlhttp1.onreadystatechange=function(){
		if(xmlhttp1.readyState== 4) {
			if(xmlhttp1.status == 200){
				radarResponse1 = xmlhttp1.responseText;
				//alert(radarResponse1);
				document.getElementById('lyr1').innerHTML='';
				document.getElementById('lyr1').innerHTML=radarResponse1;
				
			}
		}
	}
	xmlhttp1.send(null);
	
	return false;
}


function validChars(e,goods,field,max) {
	
	var key, keychar;
	key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
	if (key == null) return true;
 
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
 	if(keychar<0) return false;
	if (goods.indexOf(keychar) != -1)
		return true;
 
	if (key==null || key==0 || key==8 || key==9 || key==13 || key==27)
		return true;
 
	return false;
}


function validateAddMember(){
	var root=document.members;
	
	if(root.fname.value==''){
		alert('Please enter your first name');
		root.fname.focus();
		return false;
	}
	if(root.lname.value==''){
		alert('Please enter your last name');
		root.lname.focus();
		return false;
	}
	if(root.job.value==''){
		alert('Please specify your job title');
		root.job.focus();
		return false;
	}
	
	if(root.email.value==''){
		alert('Please enter your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	email = root.email;
	flag=email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(root.cname.value==''){
		alert('Please enter the name of your company');
		root.cname.focus();
		return false;
	}
	if(root.business.value==''){
		alert('Please select your business from the drop down menu');
		root.business.focus();
		return false;
	}
	if(root.cadd.value==''){
		alert('Please enter the address of your company');
		root.cadd.focus();
		return false;
	}
	if(root.postcode.value==''){
		alert('Please enter your postcode');
		root.postcode.focus();
		return false;
	}
	if(root.country.value==''){
		alert('Please select a country from the drop down menu');
		root.country.focus();
		return false;
	}
	
	if(root.facsimile.value==''){
		alert('Please specify a facsimile');
		root.facsimile.focus();
		return false;
	}
	
	if(root.tel.value==''){
		alert('Please enter your telephone number');
		root.tel.focus();
		return false;
	}
	
	if(root.find.value==''){
		alert('Please specify how did you find us');
		root.find.focus();
		return false;
	}
	
	if(root.username.value==''||root.username.value=='Username'){
		alert('Please enter your username');
		root.username.focus();
		return false;
	}
	if(root.pass.value==''){
		alert('Please enter your password');
		root.pass.focus();
		return false;
	}
	if(root.con_pass.value==''){
		alert('Please enter your password confirmation');
		root.con_pass.focus();
		return false;
	}
	if(root.pass.value!=root.con_pass.value){
		alert('The password and its confirmation do not match');
		root.con_pass.focus();
		return false;
	}
	
	var chk = root.terms.checked;
	
	if(!chk){
		alert('Please confirm that you have read the terms.');
		return false;
	}
	
	return true;
}

function validateEditMember(){
	var root=document.members;
	
	if(root.fname.value==''){
		alert('Please enter your first name');
		root.fname.focus();
		return false;
	}
	if(root.lname.value==''){
		alert('Please enter your last name');
		root.lname.focus();
		return false;
	}
	
	if(root.email.value==''){
		alert('Please enter your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	email = root.email;
	flag=email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(root.country.value==''){
		alert('Please select a country from the drop down menu');
		root.country.focus();
		return false;
	}
	
	if(root.cname.value==''){
		alert('Please enter the name of your company');
		root.cname.focus();
		return false;
	}
	
	if(root.cadd.value==''){
		alert('Please enter the address of your company');
		root.cadd.focus();
		return false;
	}
	if(root.postcode.value==''){
		alert('Please enter your postcode');
		root.postcode.focus();
		return false;
	}
	
	
	if(root.facsimile.value==''){
		alert('Please specify a facsimile');
		root.facsimile.focus();
		return false;
	}
	
	if(root.tel.value==''){
		alert('Please enter your telephone number');
		root.tel.focus();
		return false;
	}
	
	return true;
}

function validateChangePass(){
	var root=document.members;
	if(root.old.value==''||root.newp.value==''||root.confnew.value==''){
		alert('Please fill up all the fields');
		return false;
	}
	return true;
}

function validateLogin(){
	var root = document.form2;
	if(root.username.value==''){
		alert('Please enter your username');
		root.username.focus();
		return false;
	}
	if(root.password.value==''){
		alert('Please enter your password');
		root.password.focus();
		return false;
	}
	
	return true;
}

function validateForgotPass(){
	var root = document.forgot_pass;
	if(root.username.value==''){
		alert('Please enter your username');
		root.username.focus();
		return false;
	}
	if(root.email.value==''){
		alert('Please enter your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	email = root.email;
	flag=email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.focus();
		return false;
	}
	return true;
}

function checkContactform(){
	var root=document.contact;

	var fname=root.fname;
	var lname=root.lname;
	var email=root.email;
	var job=root.job;
	var tel=root.tel;
	var msg=root.msg;
	
	if(fname.value==""){
		alert('Please enter your first name.');
		fname.focus();
		return false;
	}
	
	if(lname.value==""){
		alert('Please enter your last name.');
		lname.focus();
		return false;
	}
	
	if(job.value==""){
		alert('Please enter your job title.');
		job.focus();
		return false;
	}
	if(tel.value==""){
		alert('Please enter your telephone number.');
		tel.focus();
		return false;
	}
	
	if(email.value==""){
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		email.focus();
		return false;
	}
	
	if(msg.value==""){
		alert('Please enter your message.');
		msg.focus();
		return false;
	}
	
}

function clearContactForm(){
	var root=document.contact;
	if(confirm('Are you sure you want to clear this form?')){
		root.name.value='';
		root.prenom.value='';
		root.email.value='';
		root.message.value='';
	}
	return false;
}

function popImage(imageURL,imageTitle){
	showItemDiv();
	var img = "<div style='position:relative;z-index:100;width:100%;height:1px;'><img src='"+imageURL+"' style='border-width:3px;border-style:solid;border-color:#000000;'></div><div style='position:relative;z-index:101;left:30px;width:95%;' class='menlinks'>&nbsp;[&nbsp;<a href='#' class='menulinks' style='background-color:#ffffff;' onclick=\"document.getElementById('popup').innerHTML='';hideItemDiv();return false;\">&nbsp;<b>Close</b>&nbsp;</a>&nbsp;]</div>";
	document.getElementById('popup').innerHTML=img;
}