lg_name = "nothing";

mustInitImg = true;
function initImgID() {
di = document.images;
if (mustInitImg && di) {
for (var i=0; i<di.length; i++) {
if (!di[i].id) 
di[i].id=di[i].name; 
} 
mustInitImg = false;
}
}

function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

function changeImages() {
	d = document;
	if (d.images) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			if (d.layers) {
				img = findElement(changeImages.arguments[i],0);
			}
			else {
				img = d.images[changeImages.arguments[i]];}
			if (img) {
				img.src = changeImages.arguments[i+1];
			}
		}
	}
}
function changeRolls() {
	d = document;
	if (d.images) {
		var img;
		for (var i=0; i<changeRolls.arguments.length; i+=2) {
			img = null;
			if (d.layers) {
				img = findElement(changeRolls.arguments[i],0);
			}
			else {
				img = d.images[changeRolls.arguments[i]];}
			if (img) {
				img.src = changeRolls.arguments[i+1];
				lg_name = changeRolls.arguments[i+1];
			}
		}
	}
}


function findElement(n,ly) {
d = document;
if (browserVers < 4)
return d[n];
if ((browserVers >= 6) && (d.getElementById)) {
initImgID; 
return(d.getElementById(n))
}; 
var cd = ly ? ly.document : d;
var elem = cd[n];
if (!elem) {
for (var i=0;i<cd.layers.length;i++) {
elem = findElement(n,cd.layers[i]);
if (elem) return elem;
}
}
return elem;
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=450,height=350,left = 200,top = 200');");
}
function popUp2() {
	lg_name = lg_name.replace("md","lg");
	
	if(lg_name=="nothing") // If user hasn't rolled over anything, assign to first pic.
		lg_name = "images/products/"+image1+"lg.jpg";
		
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('prodlarge.php?pic=' + lg_name, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=460,left = 100,top = 100');");
}
function popUp2a() {
	lg_name = lg_name.replace("md","lg");
	
	if(lg_name=="nothing") // If user hasn't rolled over anything, assign to first pic.
		lg_name = "images/products/"+image1+"lg.jpg";
		
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('prodlarge.php?pic=' + lg_name, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=460,height=460,left = 100,top = 100');");
}

function popUp3(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=430,height=520,left = 100,top = 100');");
}

function popUp4(URL) {
	URL = URL.replace(".jpg","_lg.jpg");
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('colorbarpop.php?pic=' + URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=320,left = 100,top = 100');");
}
function popUp5(sendprod) {
	var address = "www.cascobaywoolworks.com/product.php?prod_id=" +sendprod;
	day = new Date();
	aa = day.getTime();
	eval("page" + aa + " = window.open('emailfriend.php?link='+address, '" + aa + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=320,left = 50,top = 50');");
}
function popUpProd(image) {
	lg_name = "images/products/"+image+"lg.jpg";
	
	//if(lg_name=="nothing") // If user hasn't rolled over anything, assign to first pic.
	//	lg_name = "images/products/"+image1+"lg.jpg";
		
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('prodlarge.php?pic=' + lg_name, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=460,left = 100,top = 100');");
}
// prevent dup submit
counter1 = 0;
function monitor() {
	counter1++;
	if(counter1 > 1) { return false; }
	return true;
}
function popUp6() {
	day = new Date();
	aa = day.getTime();
	eval("page" + aa + " = window.open('immediateship.php', '" + aa + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=370,height=450,left = 50,top = 50');");
}
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}