	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	ns6 = (document.getElementById)? true:false

function show(id) {
		hideall();
		document.getElementById(id).style.visibility = "visible";
		findObj('bgcolor').value = id;
		writedata()
		
	}

function hideall() {
		if (ns4)
		{
			document.layers['whitebackgroundDiv'].visibility = "hidden";
			document.layers['blackbackgroundDiv'].visibility = "hidden";
			document.layers['redbackgroundDiv'].visibility = "hidden";
			document.layers['bluebackgroundDiv'].visibility = "hidden";
			document.layers['orangebackgroundDiv'].visibility = "hidden";
			document.layers['greenbackgroundDiv'].visibility = "hidden";
			document.layers['yellowbackgroundDiv'].visibility = "hidden";
			document.layers['purplebackgroundDiv'].visibility = "hidden";
			document.layers['pinkbackgroundDiv'].visibility = "hidden";
		}
		else if (ns6)
		{
			document.getElementById('whitebackgroundDiv').style.visibility = "hidden";
			document.getElementById('blackbackgroundDiv').style.visibility = "hidden";
			document.getElementById('redbackgroundDiv').style.visibility = "hidden";
			document.getElementById('bluebackgroundDiv').style.visibility = "hidden";
			document.getElementById('orangebackgroundDiv').style.visibility = "hidden";
			document.getElementById('greenbackgroundDiv').style.visibility = "hidden";
			document.getElementById('yellowbackgroundDiv').style.visibility = "hidden";
			document.getElementById('purplebackgroundDiv').style.visibility = "hidden";
			document.getElementById('pinkbackgroundDiv').style.visibility = "hidden";
		}
		else if (ie4)
		{
			document.all['whitebackgroundDiv'].visibility = "hidden";
			document.all['blackbackgroundDiv'].visibility = "hidden";
			document.all['redbackgroundDiv'].visibility = "hidden";
			document.all['bluebackgroundDiv'].visibility = "hidden";
			document.all['orangebackgroundDiv'].visibility = "hidden";
			document.all['greenbackgroundDiv'].visibility = "hidden";
			document.all['yellowbackgroundDiv'].visibility = "hidden";
			document.all['purplebackgroundDiv'].visibility = "hidden";
			document.all['pinkbackgroundDiv'].visibility = "hidden";			
		}
		writedata()
	}			
	
var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function findObj(n, d) {
  var p,i,x;  if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=findObj(n,d.layers[i].document); return x;
}

function changeCol(col)
{
	if (!DHTML) return;
	var a = new getObj('text');
	a.style.color = col;
	findObj('textcolor').value = col;
}


function changeFamily(family)
{
	if (!DHTML) return;
	var b = new getObj('text');
	b.style.fontFamily = family;
	findObj('textfamily').value = family;
}

function changeStyle(style)
{
	if (!DHTML) return;
	var c = new getObj('text');
	c.style.fontStyle = style;
	findObj('textstyle').value = style;
}

function changeWeight(weight)
{
	if (!DHTML) return;
	var d = new getObj('text');
	d.style.fontWeight = weight;
	findObj('textweight').value = weight;
}

function changeSize(size)
{
	if (!DHTML) return;
	var e = new getObj('text');
	e.style.fontSize = size;
	findObj('textsize').value = size;
}

function contstop()
{
clearTimeout(t);
writedata();
}

var texttop = 206;
var cliparttop = 200
var clipartleft = 200
function moveud(amount)
{
	if (!DHTML) return;
	var f = new getObj('text');
	texttop += amount;
	f.style.top = texttop;
	findObj('textpos1').value = texttop;
}
var currdisplay = 'photo'
var t
var textleft = 463;
function movelr(amount)
{
	if (!DHTML) return;
	var g = new getObj('text');
	textleft += amount;
	g.style.left = textleft;
	findObj('textpos2').value = textleft;
}	

var phototop = 130;
function pmoveud(amount,movingon)
{
	if (!DHTML) return;
	var h = new getObj(currdisplay);

	if(currdisplay=='photo')
		{
		findObj('photopos2').value = phototop;
		phototop += amount;
		h.style.top = phototop;
		
		}
	else if(currdisplay=='text')
		{
		findObj('textpos2').value = texttop;
		texttop += amount;
		h.style.top = texttop;		
		}
	else if(currdisplay=='clipart')
		{
		findObj('clipartpos2').value = cliparttop;
		cliparttop += amount;
		h.style.top = cliparttop;
		}
	if(movingon=='yes')
		{
		if(amount==-1)
			{
			t=setTimeout("pmoveud(-1,'yes')",50);
			}
		else
			{
			t=setTimeout("pmoveud(1,'yes')",50);
			}
		}
}

var photoleft = 440;
function pmovelr(amount,movingon)
{
	if (!DHTML) return;
	var i = new getObj(currdisplay);

	if(currdisplay=='photo')
		{
		findObj('photopos1').value = photoleft;
		photoleft += amount;
		i.style.left = photoleft;
		
		}
	else if(currdisplay=='text')
		{
		findObj('textpos1').value = textleft;
		textleft += amount;
		i.style.left = textleft;		
		}
	else if(currdisplay=='clipart')
		{
		findObj('clipartpos1').value = clipartleft;
		clipartleft += amount;
		i.style.left = clipartleft;		
		}	
	if(movingon=='yes')
		{
		if(amount==-1)
			{
			t=setTimeout("pmovelr(-1,'yes')",50);
			}
		else
			{
			t=setTimeout("pmovelr(1,'yes')",50);
			}	
		}
}	

function invi(flag)
{
	if (!DHTML) return;
	var j = new getObj('photo');
	j.style.visibility = (flag) ? 'hidden' : 'visible'
	findObj('photoonoff').value = (flag) ? 'hidden' : 'visible';
}

function invimask(flag)
{
	if (!DHTML) return;
	var k = new getObj('photomask');
	k.style.visibility = (flag) ? 'hidden' : 'visible'
	findObj('maskonoff').value = (flag) ? 'hidden' : 'visible';
}	

function changeusertext(){
   uploadedtext = document.usertextform.usertext.value
   text.innerHTML = uploadedtext;
	 findObj('mytext').value = uploadedtext;
}

function invisantamask(flag)
{
	if (!DHTML) return;
	var k = new getObj('santamask');
	k.style.visibility = (flag) ? 'hidden' : 'visible'
	findObj('santamaskonoff').value = (flag) ? 'hidden' : 'visible';
}


function GetXmlHttpObject(handler)
	{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
		{
		objXMLHttp=new XMLHttpRequest()
		}
	else if (window.ActiveXObject)
		{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
	return objXMLHttp
	}
	
function stateChanged() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
		if (xmlHttp.status == 200) 
		
			{	
			imagesrc = xmlHttp.responseText;
			//alert(imagesrc)
			if(imagesrc != '')
				{
				 //document.getElementById('text').innerHTML = '<img src="art/dyo/badges/green.gif" width="156" height="156" alt="Your Design">'
				//alert(imagesrc)
				document.getElementById('text').innerHTML =  imagesrc
				}
			}
			
			
		}
	} 
	
function writedata()
	{
	//alert(allowwritedata)
	//alert(phototop)
	if(allowwritedata)
	{
	
		xmlHttp=GetXmlHttpObject()
		
		if (xmlHttp==null)
			{
			alert ("Browser does not support HTTP Request")
			return
			} 
		//alert("hi")	
		var postparams = 'dyoID=' + document.getElementById("dyoID").value + '&maskchoice=' + document.getElementById("maskchoice").value + '&textimage=' + document.getElementById("textimage").value + '&cliparttop=' + cliparttop + '&clipartleft=' + clipartleft + '&texttop=' + texttop + '&textleft=' + textleft + '&phototop=' + phototop + '&photoleft=' + photoleft + '&bgcolor=' + document.getElementById("backgroundcolor").value + '&backgroundsize=' + document.getElementById("backgroundSliderValue").value  + '&thecolour=' + document.getElementById("textcolour").value + '&thefont=' + document.getElementById("thefont").value + '&thetextsize=' + document.getElementById("textSliderValue").value + '&thetext=' + document.getElementById("usertext").value.replace(new RegExp( "\\n", "g" ), "vbcrlf" ) + '&thefilename=' + document.getElementById("filename").value + '&clipartchoice=' + document.getElementById("clipartchoice").value + '&clipartsize=' + document.getElementById("clipartSliderValue").value + '&sID=' + Math.random()
		var url="writedata.asp?" + postparams
		//alert(url)
		xmlHttp.onreadystatechange=stateChanged 
		xmlHttp.open("POST",url,true)
		xmlHttp.send("bee=true")		
	}
	}
 

function writeimage()
	{
	//alert(document.getElementById("usertext").value)
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		} 
	var postparams = 'fontrotation=' + document.textupload.textcurvevalue.value + '&dyoID=' + document.getElementById("dyoID").value + '&bgcolor=' + document.getElementById("backgroundcolor").value + '&thecolour=' + document.getElementById("textcolour").value + '&thefont=' + document.getElementById("thefont").value + '&thetextsize=' + document.getElementById("textSliderValue").value + '&thetext=' + document.getElementById("usertext").value.replace(new RegExp( "\\n", "g" ), "vbcrlf" ) + '&thefilename=' + document.getElementById("filename").value + '&sID=' + Math.random()
	//alert(postparams)
	//postparams="hghgf"
	var url="writeimage.asp?" + postparams
	//alert(url)
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("POST",url,true)
	xmlHttp.send("bee=true")	
		

	}