var min = 10;
var max = 28;
var maxtemp = 0;
var mintemp = 0;
var maxvalreached = false;
var minvalreached = false;

function scaletext(direction) {

	var myelems = document.getElementsByClassName('scalable');
	
	for(ii = 0; ii < myelems.length; ii++) {
		
		if(myelems[ii].style.fontSize) {
			var s = parseInt(myelems[ii].style.fontSize.replace("px",""));
		} else {
			var s = 12;
		}
		
		if (direction == "increase" && s < max && maxvalreached == false) {
			s += 2;
			minvalreached = false;
			document.getElementById('decrease_font').src = "http://media.lightwaveonline.com/designimages/decrease_font_size_LW.gif";
			mintemp = 0;
		} else if (direction == "decrease" && s > min && minvalreached == false) {
			s -= 2;
			maxvalreached = false;
			document.getElementById('increase_font').src = "http://media.lightwaveonline.com/designimages/increase_font_size_LW.gif";
			maxtemp = 0;
		}
		
		myelems[ii].style.fontSize = s + "px";
		
		if (s >= max)
			maxtemp = 1;
		else if (s <= min)
			mintemp = 1;
		
	}
	
	if (maxtemp == 1) {
		maxvalreached = true;
		document.getElementById('increase_font').src = "http://media.lightwaveonline.com/designimages/increase_font_size_grey_LW.gif";
	} else if (mintemp == 1) {
		minvalreached = true;
		document.getElementById('decrease_font').src = "http://media.lightwaveonline.com/designimages/decrease_font_size_grey_LW.gif";
	}
}

function openwin(imgsrc,x,y) {
			    
	maxwidth=800;
	maxheight=600;
	
	//window.open("images/" + imgsrc,"width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
	if ((x > maxwidth) && (y > maxheight)) {
    	y = y + 34;
		xsizepercent = maxwidth / x;
		ysizepercent = maxheight / y;
		if (xsizepercent > ysizepercent) {
			x = x * xsizepercent;
			y = y * xsizepercent;
			window.open("images/" + imgsrc,"width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
		}
		else {
			x = x * ysizepercent;
			y = y * ysizepercent;
			window.open("images/" + imgsrc,"width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
		}
	}
	else if (x > maxwidth) {
		y = y + 34;
		sizepercent = maxwidth / x;
		x = x * sizepercent;
		y = y * sizepercent;
       	window.open("images/" + imgsrc,"width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
    }
	else if (y > maxheight) {
		y = y + 34;
		sizepercent = maxheight / y;
		x = x * sizepercent;
		y = y * sizepercent;
        window.open("images/" + imgsrc,"width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
    }
	else {
		y = y + 34;
 		window.open("images/" + imgsrc,"width=" + x + ",height=" + y + ",scrollbars=no,titlebar=no");
    }
}

function openwin2(imgsrc,x,y) {
			    
	// maxwidth=800;
	// maxheight=600;
	myWin = window.open(imgsrc,"_blank","width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=no");
	/*
	if ((x > maxwidth) && (y > maxheight)) {
    	y = y + 34;
		xsizepercent = maxwidth / x;
		ysizepercent = maxheight / y;
		if (xsizepercent > ysizepercent) {
			x = x * xsizepercent;
			y = y * xsizepercent;
			window.open(imgsrc,"width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
		}
		else {
			x = x * ysizepercent;
			y = y * ysizepercent;
			window.open(imgsrc,"width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
		}
	}
	else if (x > maxwidth) {
		y = y + 34;
		sizepercent = maxwidth / x;
		x = x * sizepercent;
		y = y * sizepercent;
       	window.open(imgsrc,"width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
    }
	else if (y > maxheight) {
		y = y + 34;
		sizepercent = maxheight / y;
		x = x * sizepercent;
		y = y * sizepercent;
        window.open(imgsrc,"width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
    }
	else {
		y = y + 34;
 		window.open(imgsrc,"width=" + x + ",height=" + y + ",scrollbars=no,titlebar=no");
    }
	*/
}

function OpenLargeWindow(imgsrc,x,y,brand) {
			    
	maxwidth=800;
	maxheight=600;
	
	// window.open("http://images.pennnet.com/articles/lw/cap/cap_" + imgsrc + ".jpg","width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
	if ((x > maxwidth) && (y > maxheight)) {
    	y = y + 34;
		xsizepercent = maxwidth / x;
		ysizepercent = maxheight / y;
		if (xsizepercent > ysizepercent) {
			x = x * xsizepercent;
			y = y * xsizepercent;
			window.open("http://images.pennnet.com/articles/lw/cap/cap_" + imgsrc + ".jpg","width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
		}
		else {
			x = x * ysizepercent;
			y = y * ysizepercent;
			window.open("http://images.pennnet.com/articles/lw/cap/cap_" + imgsrc + ".jpg","width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
		}
	}
	else if (x > maxwidth) {
		y = y + 34;
		sizepercent = maxwidth / x;
		x = x * sizepercent;
		y = y * sizepercent;
       	window.open("http://images.pennnet.com/articles/lw/cap/cap_" + imgsrc + ".jpg","width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
    }
	else if (y > maxheight) {
		y = y + 34;
		sizepercent = maxheight / y;
		x = x * sizepercent;
		y = y * sizepercent;
        window.open("http://images.pennnet.com/articles/lw/cap/cap_" + imgsrc + ".jpg","width=" + x + ",height=" + y + ",resizable=yes,status=no,scrollbars=yes,titlebar=0");
    }
	else {
		y = y + 34;
 		window.open("http://images.pennnet.com/articles/lw/cap/cap_" + imgsrc + ".jpg","width=" + x + ",height=" + y + ",scrollbars=no,titlebar=no");
    }
}

