
function goxml()
{
	var xmlDoc;
	var xslStylesheet;
	var resultDocument;
	if (window.ActiveXObject) {
		
		attributesfile = document.getElementById('theAfile').value;

		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load(attributesfile);

		xslStylesheet = new ActiveXObject("Microsoft.XMLDOM");
		xslStylesheet.async=false;
		xslStylesheet.load("syi_attributes_ie.xsl");

		resultDocument = new ActiveXObject("Microsoft.XMLDOM");
		resultDocument.async = false;
		
		var stillscripts = true;
		
		var ex = xmlDoc.transformNode(xslStylesheet);
		ex = ex.replace(/\<\!\-\-/g,"");
		ex = ex.replace(/\/\/\-\-\>/g,"");
		somthin = /..*/;
		var numofscripts = 0;
		var allthescripts = [];
		while (stillscripts) {
			var bos = ex.indexOf("<script");
			if (bos != -1) {
				var eos = ex.indexOf("<\/script>");
				eos += 9;
				var thescript = ex.substring(bos, eos);
				allthescripts[numofscripts] = thescript;
				numofscripts++;
				firsthalf = ex.substring(0, bos);
				secondhalf = ex.substring(eos);
				if (somthin.test(firsthalf)) {
					if (somthin.test(secondhalf)) {
						ex = firsthalf + secondhalf;
					}
					else {
						ex = firsthalf;	
					}
				}
				else {
					ex = secondhalf;
				}
			}
			else {
				stillscripts = false;
			}
			
		}
		
		document.getElementById('thediv').innerHTML = ex;
		var newjs;
		
		for(i=0;i<numofscripts;i++) {
		
				newjs = document.createElement( "script" );
				newjs.type='text/javascript';
				var output = allthescripts[i]; 
				output = output.replace(/\<script..*\>/g,"");
				output = output.replace(/\<\/script\>/g,"");
				newjs.text = output;
				document.getElementsByTagName('head')[0].appendChild(newjs);
		}

	}
	else if (document.implementation && document.implementation.createDocument)
  	{
		var xsltProcessor=new XSLTProcessor();

		var myXSLHTTPRequest = new XMLHttpRequest();
		myXSLHTTPRequest.open("GET", "syi_attributes_firefox.xsl", false);
		myXSLHTTPRequest.send(null);
		xslStylesheet = myXSLHTTPRequest.responseXML;

		xsltProcessor.importStylesheet(xslStylesheet);

		attributesfile = document.getElementById('theAfile').value;

		myXMLHTTPRequest = new XMLHttpRequest();
		myXMLHTTPRequest.open("GET", attributesfile, false);
		myXMLHTTPRequest.send(null);
		xmlDoc = myXMLHTTPRequest.responseXML;

		resultDocument = xsltProcessor.transformToFragment(xmlDoc,document); 
	
		var serializer = new XMLSerializer(); 
		var foundit = true;
	
		for(h=0;h<resultDocument.childNodes.length;h++) {
			if (resultDocument.childNodes[h].nodeName == "NOSCRIPT") {
				//alert(resultDocument.childNodes[h].nodeName + ": " + resultDocument.childNodes[h].innerHTML);
				document.getElementById('thediv').appendChild(resultDocument.childNodes[h]);
			}
		}

		while (foundit) {
			for(h=0;h<resultDocument.childNodes.length;h++) {
				if (resultDocument.childNodes[h].nodeName != "SCRIPT") {
					//alert(resultDocument.childNodes[h].nodeName + ": " + resultDocument.childNodes[h].innerHTML);

					document.getElementById('thediv').appendChild(resultDocument.childNodes[h]);
					foundit = true;
					break;
				}
				else {
					foundit = false;	
				}
			}
			if (resultDocument.childNodes.length <= 0) {
				foundit = false;
			}
		}
		for(h=0;h<resultDocument.childNodes.length;h++) {
			if (resultDocument.childNodes[h].nodeName == "SCRIPT") {
					//alert(resultDocument.childNodes[h].nodeName);

					var newjs;
					newjs= document.createElement( "script" );
					newjs.type='text/javascript';
				
					var output = XMLSerializer().serializeToString(resultDocument.childNodes[h].childNodes[0]);
			//alert(output);
					output = output.replace(/\<\!\-\-/g,"");
					output = output.replace(/\/\/\-\-\>/g,"");

					newjs.text = output;
					document.getElementsByTagName('head')[0].appendChild(newjs);
			}
		}

  	}
	else
  	{
  		alert('Your browser cannot handle this script');
  	}

}


function MakeDollar(Number,Decimals,Separator) {

 Number += "";
 Decimals += "";
 Separator += "";
 if((Separator == "") || (Separator.length > 1))  Separator = ".";
 if(Number.length == 0)  Number = "0";
 var OriginalNumber = Number;  
var Sign = 1;
 var Pad = "";
var Count = 0; 
 if(parseFloat(Number)){  Number = parseFloat(Number)} else {  Number = 0; }

 if((parseInt(Decimals,10)) || (parseInt(Decimals,10) == 0)){
  Decimals = parseInt(Decimals,10); 
} else {  
Decimals = 2;
}
 if(Number < 0) {
  Sign = -1;        
  Number *= Sign;    
} if(Decimals < 0)
  Decimals *= -1;


 Number = "" + Math.floor(Number * Math.pow(10,Decimals + 1) + 5);
 if((Number.substring(1,2) == '.')||((Number + '')=='NaN')) {
return(OriginalNumber); 
} 
 if(Number.length < Decimals +1) {
  for(Count = Number.length; Count <= Decimals; Count++) {   
	Pad += "0"; 
	}
}
 Number = Pad + Number; 
 if(Decimals == 0){

  Number = Number.substring(0, Number.length -1);
} else {

 Number = Number.substring(0,Number.length - Decimals -1) +          
		  Separator +
          Number.substring(Number.length - Decimals -1,Number.length -1);
} 
if(Sign == -1)
{
  Number = "-" + Number; 
} 
if(Number.length == 0)
{
  Number="0";
}
 return(Number)
}

function tracker () {

	somthin = /null/;
	var tracknumber = '';
	tracknumber = getCookie('ARTOPIUM:12345:TRACKER:67890');
	if (somthin.test(tracknumber)) {
		var rand = Math.round(10000000*Math.random());
		var rand2 = Math.round(10000*Math.random());
		var id = rand + rand2;
		createCookie("ARTOPIUM:12345:TRACKER:67890", id, 1);
		var userid = document.statform.UserID.value;
		var productid = document.statform.ProductID.value; 
		document.all.statimage.src = 'http://www.artopium.com/space20/newhit.cgi?Action=Start&UserID=' + userid + '&ProductID=' + productid;
	}
	else {
			alert('made it ' + tracknumber);
			eraseCookie('ARTOPIUM:12345:TRACKER:67890');
	}

}

function disable () {
	if (MMDiv.style.visibility == "hidden")
	{
		MMDiv.style.visibility='visible';
		MMDiv2.style.visibility='hidden';
	}
	else
	{
		MMDiv.style.visibility='hidden';
		MMDiv2.style.visibility='visible';
	}
}

var paypalname = "";

function checkavailability () {

	var email = document.mainform.Email.value;
	var dname = document.mainform.User_Name.value;
	var checkurl = 'http://www.artopium.com/space20/checkavailability.cgi?DisplayName=' + dname + '&Email=' + email;
	OpenWindow('CheckWindow', checkurl,'200','200');
	return false;
}


function initpaypalname () {
	paypalname = document.fashionform.paypaltitlename.value;
	
}
function updatepaypal () {

	if (document.fashionform) {
		paypalname = document.fashionform.paypaltitlename.value;
		t = document.fashionform.colors.options.length;
		if (t > 1) {
			for (p=0; p<t; p++) {
				if(document.fashionform.colors.options[p].selected) {
					color = document.fashionform.colors.options[p].text;
				}
			}
		}
		else {
			color = document.fashionform.colors.options[0].text;
		}
		t = document.fashionform.sizes.options.length;
		if (t > 1) {
			for (p=0; p<t; p++) {
				if(document.fashionform.sizes.options[p].selected) {
					size = document.fashionform.sizes.options[p].text;
				}
			}
		}
		else {
			size = document.fashionform.sizes.options[0].text;
		}
		var newtitle = paypalname + " Color: " + color + " Size: " + size;
		document.paypalform1.item_name.value = newtitle;

	}
	if (document.trackingoptionform1) {

		
		if (document.trackingoptionform1.tracking1.checked) {
			var basev = document.trackingoptionform1.basevalue1.value * 1;
			var trackc = document.trackingoptionform1.trackingcost1.value * 1;
			var newtotal = basev + trackc;
			newtotal = MakeDollar(newtotal);
			document.paypalform1.amount.value =  newtotal;
			document.paypalform1.os0.value = 'Online tracking number requested, $' + document.trackingoptionform1.trackingcost1.value;
			document.getElementById('pricetag1').innerHTML = '$' + document.trackingoptionform1.basevalue1.value + '<br> \+ $' + document.trackingoptionform1.trackingcost1.value + '<hr>$' + newtotal;
		}
		else {
			document.paypalform1.amount.value = document.trackingoptionform1.basevalue1.value;
			document.paypalform1.os0.value = '';
			document.getElementById('pricetag1').innerHTML = '$' + document.trackingoptionform1.basevalue1.value;
		}

	}
	if (document.trackingoptionform2) {

		if (document.trackingoptionform2.tracking2.checked) {
			var basev = document.trackingoptionform2.basevalue2.value * 1;
			var trackc = document.trackingoptionform2.trackingcost2.value * 1;
			var newtotal = basev + trackc;
			newtotal = MakeDollar(newtotal);
			document.paypalform2.amount.value =  newtotal;
			document.paypalform2.os0.value = 'Online tracking number requested, $' + document.trackingoptionform2.trackingcost2.value;
			document.getElementById('pricetag2').innerHTML = '$' + document.trackingoptionform2.basevalue2.value + '<br> \+ $' + document.trackingoptionform2.trackingcost2.value + '<hr>$' + newtotal;
		}
		else {
			document.paypalform2.amount.value = document.trackingoptionform2.basevalue2.value;
			document.paypalform2.os0.value = '';
			document.getElementById('pricetag2').innerHTML = '$' + document.trackingoptionform2.basevalue2.value;
		}

	}
	

}


function go(url, windowname3) {
opener.location.href = url;
window.close(windowname3);
} 


function startprinting () {
	var myinterval = window.setInterval('printcomment()',200);
}

splitwords = /\s\s*/;
function printcomment () {

	var words=document.mainform.Comment.value.split(splitwords);
	var numofwords = words.length * 5;
	if (numofwords > 1000) {
		numofwords = 1000;
	}
	document.all.baserating.innerHTML = '<br><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Base Rating: <font color="#FF0000"> ' + numofwords + ' </font></strong></font>';
	document.all.Comment.innerHTML = document.mainform.Comment.value;
}

dafile3 = '';

function validateform () {

//document.mainform.submitbutton.disabled = true;

emailyone = /...*\@..*\..../;
emailytwo = /\@\@\@*/;
something = /......*/;
spaces = /\s\s*/;
words = /^\w\w*\s*\w*\s*\w*\s*\w*\s*\w*\s*\w*\s*\w*\s*\w*\s*\w*$/;
afile = /..*\....$/;
capsnspaces = /[A-Z\s][A-Z\s]*/;


if (document.mainform.Email.value == "") { 
	alert('Please enter an email address.'); 
	return false;
}
else if (document.mainform.Email2.value == "") { 
	alert('Please re-enter your email in the second Email box for verification.'); 
	return false;
}
else if (!(emailyone.test(document.mainform.Email.value)))  {
	alert('Please make sure that your email address is spelled correctly.'); 
	return false;
}
else if (emailytwo.test(document.mainform.Email.value))  {
	alert('Please make sure that your email address is spelled correctly. You may have entered the @ sign twice.'); 
	return false;
}
else if (document.mainform.Email.value != document.mainform.Email2.value)  {
	alert('The email addresses you have entered do not match. Please re-verify your email addresses.'); 
	return false;
}
else if (document.mainform.User_Name.value == "") { 
	alert('Please enter a Display Name.'); 
	return false;
}
else if (capsnspaces.test(document.mainform.User_Name.value)) { 
	alert('You may not use capital letters or spaces in your Display Name. Please correct your Display Name and try again.'); 
	return false;
}
else if (document.mainform.Password.value == "") { 
	alert('Please enter a password.'); 
	return false;
}
else if (document.mainform.Password2.value == "") { 
	alert('Please re-enter your password in the "Password Verify" box.'); 
	return false;
}
else if (document.mainform.Password2.value != document.mainform.Password.value) { 
	alert('Please make sure that both the passwords you have entered match eachother exactly.'); 
	return false;
}
else if (document.mainform.First_Name.value == "") { 
	alert('Please enter a First Name.'); 
	return false;
}
else if (document.mainform.Last_Name.value == "") { 
	alert('Please enter a Last Name.'); 
	return false;
}
else if (document.mainform.Address_1.value == "") { 
	alert('Please enter an Address.'); 
	return false;
}
else if (document.mainform.City.value == "") { 
	alert('Please enter a City.'); 
	return false;
}
else if (document.mainform.Zip_Code.value == "") { 
	alert('Please enter a Zip Code.'); 
	return false;
}
else if (document.mainform.Page_Title.value == "") { 
	alert('Please enter a Page Title.'); 
	return false;
}
else if (!(document.mainform.agree.checked)) {
	alert('You must agree to the Terms and Conditions to be an Artopium member.'); 
	return false;
}
else {
	return true;
}
}

function clearkeywords () {
    document.myForm.keywords.value = "";
}







function uploadwin(visfactor) {

ns = (document.layers)? true:false;
ie = (document.all)? true:false;
if (ns) {
	alert('This function is only supported in browsers capable of advanced DHTML scripting. We suggest you use Internet Explorer 4.0 or higher. Thank you.');
	return false;
}
else {
		upurl = 'http://www.artopium.com/space/upload.cgi?action=start&vis=' + visfactor;
		OpenWindow('UploadWindow',upurl,'450','400','scrollbars=yes');
		return false;
}
}




function subscribeto() {
emailyone = /...*\@..*\..../;
emailytwo = /\@\@\@*/;

if (subform.email.value == "") { 
	alert('Please enter an email address.'); 
	return false;
}
else if (!(emailyone.test(subform.email.value)))  {
	alert('Please make sure that your email address is spelled correctly.'); 
	return false;
}
else if (emailytwo.test(subform.email.value))  {
	alert('Please make sure that your email address is spelled correctly. You may have entered the @ sign twice.'); 
	return false;
}



alert('Thank you, ' + subform.name.value + ', for subscribing to Artopium\'s newsletter. There should be a welcome message in your inbox now.');
document.images['fakester'].src = 'http://www.artopium.com/space20/subscribe.cgi?Name=' + subform.name.value + '&Email=' + subform.email.value + '&Newsletter=' + subform.newsletter.value;
event.returnValue=false;
alert(document.images['fakester'].src);
}

var expdate = new Date();
expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365));

function createCookie(name, value, days)
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie (name) {
var dcookie = document.cookie; 
var cname = name + "=";
var clen = dcookie.length;
var cbegin = 0;
        while (cbegin < clen) {
        var vbegin = cbegin + cname.length;
                if (dcookie.substring(cbegin, vbegin) == cname) { 
                var vend = dcookie.indexOf (";", vbegin);
                        if (vend == -1) vend = clen;
                return unescape(dcookie.substring(vbegin, vend));
                }
        cbegin = dcookie.indexOf(" ", cbegin) + 1;
                if (cbegin == 0) break;
        }
return null;
}

function eraseCookie(name)
{
  createCookie(name, "", -1);
}

function OpenWindow(windowname2, poplocation2, width2, height2) {

var winl = (screen.width - width2) / 2;
var wint = (screen.height - height2) / 2;

settings=
"toolbar=no,location=no,directories=no,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width=" + width2 + 
",height=" + height2 + 
",top=" + wint + ",left=" + winl;

NewWindow = window.open("",windowname2,settings);
NewWindow.location.href = poplocation2;


if (NewWindow.opener == null) NewWindow.opener = window;

}
