...

View Full Version : Help simplifying piece of code.



cw17s0n
02-21-2007, 05:10 AM
Hi I am working on a site that uses javascript, but have not really done much with javascript before. I am sure there is a way to condense this script so that it isn't so bloated.

http://www.cfwilson.com/RGI/NEW/V2V/V2V/viewer.js

If someone could take a look at the code I have provided a link too and make a suggestion to point me in the right direction, or show me how to accomplish this that would be great.



Thanks,
Charles

vwphillips
02-21-2007, 12:58 PM
var lastID=0;
function SelectImg(id){
if (lastID > 0) {
document.getElementById(lastID).className="thumbNormal";
}
document.getElementById(id).className="thumbSelected";
document.getElementById(0).src=document.getElementById(id).src;
lastID=id;
for (var zxc0=1;zxc0<=10;zxc0++){
document.getElementById("info_"+zxc0).style.visibility=(id==zxc0)?"visible":"hidden";
document.getElementById("info_"+zxc0).style.display=(id==zxc0)?"":"none";
document.getElementById("para1_"+zxc0).style.visibility=(id==zxc0)?"visible":"hidden";
document.getElementById("para1_"+zxc0).style.display=(id==zxc0)?"":"none";
document.getElementById("para2_"+zxc0).style.visibility=(id==zxc0)?"visible":"hidden";
document.getElementById("para2_"+zxc0).style.display=(id==zxc0)?"":"none";

}
}

function LoadTrigger(){
SelectImg(1);
}

window.onload=LoadTrigger;

function window_onload() {

for (var zxc0=1;zxc0<10;zxc0++){
document.getElementById("info_"+zxc0).style.visibility="hidden";
document.getElementById("info_"+zxc0).style.display="none";

}
document.getElementById("info_1").style.visibility="visible";
document.getElementById("info_1").style.display="";
}
function thumbnail_onmouseover(id){
document.getElementById(id).style.cursor="hand";
}
function thumbnail_onmouseout(id){
document.getElementById(id).style.cursor="default";
}
//-->
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum