function validatemail()
{
	var maxLength = 50;	
	var errString = "";
	var empty 	  = false;
	var toolong   = false;
	var unchecked = false;
	var name	  = "response";
	var nameLen	  = name.length;
	for( var i = 0; i < document.mailinglist.elements.length; i++ )
	{
		if( document.mailinglist.elements[i].name.substr( 0, nameLen ) != name )
		{
			if( document.mailinglist.elements[i].type == "text" )
			{
				if( document.mailinglist.elements[i].value == "" )
					empty = true;
				if( document.mailinglist.elements[i].value.length > maxLength )
					toolong = true;
			}
			else if( document.mailinglist.elements[i].type == "textarea" )
			{
				if( document.mailinglist.elements[i].value == "" )
					empty = true;
				if( document.mailinglist.elements[i].value.length > maxLength * 4 )
					toolong = true;
			}
			else if( document.mailinglist.elements[i].type == "radio" )
			{
				var radioname 	= document.mailinglist.elements[i].name;
				var radiolen  	= eval( 'document.mailinglist.' + radioname + '.length' );
				var somechecked = false;
				for( var j = 0; j < radiolen; j++ )
				{
					if( eval( 'document.mailinglist.' + radioname + '[j].checked' ) )
					{
						somechecked = true;
						break;
					}
				}
				if( !somechecked )
					unchecked = true;
			}
		}
	}
	
	if( empty )
		errString += "";
	else
	{
	if( document.mailinglist.email != null )		
		errString += checkEmail( document.mailinglist.email.value );
	}
	if( unchecked )
		errString += "";
	if( errString != "" )
	{
		alert( "Please enter a valid email address." + errString );
		return false;
		
	}
	var w = 250;
	var h = 20;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var emailone = document.mailinglist.email.value;
	window.open('http://www.micism.com/msubmit.php?email='+emailone+'','mailinglistpop','top='+TopPosition+',left='+LeftPosition+',toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+w+',height='+h+'');
	return false;
}
function checkEmail( emailStr )
{
	var exclude 	= /[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check		= /@[\w\-]+\./;
	var checkend 	= /\.[a-zA-Z]{2,3}$/;

	if( ( emailStr.search( exclude ) != -1 ) || ( emailStr.search( check ) == -1 ) || ( emailStr.search( checkend ) == -1 ) )
		return( "\n " );
	else
		return "";
}

var logowidth=88
var logoheight=30
var logoimage=new Image(logowidth,logoheight)
logoimage.src="./graphics/i/madeonamic.png"
var alttext="made on a MicŪ"
var visibleduration=6000
var Hoffset=15 
var Voffset=15 
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
var watermark_obj=ie? document.all.watermarklogo : document.getElementById? document.getElementById("watermarklogo") : document.watermarklogo

function insertimage(){
if (ie||document.getElementById)
watermark_obj.innerHTML='<img src="'+logoimage.src+'" width="'+logowidth+'" height="'+logoheight+'" border=0 alt="'+alttext+'">'
else if (document.layers){
watermark_obj.document.write('<img src="'+logoimage.src+'" width="'+logowidth+'" height="'+logoheight+'" border=0 alt="'+alttext+'">')
watermark_obj.document.close()
}
}

function positionit(){
var dsocleft=ie? document.body.scrollLeft : pageXOffset
var dsoctop=ie? document.body.scrollTop : pageYOffset
var window_width=ie? document.body.clientWidth : window.innerWidth-20
var window_height=ie? document.body.clientHeight : window.innerHeight

if (ie||document.getElementById){
watermark_obj.style.left=parseInt(dsocleft)+parseInt(window_width)-logowidth-Hoffset
watermark_obj.style.top=parseInt(dsoctop)+parseInt(window_height)-logoheight-Voffset
}
else if (document.layers){
watermark_obj.left=dsocleft+window_width-Hoffset-logowidth
watermark_obj.top=dsoctop+window_height-logoheight-Voffset
}
}

function hidewatermark(){
if (document.layers)
watermark_obj.visibility="hide"
else
watermark_obj.style.visibility="hidden"
clearInterval(watermarkinterval)
}

function beingwatermark(){
watermarkinterval=setInterval("positionit()",50)
insertimage()
if (visibleduration!=0)
setTimeout("hidewatermark()",visibleduration*100000)
}

if (ie||document.getElementById||document.layers)
window.onload=beingwatermark
/*
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}*/

// thumbnail zoom

var ie=document.all
var ns6=document.getElementById&&!document.all

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}

function enlarge(which, e, position, imgwidth, imgheight){
if (ie||ns6){
crossobj=document.getElementById? document.getElementById("showthumb") : document.all.showimage
if (position=="center"){
pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2
vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2
if (window.opera && window.innerHeight) //compensate for Opera toolbar
vertpos=pgyoffset+window.innerHeight/2-imgheight/2
vertpos=Math.max(pgyoffset, vertpos)
}
else{
var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX - 4
var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY - 4
}

crossobj.style.left=horzpos+"px"
crossobj.style.top=vertpos+"px"

crossobj.innerHTML='<img alt="Loading image, please wait..." title="click to close this image" src="'+which+'" onClick="closepreview()">'
crossobj.style.visibility="visible"
return false
}
else //if NOT IE 4+ or NS 6+, simply display image in full browser window
return true
}

function closepreview(){
crossobj.style.visibility="hidden"
}

function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx+"px"
crossobj.style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
}
return false
}

function initializedrag(e){
if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}

document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")

function storeimages(){

ranNum= Math.round(Math.random()*13)
//ranNum = 14;
	switch (ranNum) {
		case 0 :
			var display = "<a href='./merchant.mvc?Screen=PROD&Product_Code=dks&Category_Code=swe' target='_self' title='Diedrich Knickerbocker sweatshirt'><img src='./graphics/i/hp/large_banner_anointedS_knicks.jpg' width=580 height=159 border=0></a>";
		break
		case 1 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=dktc&Category_Code=hat' target='_self' title='Diedrich Knickerbocker trucker cap'><img src='./graphics/i/hp/large_banner_beelow_knicks.jpg' width=580 height=159 border=0></a>";
		break
		case 2 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=mmst&Category_Code=tee' target='_self' title='metallic mic(saver) t-shirt'><img src='./graphics/i/hp/large_banner_beelow_metallicmicsaver.jpg' width=580 height=159 border=0></a>";
		break
		case 3 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=ms03t&Category_Code=tee' target='_self' title='mic(saver) #03 t-shirt'><img src='./graphics/i/hp/large_banner_each_micsaver03.jpg' width=580 height=159 border=0></a>";
		break
		case 4 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=mpht&Category_Code=tee' target='_self' title='microphon(e)ism t-shirt'><img src='./graphics/i/hp/large_banner_each_microphoneism.jpg' width=580 height=159 border=0></a>";
		break
		case 5 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=vct&Category_Code=tee' target='_self' title='voCalifornia t-shirt'><img src='./graphics/i/hp/large_banner_each_vocalifornia.jpg' width=580 height=159 border=0></a>";
		break
		case 6 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=heot&Category_Code=tee' target='_self' title='HUMAN EAT OX t-shirt'><img src='./graphics/i/hp/large_banner_eat_ox.jpg' width=580 height=159 border=0></a>";
		break
		case 7 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=bct&Category_Code=tee' target='_self' title='breath control t-shirt'><img src='./graphics/i/hp/large_banner_group.jpg' width=580 height=159 border=0></a>";
		break
		case 8 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=msh&Category_Code=hoo' target='_self' title='mic(saver) hoodie'><img src='./graphics/i/hp/large_banner_micsaver.jpg' width=580 height=159 border=0></a>";
		break
		case 9 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=gblt&Category_Code=tee' target='_self' title='global(ism) t-shirt'><img src='./graphics/i/hp/large_banner_shlo_globalism.jpg' width=580 height=159 border=0></a>";
		break
		case 10 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=dkt&Category_Code=tee' target='_self' title='Diedrich Knickerbocker t-shirt'><img src='./graphics/i/hp/large_banner_knicks.jpg' width=580 height=159 border=0></a>";
		break
		case 11 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=ibat&Category_Code=tee' target='_self' title='IBA t-shirt'><img src='./graphics/i/hp/large_banner_click_IBA.jpg' width=580 height=159 border=0></a>";
		break
		case 12 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=ms03t&Category_Code=tee' target='_self' title='mic(saver) #03 t-shirt'><img src='./graphics/i/hp/large_banner_each_micsaver03_2.jpg' width=580 height=159 border=0></a>";
		break
		case 13 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=wb01&Category_Code=acc' target='_self' title='mic(saver) sweatband'><img src='./graphics/i/hp/large_banner_sweatband.jpg' width=580 height=159 border=0></a>";
		break
		case 14 :
			var display ="<a href='./merchant.mvc?Screen=PROD&Product_Code=xmh&Category_Code=hoo' target='_self' title='X-MIC hoodie'><img src='./graphics/i/hp/large_banner_shlo_xmic.jpg' width=580 height=170 border=0></a>";
		break
	}
return display;
}

function stills ( pname,pimg,pwidth,pheight ) {
	window.open('./sizing.php?pimg='+ pimg +'&pwidth='+ pwidth + '&pheight='+ pheight + '&pname='+ pname,'clothingsizes','top=20,left=40,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=300');
}
function paypal () {
	window.open('https://www.paypal.com/uk/cgi-bin/webscr?cmd=xpt/popup/OLCWhatIsPayPal-outside','olcwhatispaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=400, height=350');
}
