var one =   1; 
var two =   2; 
var three = 3; 
var four =  4;
function swap_img(img_one,img_two) {
document.images[img_one].src = img_two;
}
function rotate() {
	four = bitshift(four,-1);
	one = bitshift(one,-1);
	two = bitshift(two,-1);
	three = bitshift(three,-1);
	return true;
}
function exchange() {
	var xchng = three;
	three = four;
	four = xchng;
	return true;
}
function bitshift(zen,xan)
{
	zen = zen - xan;
	if(zen < 1) 
		zen = zen + 4;
	if(zen > 4)
	    zen = zen - 4;
	return zen;
}
function getImgSize(imgSrc)
{


	var newImg = new Image();
	newImg.src = imgSrc;
	var img_height = newImg.height;
	var img_width = newImg.width;
	var scr_width = screen.width;
	var scr_height = screen.height;
	var img_max = "";
	var scr_max = "";
	if (img_width > img_height) {
		img_max = "img_width";
	} else {
		img_max = "img_height";
	}
	if (scr_width > scr_height) {
		scr_max = "scr_width";
	} else {
		scr_max = "scr_height";
	}
	
	var total_max;
	if (img_max == "img_width" && scr_max == "scr_width") {
		rotate();
	}
	if (img_max == "img_width" && scr_max == "scr_height") {
		rotate();
		exchange();
	}
	if (img_max == "img_height" && scr_max == "scr_width") {
		rotate();
		rotate();
	}
	if (img_max == "img_height" && scr_max == "scr_height") {
		rotate();
		rotate();
		exchange();
	}
	var result = ((one * 1000) + (two * 100) + (three * 10) + (four * 1));
	switch(result) {
	case 2341:
	// scr_width && img_width max
	case 2314:
	// scr_height && img_width max
	var width = newImg.width / screen.width;
	width = newImg.width / width;
	document.images["demoImg"].width = width;
	break;
	case 3412:
	// scr_width && img_height max
	case 3421:
	// scr_height && img_height max
	var height = newImg.height / screen.height;
	height = newImg.height / height;
	document.images["demoImg"].height = height;
	break;
	case 0:
		alert("This should never happen!");
	break;
	}
}

//alert((one * 1000) + (two * 100) + (three * 10) + (four * 1));

