var popUpwidth=510;
var encours=false;
var img_pos=0;
var tot=0;
function goto(lnk){
	window.location=lnk;
}
function gotonew(lnk){
window.open(lnk,'wASTE','width='+screen.width,'height='+screen.height,'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes')
}
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;
  }
  var a=new Array(myWidth,myHeight);
  return a;
}
function moveImgleft(){
    if(img_pos>1){
        img_pos--;
        view_img(images[img_pos][0],images[img_pos][1],images[img_pos][2],images[img_pos][3],images[img_pos][4])
    }
}
function moveImgright(){
    if(img_pos<tot){
        img_pos++;
        view_img(images[img_pos][0],images[img_pos][1],images[img_pos][2],images[img_pos][3],images[img_pos][4])
    }
}
function view_img(lnk,w,h,img_num,img_tot){
    img_pos=img_num
    tot=img_tot
	var a=new Array(w,h);
	a=resizeImg(a);
	var b=new Array();
	b=alertSize();
	document.getElementById('light').style.width=popUpwidth+"px";
	document.getElementById('light').style.height=popUpwidth+"px";
	document.getElementById('light').style.display='block';
	//document.getElementById('fade').style.display='block';
	document.getElementById('light').style.left=((b[0]-popUpwidth+100)/2)+"px"
	document.getElementById('light').style.top=((b[1]-popUpwidth)/2)+"px"
	document.getElementById('img').innerHTML='<img height="'+a[1]+'px" width="'+a[0]+'px" src="'+lnk+'"/>'
	document.getElementById('img').style.width=a[0]+"px"
	document.getElementById('img').style.height=a[1]+"px"
    document.getElementById('img1').style.width=a[0]+"px"
}
function resizeImg(a){
	var SIZE=popUpwidth-50;
	if(a[0]>a[1]){
		a[1]=Math.floor((a[1]*SIZE)/a[0])
		a[0]=SIZE;
	}else{
		a[0]=Math.floor((a[0]*SIZE)/a[1])
		a[1]=SIZE;
	}
	return a;
}
function moveIt(){
	if(i){
		t=setInterval(goUp,20);
	}else{
		t=setInterval(goDown,20);
	}
}
function goUp(){
	if(pos>-h && pos<=0){
		pos-=SPEED;
		document.getElementById("toMove").style.top=pos+"px";
	}else{
		i=false;
	}
}
function goDown(){
	if(pos>=-h && pos<0){
		pos+=SPEED;
		document.getElementById("toMove").style.top=pos+"px";
	}else{
		i=true;
	}
}
function go(i){
	if(i){
		t=setInterval(goUp,20);
	}else{
		t=setInterval(goDown,20);
	}
}
function stopGo(){
	clearInterval(t);
}
//for left right gallery
function stopGoLR(){
	clearInterval(t1);
encours=false;
}
function goLeft(){
	if(pos1<0){
		pos1+=SPEED1;
		document.getElementById("toMove1").style.left=pos1+"px";
	}else{
stopGoLR();
}
}
function goRight(){
	if(pos1>-h1 && pos1<=0){
		pos1-=SPEED1;
		document.getElementById("toMove1").style.left=pos1+"px";
	}
else{
stopGoLR();
}
}
function goLR(i){
if(!encours){ encours=true;
	if(i){
		t1=setInterval(goLeft,20);
	}else{
		t1=setInterval(goRight,20);
	}
}
}
var browserOK;

	var nVer = navigator.appVersion;
	var nAgt = navigator.userAgent;
	var browserName  = navigator.appName;
	var fullVersion  = ''
	var verOffset;
    var safari=false;
	if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
	 browserName = "Microsoft Internet Explorer";
	 fullVersion = nAgt.substring(verOffset+5,verOffset+8);
	}
    if((verOffset=nAgt.indexOf("Safari"))!=-1){
        safari=true;
    }
	browserOK=isBrowserOK();
function isBrowserOK(){
	if(browserName=="Microsoft Internet Explorer" && (fullVersion==6.0 || fullVersion==7.0 || fullVersion==5.0)){
		return true;
	}else{
		return false;
	}
}
