/*<![CDATA[*/

function updateOrientation()
{
	/*window.orientation returns a value that indicates whether iPhone is in portrait mode, landscape mode with the screen turned to the
	  left, or landscape mode with the screen turned to the right. */
	var orientation=window.orientation;
	var wrapper = document.getElementById("wrapper");
	var imgsArr = document.getElementsByTagName("img");
	var i = 0;
	var id = 0;
	
	//alert(orientation);
	
	switch(orientation)
	{
	
		case undefined:
				/* If in portrait mode, sets the body's class attribute to portrait. Consequently, all style definitions matching the body[class="portrait"] declaration
				   in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */
				
				for (i = 0; i < imgsArr.length; i++) {
               id = parseInt(imgsArr[i].id.substr(3));
               imgsArr[i].style.width = img_sizes_300[id].w+"px";
               imgsArr[i].style.height = img_sizes_300[id].h+"px";
             //  alert(imgsArr[i].src);
            }
				
				/* Add a descriptive message on "Handling iPhone or iPod touch Orientation Events"  */
				//document.getElementById("currentOrientation").innerHTML="Now in portrait orientation (Home button on the bottom).";
				break;
				
		case 0:
				/* If in portrait mode, sets the body's class attribute to portrait. Consequently, all style definitions matching the body[class="portrait"] declaration
				   in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */
				
				for (i = 0; i < imgsArr.length; i++) {
               id = parseInt(imgsArr[i].id.substr(3));
               imgsArr[i].style.width = img_sizes_300[id].w+"px";
               imgsArr[i].style.height = img_sizes_300[id].h+"px";
             //  alert(imgsArr[i].src);
            }
				
				/* Add a descriptive message on "Handling iPhone or iPod touch Orientation Events"  */
				//document.getElementById("currentOrientation").innerHTML="Now in portrait orientation (Home button on the bottom).";
				break;				
				
		case 90:
				/* If in landscape mode with the screen turned to the left, sets the body's class attribute to landscapeLeft. In this case, all style definitions matching the
				   body[class="landscapeLeft"] declaration in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */
				
				for (i = 0; i < imgsArr.length; i++) {
               id = parseInt(imgsArr[i].id.substr(3));
               imgsArr[i].style.width = img_sizes_460[id].w+"px";
               imgsArr[i].style.height = img_sizes_460[id].h+"px";
            //   alert(imgsArr[i].src);
            }
				
				//document.getElementById("currentOrientation").innerHTML="Now in landscape orientation and turned to the left (Home button to the right).";
				break;
				
		case -90:
				/* If in landscape mode with the screen turned to the left, sets the body's class attribute to landscapeLeft. In this case, all style definitions matching the
				   body[class="landscapeLeft"] declaration in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */
				
				for (i = 0; i < imgsArr.length; i++) {
               id = parseInt(imgsArr[i].id.substr(3));
               imgsArr[i].style.width = img_sizes_460[id].w+"px";
               imgsArr[i].style.height = img_sizes_460[id].h+"px";
           //    alert(imgsArr[i].src);
            }
				
				//document.getElementById("currentOrientation").innerHTML="Now in landscape orientation and turned to the left (Home button to the right).";
				break;
				
				
	}
	


}

// Point to the updateOrientation function when iPhone switches between portrait and landscape modes.
window.onorientationchange = updateOrientation;
//window.onload = updateOrientation;

//alert(window.orientation);

/*]]>*/
