﻿var preloadFlag = false;
preloadImages()
 

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function preloadImages() {
	if (document.images) {
		image1 = newImage('images/s1-1h.gif');
		image1 = newImage('images/s1-2h.gif');
		image1 = newImage('images/s1-3h.gif');
		image1 = newImage('images/s1-4h.gif');
		image1 = newImage('images/s1-5h.gif');
		image1 = newImage('images/s2-1h.gif');
		image1 = newImage('images/s2-2h.gif');
		image1 = newImage('images/s2-3h.gif');
		image1 = newImage('images/s2-4h.gif');
		image1 = newImage('images/s3-1h.gif');
		image1 = newImage('images/s3-2h.gif');
		image1 = newImage('images/s3-3h.gif');
		image1 = newImage('images/s3-1-1h.gif');
		image1 = newImage('images/s3-1-2h.gif');
		image1 = newImage('images/s3-1-3h.gif');
		image1 = newImage('images/s3-1-4h.gif');

		preloadFlag = true;
	}
}
function highlight(me){
	low=me.src;
	if ((low.substr(low.length-5,1) != "a") && (low.substr(low.length-5,1) != "h")){
	high=low.substr(0,low.length-4)+"h.gif";
	me.src=high;
	}
	
}

function lowlight(me){
	high=me.src;
	if (high.substr(high.length-5,1) == "h"){
	low=high.substr(0,high.length-5)+".gif";
	me.src=low;
	}
}

function showphoto(me){
window.open("projects/photo.html#"+me.id,"new","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=600, height=600");
}
myhash="";
function openphoto(){
if (myhash != location.hash){
window.focus();
myhash=location.hash;
myid=myhash.substr(1,myhash.length-1);
source=window.opener.document.getElementById(myid).src;
mysource="photo/"+source.substr(source.lastIndexOf("/")+1,source.length);
mycaption=window.opener.document.getElementById(myid).alt;
document.title=mycaption;
document.getElementById("caption").innerHTML=mycaption;
document.getElementById("pic").src=mysource;
}
t=setTimeout("openphoto()",500);
}


function expand(me)
{
mydes=document.getElementById(me.id+"-d");
if (mydes.style.display =='block'){
mydes.style.display =  'none';
}else{
mydes.style.display='block';
mytop = me.offsetTop;
window.scrollTo(0,mytop);
}
}


function loadinframe(){
source= location.hash.substr(1);
if (location.hash != ""){
document.getElementById("inframe").src='projects/'+source+'.html';
}
}

function next(){

mylist= document.getElementById("list");

nowtop = parseInt(mylist.style.top)
if (document.getElementById("next").className != "nextoff"){
mylist.style.top = nowtop -360;
}
checknextstate();
}

function previous(){
mylist= document.getElementById("list");
nowtop = parseInt(mylist.style.top)
if (document.getElementById("previous").className != "nextoff"){
mylist.style.top= nowtop + 360;
}
checknextstate();
}

function checknextstate(){
mylist= document.getElementById("list");
nextbtn=document.getElementById("next");
prevbtn=document.getElementById("previous");
mytop = parseInt(mylist.style.top)
if (mytop + mylist.offsetHeight < 360) {
	nextbtn.className = "nextoff"
}else{
	nextbtn.className = "next"
}

if (mytop >=0){
	prevbtn.className = "nextoff"
}else{
	prevbtn.className = "next"
}
}

function ArrangePhotos(){
for (i=1; i<=6; i++){
	thisphoto = document.getElementById('photo'+i);
	k = myphoto.length - pagenumber*6 - i;
	if (myphoto[k]){
		thisphoto.src = "tmbs/" + myphoto[k];
		thisphoto.alt = mydesc[k];
	} else {
		thisphoto.src = "../images/spacer.gif";
	}
}
checknextstate_g();
}

function checknextstate_g(){
nextbtn=document.getElementById("next");
prevbtn=document.getElementById("previous");
if (pagenumber ==0) {
	prevbtn.className = "nextoff"
	} else {
	prevbtn.className = "next"
	}
if (((pagenumber+1) * 6) >= myphoto.length){
	nextbtn.className = "nextoff"
	} else {
	nextbtn.className = "next"
	}
}

function NextG(){
if (document.getElementById('next').className == "next"){
window.location="photogallery00.html#" + (pagenumber+1);
window.location.reload();
} else {
//window.location="photogallery00.html#" + pagenumber;
}
}

function PreviousG(){
if (document.getElementById('previous').className == "next"){
window.location="photogallery00.html#" + (pagenumber-1);
window.location.reload();
} else {
//window.location="photogallery00.html#" + pagenumber;
}
}

function filltop(){
	if (top.parentflag) {
		top.document.getElementById("container").innerHTML = document.body.innerHTML
	} else {
		document.write ('<a href="http://www.ramtintaj.com/index.html">Go back to Home</a>');
	}
}







