
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 );
}


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 );
}


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 checkEmail(str, text){
	var at = "@";
	var dot = ".";
	var lat = str.indexOf(at);
	var lstr = str.length;
	var ldot = str.indexOf(dot);

	if (str != '')	{
		//ja e-mail adres nav at
		if (str.indexOf(at) == -1){
		   alert(text);
		   return false;
		}
	
		//ja ar at beidzas vai sakas adrese
		if (str.indexOf(at) == 0 || str.indexOf(at) == lstr){
		   alert(text);
		   return false;
		}
	
		//ja e-mail adres nav punkts, vai adrese ar to sakas vai beidzas
		if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr){
			alert(text);
			return false;
		}
	
		//ja adres ir 2 ati
		if (str.indexOf(at, (lat + 1)) != -1){
			alert(text)
			return false
		}
	
		//ja punkts atrodas tiesi pirms vai tiesi pec at
		if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot){
			alert(text);
			return false;
		}
	
		//ja punkts neatrodas vismaz 2 simbolus aiz at
		if (str.indexOf(dot, (lat + 2)) == -1){
			alert(text);
			return false;
		}
		
		//ja adres ir kds space
		if (str.indexOf(" ")!=-1){
			alert(text);
			return false;
		}
	}else{
		alert(text);
		return false;
	}
	 return true;
}
