var restoreimgsrc="";

function MMon(p){
restoreimgsrc = document.images[p].src;
document.images[p].src=restoreimgsrc.substring(0,restoreimgsrc.length-4)+"_on.gif";
}
function MMof(p){
 document.images[p].src=restoreimgsrc;
}

function Pagelocation(page) {
 if (page.indexOf("/")>=0 ) document.location = page;
}

function imgchange(chimg){
  var imgobj = document.images[chimg];
  imgpath = imgobj.src;
  imgpath_base = imgpath.substring(0,imgpath.length-6);

  switch (imgobj.width){
     case 231:   // normal=>lager
       imgobj.width  = 456;
       imgobj.height = 306;
       imgobj.src=imgpath_base + '_1.jpg';
       break;
     case 456:
       imgobj.width  = 231;
       imgobj.height = 156;
       imgobj.src=imgpath_base + '_2.jpg';
       break;
     case 156:  //vertcal=>v.large
       imgobj.width  = 306;
       imgobj.height = 456;
       imgobj.src=imgpath_base + '_1.jpg';
       break;
     case 306:  //vertcal=>v.large
       imgobj.width  = 156;
       imgobj.height = 231;
       imgobj.src=imgpath_base + '_2.jpg';
       break;
  }

}

function galeryimgshow(chimg){
  var imgobj = document.images[chimg];
  imgpath = imgobj.src;
  imgpath_base = imgpath.substring(0,imgpath.length-5);
  //imgwidth  = imgobj.width;
  bgimg.src=imgpath_base + '1.jpg';
}

function showNavLayer(){
document.getElementById("NavLayer").style.visibility="visible";
}

function hideNavLayer(){
document.getElementById("NavLayer").style.visibility="hidden";
}


function ShowMe(el) {
  document.all[el].style.visibility = "visible";
}
function HideMe(el) {
  document.all[el].style.visibility = "hidden";
}


function popup( src) {
 wdparms = 'width=330,height=330,scrollbars=no,resizable=yes,toolbar=no,menubar=no,left=20,top=20';
 window.open( 'popup.php?src='+src,'',  wdparms );
}

function full(src) {
 wdparms = 'status=no,titlebar=no,location=no,scrollbars=auto,toolbar=no,menubar=no,fullscreen=1';
 window.open( src,'',  wdparms );
}


var restorebck="";

function changeBckOver(p){
restorebck = document.getElementById(p).style.backgroundImage;
//alert(restorebck);
if (restorebck.indexOf('_on')==-1){
document.getElementById(p).style.backgroundImage = restorebck.substring(0,restorebck.length-5)+"_on.gif)";
}
//alert(restorebck.substring(0,restorebck.length-5)+"_on.gif)");
//document.images[p].src=restorebck.substring(0,restorebck.length-4)+"_on.gif";
}
function changeBckOut(p){
if (restorebck.indexOf('_on')==-1){
document.getElementById(p).style.backgroundImage = restorebck;
}
// document.images[p].src=restorebck;
}


function mC(a){
//alert(a.tagName);
//alert();
z=a.getElementsByTagName("a");
myBody=z.item(0);
//alert(myBody.href);
//z=myBody.getElementsByTagName('a')
//window.open(myBody.href);
location.href=myBody.href;
//myBody.click();
}



function popupImage(src) {
	 wdparms = 'width=200,height=200,scrollbars=no,resizable=yes,toolbar=no,menubar=no,left=50,top=100';
	 window.open( 'popupImage.php?src='+src, 'popup',  wdparms );
}

function popupWindow(src,width,height,scrollbars,toolbar,resizable, menubar,title,autosize) {
	 	wdparms = 'width='+width+',height='+height+',scrollbars='+scrollbars+',toolbar='+toolbar+',resizable='+resizable+',menubar='+menubar;
		window.open( 'popupWindow.php?src='+src+'&autosize='+autosize+'&title='+title, '',  wdparms );
}

function throwPopup(src,width,height,scrollbars,toolbar,resizable, menubar) {
	 	wdparms = 'width='+width+',height='+height+',scrollbars='+scrollbars+',toolbar='+toolbar+',resizable='+resizable+',menubar='+menubar;
		return window.open(src, '',  wdparms );
}

var oldColor;
function changeBckColorOver(p){
oldColor = document.getElementById(p).style.backgroundColor;
if (oldColor!='#DC9147')
document.getElementById(p).style.backgroundColor = '#DC9147';
}

function changeBckColorOut(p){
if (oldColor!=document.getElementById(p).style.backgroundColor)
document.getElementById(p).style.backgroundColor = oldColor;
}

function popupHref(href){
	window.open(href,"",'width=100,height=100');
}

function changeClass(object, name){
	object.className=name;
}

function klases(id) {
  
    var table = document.getElementById(id);
    if (! table) { return; }

    var tbodies = table.getElementsByTagName("tbody");

    for (var h = 0; h < tbodies.length; h++) {
    
      var trs = tbodies[h].getElementsByTagName("tr"); 
      
      for (var i = 0; i < trs.length; i++) {

          var tds = trs[i].getElementsByTagName("td");

          for (var j = 0; j < 2; j++) {
        
            var mytd = tds[j]; 
            
            if (j == 0) { mytd.className = "pirma"; }
            	else { mytd.className = "otra"; }

          }
      }
    }
  }
