////////////////////////////////////////////////////////////////////////////////
// Envision v2.0 by Inscripts                                                 //
////////////////////////////////////////////////////////////////////////////////
// Written by Anant Garg, webmaster@inscripts.com                             //
// Available from http://www.inscripts.com <> http://www.envisionv2.com       //
////////////////////////////////////////////////////////////////////////////////
// This script is provided "as is" with no kind of warranty.                  //
// If you encounter errors while using this script , feel free to contact     //
// us at support@envisionv2.com                                               //
////////////////////////////////////////////////////////////////////////////////
// By using this script you agree to indemnify Anant Garg from any liability  //
// that might arise from it's use. Inscripts.com and its staff does not       //
// guarantee that the script will work on all servers and will not be         //
// held liable for anything.                                                  //
//                                                                            //
// Selling the code for this program without prior written consent is         //
// expressly forbidden. Obtain permission before redistributing this script   //
// via any medium.                                                            //
//                                                                            //
// Use At Your Own Risk !!!                                                   //
////////////////////////////////////////////////////////////////////////////////

///////// DO NOT EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING /////////

function showyear(year)
{
o=document.getElementById(year);
s=o.style.display;
if(s!="block")
	{
	o.style.display="block";
	}
else
	{
	o.style.display="none";
	}
}

function arrange(type) {
document.cookie = "arrange" + "=" + type;

if (type == "random") {
var randomcode = (Math.round(Math.random( ) * 1000));
document.cookie = "code" + "= 0." + randomcode;
}

window.location.reload();
}

function ipp(no) {
document.cookie= "ipp" + "=" + no;
window.location.reload();
}

function skin(name) {
document.cookie= "template" + "=" + name;
window.location.reload();
}

function css(name) {
document.cookie= "css" + "=" + name;
window.location.reload();
}

function qj() {
var URL = document.envision.cat.options[document.envision.cat.selectedIndex].value;
window.location.href = URL;
}

function comments(album, img) {
var id = (Math.round(Math.random( ) * 1000));
var cmnt = window.open("comments.cgi?album=" + album + ";image=" + img, "cmnt"+id, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=' + 320 + ',height=' + 400);
	cmnt.focus();
}

function rating(album, img) {
var id2 = (Math.round(Math.random( ) * 1000));
var rate = window.open("rateimage.cgi?album=" + album + ";image=" + img, "rate"+id2, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + 240 + ',height=' + 180);
	rate.focus();
}

function hotrate() {
var hr = window.open("hotrate.cgi?album="+directory, "hotrate", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + 640 + ',height=' + 480);
	hr.focus();
}

function slideshow() {
var sld = window.open("slideshow.cgi?album="+directory, "slideshow", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + 640 + ',height=' + 480);
	sld.focus();
}

function getcookie(name) {
var c = document.cookie;
var index = c.indexOf(name + "=");
if (index != -1) {
index = c.indexOf("=", index) + 1;
var endstr = c.indexOf(";", index);
if (endstr == -1) endstr = c.length;
return unescape(c.substring(index, endstr));
} else {
return "1";
}
}

function sethits() {
var hits = getcookie("hits");

if (hits != "1") {
hits = hits+"|"+hitpath;
} else {
hits = hitpath;
}

var expiry = new Date(today.getTime() +  1000 * 60 * 60 * 24 * 100 * 365);
document.cookie="hits" + "=" + hits + "; expires=" + expiry.toGMTString();

}

function getbrowsersize() {
    if( typeof( window.innerWidth ) == 'number' ) {
    wdwd = window.innerWidth;
    wdht = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    wdwd = document.documentElement.clientWidth;
    wdht = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    wdwd = document.body.clientWidth;
    wdht = document.body.clientHeight;
  }
}

function start() {
getbrowsersize();
wdwd -= 60;
wdht -= 60;
orght = document.dispimg.height; 
orgwd = document.dispimg.width; 

loaded=1;
changesize=0;
resize('table');
}

function check() {
if (changesize == 1 && loaded == 1) {
getbrowsersize();
wdwd -= 60;
wdht -= 60;
resize('exact');
}
}

function resize(size) {

if (loaded == 1) {

if(size=="exact") {
changesize = 1;

ratio = wdwd/orgwd;
newht = orght*ratio;

newwd = wdwd;

if (newwd > orgwd) {
newwd = orgwd;
newht = orght;
}

if (newwd < tablewidth) {
if (tablewidth < orgwd) {
rat = tablewidth/orgwd;
newwd = tablewidth;
newht = orght*rat;
 } else {
newwd = orgwd;
newht = orght;
 }
}

} else if (size=="original") {
changesize = 0;
newwd = orgwd;
newht = orght;
} else {
changesize = 0;

if (orgwd > tablewidth) {
newwd = tablewidth;
rat = newwd/orgwd;
newht = orght*rat;
} else {
newwd = orgwd;
newht = orght;
}

}


document.dispimg.width  = newwd;
document.dispimg.height = newht;
}
}

if (typeof addhit != 'undefined') {
if (addhit == 1) { 	sethits(); }
}