var this_array = 0

var row = 0

var array_size = numberOfImages - 1

first_array = new Array()

function generate_array()
{

if(numberOfImages==1){
 first_array[0]=0
	}else
{
 for (a = 0; a<= array_size ; a++)
  {
   first_array[a]=a
  }

for (z =0; z <= array_size ;z++)
 {
  this_array = Math.round(Math.random()*(z));
  row = first_array[this_array];
  if (this_array <= array_size)
   {
    for (s = this_array; s<=array_size;s++)
     {
      first_array[s] = first_array[(s+1)]
     first_array[array_size+1] = row
     }
    }
 }

//clear array from dubllicated

var res, resI,has,val;
res  = new Array(); 
resI=0;
iii=2;
for (z =0; z <= array_size+1 ;z++) {
	val = first_array[z];
	has=0;
	for (zz =0; zz <= resI ;zz++) {
		if(res[zz]==val) {
			val = array_size+iii;
			iii++;
			break;
		}
	}
	res[resI]=val;
	resI++;
}
 for (a = 0; a<=array_size+1 ; a++)
  {
   first_array[a]=res[a];
  }

//

}
}


generate_array()  


function fitWindowSizePortrait(image_name,image_num,imagepath)
 {
	var image_w
 	var image_h
 	var winh
 	var winw
 	image_w = (document.images[image_num].width)*2.328;
	image_h =(document.images[image_num].height)*2.328;
	winh = image_h + 8 
	 //+ 110;
	winw = image_w + 8
	 //+ 80;  
	win_name = image_num

	showWindow(winw,winh,image_h,win_name,image_name,image_w,imagepath)
}





function fitWindowSizeLandscape(image_name,image_num,imagepath)
{
	var image_w
	var image_h
	var winh
	var winw
	image_w = (document.images[image_num].width)*2.47;
	image_h =(document.images[image_num].height)*2.47;
	winh = image_h + 8 
	 //+ 110;
	winw = image_w + 8
	//+ 80;  
	win_name = image_num
	showWindow(winw,winh,image_h,win_name,image_name,image_w,imagepath)

}


function showWindow(winw,winh,image_h,win_name,image_name,image_w,imagepath)
{
  preview = window.open("",win_name, "width=" + winw + ",height=" + winh + "top = 50, left = 100");
  preview.document.open();

  preview.document.write("<html><head>");
  preview.document.write("<title>preview</title>");
  preview.document.write("<style type='text/css'> body { background-image: url('" + imagepath + "/" + image_name + ".jpg');" + " background-attachment: fixed; background-color:#000000; background-repeat: no-repeat; background-position: center center;} </style>");
  preview.document.write("</head><body text='ffffff' onblur='javascript:self . focus ();'>");
  preview.document.write("<form><input type='button' value='close' " + "onclick='window.close()'></form>");
  preview.document.write("</center>");
  preview.document.write("</body></html>");
  preview.document.close();   
}

function JumpMenu(selObj,restore){ //v1.7 by Project Seven
	var theFullString = selObj.options[selObj.selectedIndex].value;
	if (restore) selObj.selectedIndex=0;
	var theLength = theFullString.length;
	var endPos = theFullString.lastIndexOf("~");
	var theUrl, theTarget, theParent;
	if (endPos > 0) {theUrl = theFullString.substring(0,endPos);}
	else {theUrl = theFullString;}
	endPos++
	if (endPos < theLength) {theTarget = theFullString.substring(endPos,theLength)}
	else {theTarget = "window:Main";}
	if (theTarget == "window:New") {window.open(theUrl);}
	else if (theTarget == "window:Main") {eval("parent.location='"+theUrl+"'");}
	else {eval("parent.frames[\'"+theTarget+"\'].location='"+theUrl+"'");}
}

function externalLinks()
{ 
	if (!document.getElementsByTagName) return; 
		var anchors = document.getElementsByTagName("a"); 
		for (var i=0; i<anchors.length; i++) 
			{ 
				var anchor = anchors[i]; 
				if (anchor.getAttribute("href") && 
						anchor.getAttribute("rel") == "external") 
						anchor.target = "_blank"; 
					}
}
window.onload = externalLinks;

