
for(var j = 0; j < imgAr1.length; j++)
{
		rImg1[j] = new Image();
        rImg1[j].src = imgAr1[j];
}

//window.onload = setting();

var slide =  null;
function setting()
{
	slide = document.getElementById('pic');
	slide.src = imgAr1[0];
	scale();
}

//Image or picture slide show using java script
//slideshow function
var picture = 0;
function next_img(){
	if(picture < imgAr1.length - 1){
		picture = picture + 1;
	} else {
		picture = 0;
	}
	slide.src = imgAr1[picture];
	scale();
}

function prev_img(){
	if(picture > 0 ){
		picture=picture-1;
	} else {
		picture = imgAr1.length -1;
	}
	slide.src = imgAr1[picture];
	scale();
}

function scale() {
	var width = 0, height = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    width = window.innerWidth;
    height = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    width = document.documentElement.clientWidth;
    height = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    width = document.body.clientWidth;
    height = document.body.clientHeight;
  }
	//var width = window.innerWidth;
	//var height = window.innerHeight;
	if (width / rImg1[picture].width < height / rImg1[picture].height) {
		mult = height / rImg1[picture].height;
	} else {
		mult = width / rImg1[picture].width;
	}
	slide.style.width = (rImg1[picture].width * mult) + 'px';
	slide.style.height = (rImg1[picture].height * mult) + 'px';
}
