function submitform(formname){
if (document.forms[formname]) {
  document.forms[formname].submit();
}
}


function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
 // window.alert( 'Width = ' + myWidth );
 // window.alert( 'Height = ' + myHeight );
	return myWidth;
}

CPRC = new Object();

var images = [
['001.jpg',8500],
['002.jpg',7500],
['003.jpg',9100],

['004.jpg',61000],
['006.jpg',7400],
['007.jpg',8900],
['008.jpg',8100],
['009.jpg',7900],
['010.jpg',8800],
['011.jpg',8200],
['012.jpg',8500],
['013.jpg',8300],
['014.jpg',8600],
['015.jpg',8800],
['016.jpg',8100],
['017.jpg',8200],
['018.jpg',8300]
];

function rotate_img(int_img){
	var str_element = 'image'+int_img;
	var rnd_no 		= get_rnd_no();
 	var obj 		= document.getElementById(str_element);
 	var functRef 	= callLater(int_img);
	obj.src 		= '/pubfiles/' + images[rnd_no][0];
	
 	setTimeout(functRef,images[rnd_no][1]);
}

//less repitition?
function get_rnd_no(){
	var rnd_no = Math.round((images.length-1)*Math.random());
	if(rnd_no == CPRC.old_pic){
		rnd_no = get_rnd_no();
	}
	CPRC.old_pic = rnd_no;
	return rnd_no;
}

function callLater(int_img){
    return (function(){
        rotate_img(int_img);
    });
}

function findnoofpictures () {
	var wsize=alertSize();
	var nopics;
	if (wsize>=1024) {nopics=5;}
	else if (wsize>=921) {nopics=5;}
	else if (wsize>=777) {nopics=4;}
	else if (wsize>=622) {nopics=3;}
	else if (wsize>=470) {nopics=2;}

	return nopics;
}

function initevents () {

	var nopics=findnoofpictures();
	rotate_img(1);
	rotate_img(2);
	if (nopics>2) rotate_img(3); else document.getElementById('image3').style.display='none';
	if (nopics>3) rotate_img(4); else document.getElementById('image4').style.display='none';
	if (nopics>4) rotate_img(5); else document.getElementById('image5').style.display='none';

}

window.onload = initevents;
