// JavaScript Document
function load() {
      if (GBrowserIsCompatible()) {
        	
			
			var blueIcon = new GIcon(G_DEFAULT_ICON); 
			blueIcon.image = "http://www.worldofwool.co.uk/images/mapicon.png"; 
			blueIcon.iconSize = new GSize(28, 48);
			blueIcon.iconAnchor = new GPoint(14, 48); 
			blueIcon.shadowSize = new GSize(37, 34); 
			markerOptions = { icon:blueIcon }; 
			
			var map = new GMap2(document.getElementById("map"));
			var center = new GLatLng(53.640522727241915, -1.8322277069091797);
			map.setCenter(center, 12);
			map.addControl(new GLargeMapControl());
			//map.addControl(new GSmallMapControl());
			//map.addControl(new GMapTypeControl());
			//map.addControl(new GSmallZoomControl());
			var marker = new GMarker(center,markerOptions);
			
			GEvent.addListener(marker, "click", function() {
			  //marker.openInfoWindowHtml("<div style='width:200px;font-size:12px;'>World Of Wool</div>");
			});
	
			map.addOverlay(marker);
			//marker.openInfoWindowHtml("<div style='width:200px;font-size:12px;'>World Of Wool</div>");
     
	 }
}


function mouseover(x,value){
	
	x.style.opacity = value/10;
	x.style.filter = 'alpha(opacity=' + value*10 + ')';

}

function hidesignupemail(){
	document.getElementById('signupemail').style.display="none";
	document.getElementById('emailfield').focus();
}

function printflash(swf,w,h,div){
		var so = new SWFObject(swf, "flash-animations", w, h, "8", "#ffffff");
		so.addParam("wmode", "transparent");
		so.write(div);	
}

function ini_gallery(x,id,gid){
	
	var m=document.getElementById('mask');
	var g=document.getElementById('gallery');
	var c=document.getElementById('container');
	var f=document.getElementById('footer');

	
	if(x=='load'){
		
		f.style.display="none";
		m.style.display="block";
		g.style.display="block";
		c.style.height="100%";
		c.style.overflow="hidden";
		
		var so = new SWFObject("/media/gallery2010.swf?r=2&www=/&iid="+id+"&gallid="+gid, "wowgallery", "900", "600", "8", "#333333");
		so.write("gallery");
		
		
	}else{
		
		f.style.display="block";
		m.style.display="none";
		g.style.display="none";
		c.style.height="auto";
		c.style.overflow="visible";
		
	}
	
}

cid=0;

function gotonews(){
	window.location.href = url[cid];	
}

function geturl(u){
	window.location.href=u;	
}

function vidiprint(x,y,z){
	if(y==4) { y=1 }
	cid=y;
	var vidi=document.getElementById('vidi');
	x++;
	if(z==0){
		vidi.innerHTML=""+news[y].substr(0,x)+"_";
		z=1;
	}else{
		vidi.innerHTML=""+news[y].substr(0,x)+"";
		z=0;
	}
	
	if(x<news[y].length){ vp=setTimeout(function(){ vidiprint(x,y,z) },120); } else { vp=setTimeout(function(){ pause(x,y,1,0) },120); }
	
}

function pause(x,y,c,z){
	var vidi=document.getElementById('vidi');
	
	if(z==0){
		vidi.innerHTML=""+news[y].substr(0,x)+"_";
		z=1;
	}else{
		vidi.innerHTML=""+news[y].substr(0,x)+"";
		z=0;
	}
	c++;
	if(c==25){ vp=setTimeout(function(){ vidiprint(-1,y+1,0) },120); } else { vp=setTimeout(function(){ pause(x,y,c,z) },120); }
}


function dispprod(x){
	
	
	var m=document.getElementById('mask');
	var d=document.getElementById('prodpopup');
	var s=document.getElementById('prodpopupsrc');
	var c=document.getElementById('container');
	var f=document.getElementById('footer');
	var l=document.getElementById('legal');
	
	f.style.display="none";
	l.style.display="none";
	m.style.display="block";
	d.style.display="block";
	c.style.height="100%";
	c.style.overflow="hidden";
	s.src="/prodimages/"+x+".jpg";

 	//var so = new SWFObject("/media/loader.swf?imgurl=/prodimages/"+x+".jpg", "flash-animations", "600", "450", "6", "#ffffff");
	//so.write("prodpopup");

	
}


function closeprod(){
	
	var m=document.getElementById('mask');
	var d=document.getElementById('prodpopup');
	var c=document.getElementById('container');
	var f=document.getElementById('footer');
	var l=document.getElementById('legal');
	var s=document.getElementById('prodpopupsrc');
	
	l.style.display="block";
	f.style.display="block";
	m.style.display="none";
	d.style.display="none";
	c.style.height="auto";
	c.style.overflow="visible";
	s.src="/prodimages/_blank.jpg";

}



function disptops(id){
	
	
	var m=document.getElementById('mask');
	var d=document.getElementById('dmt'+id);
	var c=document.getElementById('container');
	var f=document.getElementById('footer');
	var n=document.getElementById('nav');
	
	n.style.display="none";
	f.style.display="none";
	m.style.display="block";
	d.style.display="block";
	c.style.height="100%";
	c.style.overflow="hidden";
	
}


function closetops(id){
	
	var m=document.getElementById('mask');
	var d=document.getElementById('dmt'+id);
	var c=document.getElementById('container');
	var f=document.getElementById('footer');
	var n=document.getElementById('nav');
	
	n.style.display="block";
	f.style.display="block";
	m.style.display="none";
	d.style.display="none";
	c.style.height="auto";
	c.style.overflow="visible";

}

function namecheck(x){
	if(x.value.length>4 && x.value.match(" ")!=null){
		document.getElementById('v_name').src='images/tick.jpg';
	}else{
		document.getElementById('v_name').src='images/error.jpg';	
	}
}

function emailcheck(x){
	if(x.value.length>7 && x.value.indexOf(".")!=-1 && x.value.match("@")!=null && x.value.match(" ")==null ){
		document.getElementById('v_email').src='images/tick.jpg';
	}else{
		document.getElementById('v_email').src='images/error.jpg';	
	}
	//alert(x.value.lastIndexOf("."))
}

function addcheck(x,img){
	if(x.value.length>4){
		document.getElementById(img).src='images/tick.jpg';
	}else{
		document.getElementById(img).src='images/error.jpg';	
	}
}

function Validate(event) { 
      /*var bRes = false; 


      if ((event.keyCode >= 48) && (event.keyCode <= 57))  //0-9 
      { 
         bRes = true; 
      } 

		return bRes; */
} 
	
function phonecheck(x,img){
	
	if(x.value.length>6){
		document.getElementById(img).src='images/tick.jpg';
	}else{
		document.getElementById(img).src='images/error.jpg';	
	}
	
}

function quickadd(c,x){
			
		if(x!=c){
			
			x++
		
			var f=document.getElementById('tForm'+x)
			var id=f.id.value;
			var quant=f.quant.value;

			var qa=document.getElementById('quickadd');
			qa.innerHTML="<img src='/quickadd.php?id="+id+"&quant="+quant+"&mode=add' />";
			
			quickadder=setTimeout(function(){ quickadd(c,x) },500)
		
		}else{
			
			clearTimeout(quickadder);
			document.getElementById('qab').src='/images/added.jpg';
		}
	
	//var qa=document.getElementById('quickadd');
	//qa.innerHTML="<img src='quickadd.php?id=T100&quant=1&mode=add' />";
	/*qa.innerHTML="<script language='javascript' src='quickadd.php?id=T100&quant=1&mode=add' /></script>";*/
	
}

function reorder(id){

	var qa=document.getElementById('quickadd');
	qa.innerHTML="<img src='reorder.php?id="+id+"' />";
	
}

function cartval(frm){
	
		if(frm.license.checked==false){
			alert("Please proceed only if you are in acceptance of our terms and conditions.\nYou must signal your acceptance by checking the box.");
			mainform.license.focus();
			return (false);
		}
		


		if(frm.name.value==""){
			
			alert("Please enter a value in the field \"Full Name\".");
			frm.name.focus();
			return (false);
		}
		gotspace=false;
		var checkStr = frm.name.value;
		for (i = 0; i < checkStr.length; i++){
			if(checkStr.charAt(i)==" ")
				gotspace=true;
		}
		if(!checkedfullname && !gotspace){
			alert("This message will not be shown again.\nPlease be sure to enter your first and last name in the field \"Full Name\".");
			frm.name.focus();
			checkedfullname=true;
			return (false);
		}
		if(frm.email.value==""){
			alert("Please enter a value in the field \"Email\".");
			frm.email.focus();
			return (false);
		}
		validemail=0;
		var checkStr = frm.email.value;
		for (i = 0; i < checkStr.length; i++){
			if(checkStr.charAt(i)=="@")
				validemail |= 1;
			if(checkStr.charAt(i)==".")
				validemail |= 2;
		}
		if(validemail != 3){
			alert("Please enter a valid email address.");
			frm.email.focus();
			return (false);
		}
		if(frm.address.value==""){
			alert("Please enter a value in the field \"Address\".");
			frm.address.focus();
			return (false);
		}
		if(frm.city.value==""){
			alert("Please enter a value in the field \"City\".");
			frm.city.focus();
			return (false);
		}
		if(frm.country.selectedIndex < numhomecountries){
			if(frm.state.selectedIndex==0){
				alert("Please select a County (UK)");
				frm.state.focus();
				return (false);
			}
		}else{
			if(frm.state2.value==""){
				alert("Please enter a value in the field \"State / Province (Non UK)\".");
				frm.state2.focus();
				return (false);
			}
		}
		if(frm.zip.value==""){
			alert("Please enter a value in the field \"Postcode\".");
			frm.zip.focus();
			return (false);
		}
		
		if(frm.phone2.value==""){
			alert("Please enter a value in the field \"Phone\".");
			frm.phone2.focus();
			return (false);
		}

		
		mainform.payprovider.value=1;
		mainform.submit();
}

/*	

	
*/



