String.prototype.trim = function() {
  return( this.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') ); 
}

function switchPNO (n, mode) {
	d = document;
	if ((d.pno) && (d.pno[n]) && (d.pno[n][mode])) {
		img = d.images['pno' + n];
		if (img) img.src = d.pno[n][mode].src;
	}
}

function switchOL(mode) {
	d = document;
	if ((d.ol) && (d.ol[mode])) {
		img = d.images['ol_img'];
		if (img) img.src = d.ol[mode].src;
	}
}

function openMenus1(id) {
	d = document;
	actMenu1Id = '';
	if (d.all) {
		if (d.activeMenu1Id != '') {
			actMenu1Id = d.activeMenu1Id;
			menuArray = eval('d.menus1_' + d.activeMenu1Id);
			if (menuArray != null) {
				for (mid in menuArray) {
					m = d.all[menuArray[mid]];
					if (m != null) {
						m.style['visibility'] = 'hidden';
						m.style['position'] = 'absolute';
					}
				}
			}
			menuDelimiter = d.all['menuDelimiter' + actMenu1Id];
			if (menuDelimiter != null) {
				menuDelimiter.style['visibility'] = 'hidden';
				menuDelimiter.style['position'] = 'absolute';
			}
			d.activeMenu1Id = '';
		}
		if (d.activeMenu2Id != '') {
			m = d.all['menu2_' + d.activeMenu2Id];
			if (m != null) {
				m.style['visibility'] = 'hidden';
				m.style['position'] = 'absolute';
			}
			d.activeMenu2Id = '';
		}
		if (actMenu1Id != id) {
			menuArray = eval('d.menus1_' + id);
			if (menuArray != null) {
				isActive = false;
				for (mid in menuArray) {
					isActive = true;
					m = d.all[menuArray[mid]];
					if (m != null) {
						m.style['position'] = 'static';
						m.style['visibility'] = 'visible';
					}
				}
				if (isActive) {
					menuDelimiter = d.all['menuDelimiter' + id];
					if (menuDelimiter != null) {
						menuDelimiter.style['position'] = 'static';
						menuDelimiter.style['visibility'] = 'visible';
					}
					d.activeMenu1Id = id;
				}
			}
		}
	}
	else if (d.getElementById) {
		if (d.activeMenu1Id != '') {
			actMenu1Id = d.activeMenu1Id;
			menuArray = eval('d.menus1_' + d.activeMenu1Id);
			if (menuArray != null) {
				for (mid in menuArray) {
					m = d.getElementById(menuArray[mid]);
					if (m != null) {
						m.style['visibility'] = 'hidden';
						m.style['position'] = 'absolute';
					}
				}
			}
			menuDelimiter = d.getElementById('menuDelimiter' + actMenu1Id);
			if (menuDelimiter != null) {
				menuDelimiter.style['visibility'] = 'hidden';
				menuDelimiter.style['position'] = 'absolute';
			}
			d.activeMenu1Id = '';
		}
		if (d.activeMenu2Id != '') {
			m = d.getElementById('menu2_' + d.activeMenu2Id);
			if (m != null) {
				m.style['visibility'] = 'hidden';
				m.style['position'] = 'absolute';
			}
			d.activeMenu2Id = '';
		}
		if (actMenu1Id != id) {
			menuArray = eval('d.menus1_' + id);
			if (menuArray != null) {
				isActive = false;
				for (mid in menuArray) {
					isActive = true;
					m = d.getElementById(menuArray[mid]);
					if (m != null) {
						m.style['position'] = 'static';
						m.style['visibility'] = 'visible';
					}
				}
				if (isActive) {
					menuDelimiter = d.getElementById('menuDelimiter' + id);
					if (menuDelimiter != null) {
						menuDelimiter.style['position'] = 'static';
						menuDelimiter.style['visibility'] = 'visible';
					}
					d.activeMenu1Id = id;
				}
			}
		}
	}
}

function openMenus2(id1, id2) {
	d = document;
	actMenu2Id = '';
	if (d.all) {
		if ((d.activeMenu1Id != '') && (id1 != d.activeMenu1Id)) {
			menuArray = eval('d.menus1_' + d.activeMenu1Id);
			if (menuArray != null) {
				for (mid in menuArray) {
					m = d.all[menuArray[mid]];
					if (m != null) {
						m.style['visibility'] = 'hidden';
						m.style['position'] = 'absolute';
					}
				}
			}
			menuDelimiter = d.all['menuDelimiter' + d.activeMenu1Id];
			if (menuDelimiter != null) {
				menuDelimiter.style['visibility'] = 'hidden';
				menuDelimiter.style['position'] = 'absolute';
			}
			d.activeMenu1Id = '';
		}
		if (d.activeMenu2Id != '') {
			actMenu2Id = d.activeMenu2Id;
			m = d.all['menu2_' + d.activeMenu2Id];
			if (m != null) {
				m.style['visibility'] = 'hidden';
				m.style['position'] = 'absolute';
			}
			d.activeMenu2Id = '';
		}
		if (id2 != actMenu2Id) {
			m = d.all['menu2_' + id2];
			if (m != null) {
				m.style['position'] = 'static';
				m.style['visibility'] = 'visible';
				d.activeMenu2Id = id2;
			}
		}
	}
	else if (d.getElementById) {
		if ((d.activeMenu1Id != '') && (id1 != d.activeMenu1Id)) {
			menuArray = eval('d.menus1_' + d.activeMenu1Id);
			if (menuArray != null) {
				for (mid in menuArray) {
					m = d.getElementById(menuArray[mid]);
					if (m != null) {
						m.style['visibility'] = 'hidden';
						m.style['position'] = 'absolute';
					}
				}
			}
			menuDelimiter = d.getElementById('menuDelimiter' + d.activeMenu1Id);
			if (menuDelimiter != null) {
				menuDelimiter.style['visibility'] = 'hidden';
				menuDelimiter.style['position'] = 'absolute';
			}
			d.activeMenu1Id = '';
		}
		if (d.activeMenu2Id != '') {
			actMenu2Id = d.activeMenu2Id;
			m = d.getElementById('menu2_' + d.activeMenu2Id);
			if (m != null) {
				m.style['visibility'] = 'hidden';
				m.style['position'] = 'absolute';
			}
			d.activeMenu2Id = '';
		}
		if (id2 != actMenu2Id) {
			m = d.getElementById('menu2_' + id2);
			if (m != null) {
				m.style['position'] = 'static';
				m.style['visibility'] = 'visible';
				d.activeMenu2Id = id2;
			}
		}
	}
}

function changeThumbnail(id, mode) {
	d = document;
	if ((d.images) && (d.images['thumb' + id]) && (d.blankImage)) {
		if (mode == 1) {
			if ((d.thumbnails) && (d.thumbnails[id])) d.images['thumb' + id].src = d.thumbnails[id].src;
		}
		else d.images['thumb' + id].src = d.blankImage.src;
	}
}

function validateCForm(f) {
	if (f.elements['firstName'].value.trim() == '') {
		alert('Write in your first name please!');
		f.elements['firstName'].focus();
		return false;
	}
	if (f.elements['lastName'].value.trim() == '') {
		alert('Write in your last name please!');
		f.elements['lastName'].focus();
		return false;
	}
	email = f.elements['email'].value.trim();
	emailRegXp = /^[_a-z0-9\-]+(\.[_a-z0-9\-]+)*@[_a-z0-9\-]+(\.[_a-z0-9\-]+)*(\.[_a-z0-9\-]{2,4})$/i;
	if (email == '') {
		alert('Write in your email please!');
		f.elements['email'].focus();
		return false;
	}
	else if (!emailRegXp.test(email)) {
		alert('Invalid email address!');
		f.elements['email'].focus();
		return false;
	}
	return true;
}


function DrawAMC(height, width, imagepath, CLSID_AMC, ver_AMC, ShowAMCToolbar, ptzgui, useWithCam, camnbr, UseRel, UseMotion)
{

    document.write('<OBJECT ID="Player" height="' + height + '" width="' + width + '" border="0" CLASSID="CLSID:' + CLSID_AMC + '" CODEBASE="/activex/AMC.cab#version=' + ver_AMC + '" STANDBY="Loading Axis Media Control components...">');
    document.write('<param name="MediaURL" value="' + imagepath + '">');
    document.write('<param name="MediaType" value="mjpeg-unicast">');
    document.write('<param name="ShowStatusBar" value="0">');
    document.write('<param name="ShowToolbar" value="0">');
    document.write('<param name="AutoStart" value="1">');
    document.write('<param name="StretchToFit" value="1">');
    document.write('</OBJECT>');
}

function video(imagepath)
{
  var width = 610
  var height = 366

  var picturepath = imagepath.replace(/video/, "image")
  picturepath = picturepath.replace(/mjpg/g, "jpg")

  if ('1' != '1') {
    width = width*1
    height = height*1
  }

  if ((navigator.appName == "Microsoft Internet Explorer")&&(navigator.platform != "MacPPC")&&(navigator.platform != "Mac68k")) {
    DrawAMC(height, width, imagepath, "745395C8-D0E1-4227-8586-624CA9A10A8D", "3,11,0,1", "", "", "", "", "", "no");
  } else {
    theDate = new Date();
        var output = '<center>'+
                     '<a href="http://www.obala-alter.net" target="_blank">'+
                     '<img SRC="' + imagepath + '"width="' + width + '"height="' + height +'" width="' + width;
        output += '" border=0 ALT="Ni slike? Zgleda, da si se spomnil prepozno in si zamudil (zasedene so vse povezave do kamere).. Poskusi veæ ksno." width=' + width + ' height=' + height +' width=' + width + '></a></center>';
      document.write(output);
  }
}

