var APP_CMS_PATH = "http://www.bentelsecurity.it/CMS/";

document.onkeyup = closePopups;
function changeLanguage() {
	url = "index.php?o=get_lang_popup";
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_changeLanguage;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _changeLanguage() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
//		closeWait();
//		showOverlay();
		box(getXMLNode(ret));
	}

}

function changeRegion() {
	url = "index.php?o=get_reg_popup";
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_changeRegion;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _changeRegion() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
//		closeWait();
//		showOverlay();
		box(getXMLNode(ret));
	}

}

function showLogin(msg) {
	return showLoginNew(msg);
	txt = '';
	txt += '<div class="login-popup"> ';
	txt += '<div class="login-close"> <a href="#"><img src="images/icon_delte_up.gif" alt="close" name="closepop" width="21" height="21" border="0" id="closepop" onmouseover="MM_swapImage(\'closepop\',\'\',\'images/icon_delte_over.gif\',1)" onmouseout="MM_swapImgRestore()" onclick="closeWait()" /></a></div>';
	txt += '<div class="login-title">Security Professional Login  </div>';
	if (msg) txt += '<div class="login-error">' + msg +  ' </div>';
	txt += '<div class="login-row">';
	txt += '<div class="login-label">Please note: Extended Site Access is for Authorized DSC Dealers only.</div> ';
	txt += '</div>';
	txt += '<div class="login-row">';
	txt += '<div class="login-label">User Name</div>';
	txt += '<div class="login-field-holder"><input class="login-field" id="lusername" type="text" onkeyup="login2(event)"/> </div>';
	txt += '</div>';
	txt += '<div class="login-row">';
	txt += '<div class="login-label">Password</div>';
	txt += '<div class="login-field-holder"><input class="login-field" id="lpassword" type="password"  onkeyup="login2(event)"/> </div>';
	txt += '</div>';
	txt += '<div class="login-bttn-row">';
	txt += '<div class="bttn-eventpop"><a href="#self" onclick="login();">Login</a></div> ';
	txt += '</div>';
	txt += '<div class="login-link">Forgot your Password?</div>';
	txt += '<div class="login-link"><a href="#self" onclick="showForgot()">Click Here.</a></div>';

	
	txt += '<div class="exaccess-link"> <a href="index.php?o=register">Register now for Extended  Site Access &nbsp;<img src="images/arrow_white_right.jpg" border="0" /></a></div>';
	txt += '</div>';
	showOverlay();
	box(txt);
}

function showLoginNew(msg) {
	Set_Cookie("CheckCookie", 1);
	if (!Get_Cookie("CheckCookie"))
	{
		message2("<div class='message'>We are sorry, but your browser doesn't accept cookies from our server. In order to login to our website, you must allow cookies from your browser options. <br><br><a href='http://www.google.com/cookies.html' target='_blank'>Click here to view the instructions on how to enable cookies in common browsers</a></div>");
		return false;
	}
//	txt = '';
//	txt += '<div class="login-popup"> ';
//	txt += '<div class="login-close"> <a href="#"><img src="images/icon_delte_up.gif" alt="close" name="closepop" width="21" height="21" border="0" id="closepop" onmouseover="MM_swapImage(\'closepop\',\'\',\'images/icon_delte_over.gif\',1)" onmouseout="MM_swapImgRestore()" onclick="closeWait()" /></a></div>';
//	txt += '<div class="login-title">Security Professional Login  </div>';
//	if (msg) txt += '<div class="login-error">' + msg +  ' </div>';
//	txt += '<div class="login-row">';
//	txt += '<div style="padding: 20px 10px 0px 10px; color: #cc0000">Please note: Extended Site Access is for Authorized DSC Dealer/Distributor only.</div> ';
//	txt += '</div>';
//	txt += '<div class="login-row">';
//	txt += '<div class="login-label">User Name</div>';
//	txt += '<div class="login-field-holder"><input class="login-field" id="lusername" type="text" onkeyup="login2(event)"/> </div>';
//	txt += '</div>';
//	txt += '<div class="login-row">';
//	txt += '<div class="login-label">Password</div>';
//	txt += '<div class="login-field-holder"><input class="login-field" id="lpassword" type="password"  onkeyup="login2(event)"/> </div>';
//	txt += '</div>';
//	txt += '<div style="width: 450px; text-align: left; padding-left: 144px;"><input type="checkbox" id="remember"> remember password</div>';
//	txt += '<div class="login-bttn-row">';
//	txt += '<div class="bttn-eventpop"><a href="#self" onclick="login();">Login</a></div> ';
//	txt += '</div>';
//	txt += '<div class="login-link">Forgot your Password?</div>';
//	txt += '<div class="login-link"><a href="#self" onclick="showForgot()">Click Here.</a></div>';
//	txt += '<div class="exaccess-link"> <a href="index.php?o=register">Register now for Extended  Site Access &nbsp;<img src="images/arrow_white_right.jpg" border="0" /></a></div>';
//	txt += '</div>';
	showOverlay();
	url = "index.php?o=get_login_form&err=" + msg;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showLoginNew;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _showLoginNew() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
		txt = getXMLNode(ret);
		box(txt);
		el = document.getElementById('lusername');
		el.focus();
	}

}


function login2(e) {
	if (e.keyCode == 13) login();
	return true;
}

function login() {
	el = document.getElementById("lusername");
	el2 = document.getElementById("lpassword");
	el3 = document.getElementById("remember");
	el2.value = el2.value.replace(/^\s+|\s+$/g,"");
	url = "index.php?o=login&user=" + encode(el.value) + "&pwd=" + md5(el2.value);
	if (el3 && el3.checked)
	{
		url += "&remember=yes";
	}
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_login;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	} else {
		url2 = "index.php?o=login2&user=" + encode(el.value) + "&pwd=" + md5(el2.value);
		if (el3 && el3.checked)
		{
			url2 += "&remember=yes";
		}
		window.location=url2;
	}
}


function _login() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("ret");
		ret2=response.getElementsByTagName("back1");
		msg = getXMLNode(ret);
		bck = getXMLNode(ret2);
		if (msg == "ok")
		{
//			grp = response.getElementsByTagName("groupid");
//			grp = getXMLNode(grp);
//			if (grp == 21 || grp == 22 || grp == 24 || !grp) window.location="index.php?n=distributors"; 
//			else 
//				closeWait();
				if (bck == "no") window.location.reload(); else {
					window.location='index.php?n=Forum';
				}
		} else {
			showLogin(msg);
		}
	}
}


function showForgot(msg) {
	showOverlay();
	url = "index.php?o=get_forgot_form&err=" + msg;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showForgot;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showForgot() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
		txt = getXMLNode(ret);
		box(txt);
		el = document.getElementById('email');
		el.focus();
	}

}


function forgot() {
	el = document.getElementById("email");
	url = "index.php?o=retrieve&email=" + encode(el.value);
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_forgot;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _forgot() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("ret");
		msg = getXMLNode(ret);
		if (msg == "ok")
		{
			message("Your password was emailed to you. Please check your email for details");
		} else {
			showForgot(msg);
		}
	}

}

function showTab(i) {
	selectedTab = i;
	showCover(); 
	el = document.getElementById("menutabs");
	if (i)
	{
		el.style.backgroundImage = "url(images/ptab"+i+"_dwn.jpg)";
	} else el.style.backgroundImage = "url(images/ptabs_allup.jpg)";
	for (k=1; k<=3; k++)
	{
		el = document.getElementById("tabMenu" + k);
		if (i != k) 
			el.style.display = "none"; 
		else 
			el.style.display = "block"; 
	}
	el = document.getElementById("footer");
	el.style.position = "static";
}

function closeTab() {
	hideCover(); 
	el = document.getElementById("menutabs");
	el.style.backgroundImage = "url(images/ptabs_allup.jpg)";
	for (k=1; k<=3; k++)
	{
		el = document.getElementById("tabMenu" + k);
		el.style.display = "none"; 
	}
	el = document.getElementById("footer");
	el.style.position = "absolute";

}

	
function showIdentify() {
	url = "index.php?n=enduser&o=identify2";
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showIdentify;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}


function _showIdentify() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
//		closeWait();
//		showOverlay();
		box(getXMLNode(ret));
	}
}

function showDownload(langs)  {
	pieces = langs.split(",");
	txt = "";
	txt += '<div class="xsmall-popup"> ';
	txt += '	<div class="login-close"> <a href="#self" onclick="closeWait();"><img src="images/icon_delte_up.gif" alt="close" name="closepop" width="21" height="21" border="0" id="closepop" onmouseover="MM_swapImage(\'closepop\',\'\',\'images/icon_delte_over.gif\',1)" onmouseout="MM_swapImgRestore()" /></a></div>';
	txt += '	<div class="small-popuptitle" style="padding:0 0 15px 30px;">Available Languages<br /></div>';
	txt += '	<table width="204" border="0" cellspacing="0" style="margin-left:60px;">';
	for (i = 0; i< pieces.length/2 ; i++)
	{
		txt += '<tr>';
		txt += '<td width="32" height="30" align="center" valign="middle">&nbsp;</td>';
		txt += '<td width="168" ><a class="popup-link" target="_blank" href="'+pieces[2*i+1]+'">'+pieces[2*i]+'</a></td>';
		txt += '</tr>';
	}
	txt += '	</table>';
	txt += '	<div class="small-popuptitle" style="padding:0 0 15px 30px;">&nbsp;<br /></div>';
	txt += '</div>';
//	showOverlay();
	showWait(txt);
}

function closePopups() {
	try
	{
		if (event && event.keyCode == 27) closeWait();
	}
	catch (ex)
	{
	}
}

function showAdvancedSearch() {
	txt = '';
	txt += ' <div class="advsrch-popup"> ';
	txt += ' <div class="login-close"> <a href="#self" onclick="closeWait()"><img src="images/icon_delte_up.gif" alt="close" name="closepop" width="21" height="21" border="0" id="closepop" onmouseover="MM_swapImage(\'closepop\',\'\',\'images/icon_delte_over.gif\',1)" onmouseout="MM_swapImgRestore()" /></a></div>';
	txt += ' <div class="advsrch-title">Advanced Search</div>';
	txt += ' <div class="advsrchtxt">Search all documents including their content.</div>';
	txt += ' <div class="advsrchfield"><input class="txtfield435-w" name="" type="text" id="txtSearch"/></div>';
	txt += ' <div class="login-bttn-row">';
	txt += ' <div class="bttn-advsrch"><a href="#self" onclick="doSearch();">Search</a></div> ';
	txt += ' </div></div>';
	showAlert(txt);	
//	box(txt);
}

function doSearch() {
	el = document.getElementById('txtSearch');
	url = "index.php?n=library&o=get_search&txt=" + el.value;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_doSearch;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _doSearch() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
		closeWait();
		el = document.getElementById("libraryContent");
		el.innerHTML = getXMLNode(ret);;
	}

}


function filterDocuments(ev, txt) {

	if (ev.keyCode != 0)
	{
		results = 0;
		txt = txt.toLowerCase();
		words = txt.split(" ");
		x = document.getElementsByTagName("table");
		
		for (i=0; i<x.length ; i++)
		{
			if (x[i].title == "docResults")
			{
				found = true;
				for (w in words)
				{
					if (x[i].id.search(words[w]) == -1)
					{
						found = false; break;
					}
				}
				if (!found) {
					x[i].style.display= "none";
				} else {
					x[i].style.display= "block";
					results ++;
				}
			}
		}
		el = document.getElementById('spanResults');
		el.innerHTML = parseInt(results);
	}
}


var contactsList = [];
var contactsIndex = [];
function showContacts(continentID) {
	return loadContacts(continentID);
}
function loadContacts(continentID) {
	url = "index.php?o=get_contacts&id=" + parseInt(continentID) + "&contact_type=" + getQueryVariable("contact_type");
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_loadContacts;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _loadContacts() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		x=response.getElementsByTagName("regionname");
		y=response.getElementsByTagName("regionid");
		z=response.getElementsByTagName("continentname");
		el = document.getElementById("CountryName");
		el.innerHTML = getXMLNode(z);
		el = document.getElementById("regionsList");
		el.options.length = 1;
		for (i=0; i<x.length; i++)
		{
			opt = new Option();
			opt.text= getXMLNode(x, i);
			opt.value= getXMLNode(y, i);
			el.options[el.options.length] = opt;
		}

		x=response.getElementsByTagName("typename");
		y=response.getElementsByTagName("typeid");
		el = document.getElementById("titlesList");
		el.options.length = 1;
		for (i=0; i<x.length; i++)
		{
			opt = new Option();
			opt.text= getXMLNode(x, i);
			opt.value= getXMLNode(y, i);
			el.options[el.options.length] = opt;
		}

		xid = response.getElementsByTagName("id");
		xname = response.getElementsByTagName("name");
		xtype = response.getElementsByTagName("contacttype");
		xregion = response.getElementsByTagName("location");
		xtypeid = response.getElementsByTagName("contacttypeid");
		xregionid = response.getElementsByTagName("locationid");
		xindex = response.getElementsByTagName("index");
		xcity = response.getElementsByTagName("city");
		contactsList = [];

		txt = "";
		for (i=0; i<xindex.length; i++)
		{
			txt += '<table style="width: 660px" cellspacing="0" cellpadding="0" class="contacts" id="contactsTable'+ i +'">';
			idx = parseInt(getXMLNode(xindex, i));
			contactsList[idx] = {id: parseInt(getXMLNode(xid, i)), typeid: parseInt(getXMLNode(xtypeid, i)), regionid: parseInt(getXMLNode(xregionid, i)), region: getXMLNode(xregion, i), name: getXMLNode(xname, i), type: getXMLNode(xtype, i), indexid: getXMLNode(xindex, i), city: getXMLNode(xcity, i)};
			txt += '<tr title="click to view full contact info" style="cursor: pointer;" onclick="showContact('+idx+')" onmouseover="highlightRow(this)" onmouseout="unhighlightRow(this)"><td width="200" align="left">'+getXMLNode(xregion, i)+'<br>Office location: ' + getXMLNode(xcity, i) + '</td><td width="200" align="left">'+getXMLNode(xtype, i)+'</td><td width="240" align="left">'+getXMLNode(xname, i)+'</td><td width="20" align="right"><img src="images/icon_info.gif"</td></tr>';
			txt += "</table>";
			contactsIndex[i] = [contactsList[idx].typeid, contactsList[idx].regionid, contactsList[idx].name.toLowerCase() + " " + contactsList[idx].region.toLowerCase() + " " + contactsList[idx].type.toLowerCase()];
		}
		el = document.getElementById("contactsDiv");
		el.innerHTML = txt;
		el3 = document.getElementById("contactFilter"); el3.value = "";
		el3 = document.getElementById("contactsArea"); el3.style.visibility = "visible";
		el.style.visibility = 'hidden';
		closeWait();
	}
}

function filterContactsByRegion() {
	maind = document.getElementById("contactsDiv");
	maind.style.visibility = 'visible';

	el1 = document.getElementById("regionsList"); regid = el1.options[el1.selectedIndex].value;
	el2 = document.getElementById("titlesList");titleid = el2.options[el2.selectedIndex].value;
	el3 = document.getElementById("contactFilter");
	for (i in contactsIndex)
	{
		el = document.getElementById("contactsTable" + i);
		if (contactsIndex[i][1] == regid || !regid)
		{
			if (!titleid || contactsIndex[i][0] == titleid || !titleid)
			{
				if (!el3.value || contactsIndex[i][2].search(el3.value.toLowerCase()) != -1)
				{
					if (el) el.style.display = "block";
				}
			}
		} else {
			if (el) el.style.display = "none";
		}
	}
	if (!regid && !titleid && !el3.value)
	{
		maind.style.visibility = 'hidden';
	}
}

function filterContactsByTitle() {
	maind = document.getElementById("contactsDiv");
	maind.style.visibility = 'visible';

	el1 = document.getElementById("regionsList"); regid = el1.options[el1.selectedIndex].value;
	el2 = document.getElementById("titlesList");titleid = el2.options[el2.selectedIndex].value;
	el3 = document.getElementById("contactFilter");
	for (i in contactsIndex)
	{
		el = document.getElementById("contactsTable" + i);
		if (contactsIndex[i][0] == titleid || !titleid)
		{
			if (!regid || contactsIndex[i][1] == regid || !regid)
			{
				if (!el3.value || contactsIndex[i][2].search(el3.value.toLowerCase()) != -1)
				{
					if (el) el.style.display = "block";
				}
			}
		} else {
			if (el) el.style.display = "none";
		}
	}

	if (!regid && !titleid && !el3.value)
	{
		maind.style.visibility = 'hidden';
	}
}

function filterContactsByTxt() {
	maind = document.getElementById("contactsDiv");
	maind.style.visibility = 'visible';

	el1 = document.getElementById("regionsList"); regid = el1.options[el1.selectedIndex].value;
	el2 = document.getElementById("titlesList");titleid = el2.options[el2.selectedIndex].value;
	el3 = document.getElementById("contactFilter");
	for (i in contactsIndex)
	{
		el = document.getElementById("contactsTable" + i);
		if (!el3.value || contactsIndex[i][2].search(el3.value.toLowerCase()) != -1)
		{
			if (!titleid || contactsIndex[i][0] == titleid || !titleid)
			{
				if (!regid || contactsIndex[i][1] == regid || !regid)
				{
					if (el) el.style.display = "block";
				}
			}
		} else {
			if (el) el.style.display = "none";
		}
	}

	if (!regid && !titleid && !el3.value)
	{
		maind.style.visibility = 'hidden';
	}
}

function showContact(index) {
	url = "index.php?o=get_contact&id=" + parseInt(contactsList[index].id) + "&regionid=" + parseInt(contactsList[index].indexid);
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showContact;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showContact() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
//		closeWait();
//		showOverlay();
		box(getXMLNode(ret));
		el = document.getElementById('contactsArea');
		el.style.visibility = 'hidden';
	}

}


function showNewsTab(tabID) {
	el = document.getElementById("newsList" + 1); el.style.display = "none";
	el = document.getElementById("newsList" + 2);el.style.display = "none";
	el = document.getElementById("newsList" + 3);el.style.display = "none";
	try
	{
		el = document.getElementById("articleTab");el.style.display = "none";
	}
	catch (ex)
	{
	}
	el = document.getElementById("newsList" + tabID);el.style.display = "block";
}

function showEventPopup(id) {
	url = "index.php?n=news&o=get_event&id=" + parseInt(id);
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showEventPopup;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showEventPopup() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
		box(getXMLNode(ret));
	}

}

function showImagePopup(image, wd, ht) {
	if (wd >= 800 || !wd) wd = 800;
	box("<div onclick='closeWait();'><div style='cursor: pointer; color: #000; padding: 2px 0px; font-size: 11px; '>click to close</div><img width=\""+wd+"\"  src='" +image+ "'></div>", wd, ht);
}

var  galImages = [];
function showImagePopup2(image, image2, wd, ht) {
//	if (wd >= 800 || !wd) wd = 800;
//	if (!ht || ht >= 600) ht = 600;
	txt  = "<div class='gallery-menu'>";
	for (i in galImages)
	{
		txt += " <img src='" + galImages[i].thumb + "' class='gallery-thumb' onclick='selectGalleryImage("+i+")'>";
	}
	txt += "</div>";
//	alert(wd);
	message2("<div style='text-align: center'>"+txt+"<a id=\"galleryMainLink\" href=\""+APP_CMS_PATH+"/download.php?t=3&file="+image2+"\"target=\"_blank\"><img  id=\"galleryMainImage\" width=\""+wd+"\"  src='" +image+ "'><br><br>"+HIGH_REZ_IMAGE+"</a></div>", wd, ht);
}

function selectGalleryImage(imgid) {
		el = document.getElementById("galleryMainImage");
		el.src =  galImages[imgid].path;
		el = document.getElementById("galleryMainLink");
		el.href = APP_CMS_PATH + '/download.php?t=3&file=' + galImages[imgid].mainimg;

}

function showLibraryProductSearch() {
	txt = '';
	txt += '<div class="login-popup"> ';
	txt += '<div class="login-close"> <a href="#"><img src="images/icon_delte_up.gif" alt="close" name="closepop" width="21" height="21" border="0" id="closepop" onmouseover="MM_swapImage(\'closepop\',\'\',\'images/icon_delte_over.gif\',1)" onmouseout="MM_swapImgRestore()" onclick="closeWait()" /></a></div>';
	txt += '<div class="login-title">Search documents by product</div>';
	txt += "<form name='frmDocSearch' id='frmDocSearch' action='index.php?n=library&o=products' method='post'>";
	txt += '<div class="login-row">';
	txt += '<div class="login-label">Search Product</div>';
	txt += '<div class="login-field-holder"><input class="login-field" name="txt" type="text" /> </div>';
	txt += '</div>';
	txt += '<div class="login-bttn-row">';
	txt += '<div class="bttn-eventpop"><a href="#self" onclick="el=document.getElementById(' + "'frmDocSearch'" + '); el.submit(); showWait(); ">Search</a></div> ';
	txt += '</div>';
	txt += '</form>';
	txt += '</div>';

	showWait(txt);
}

function showCover() {
	x = document.getElementById('content'); 
	if (!x)	x = document.getElementById('productcontent'); 
	y = document.getElementById('productsContainer'); 
	if (y && x)
	{
		y.style.display='block'; 
		y.style.height=(x.offsetHeight -110) + 'px'; 
		y.style.position='absolute'; 
		y.style.width='980px'; 
		y.style.left=findPosX(x) + 'px';
		y.style.top=findPosY(x) + 'px'; 
		y.style.left='0px';
		y.style.top='65px'; 
		y.style.backgroundColor = '#ccc'; 
		opacity(y, 97);
	}
}

function hideCover() {
	y = document.getElementById('productsContainer'); 
	if (y) y.style.display='none'; 

}

function showImagePopup(image, width, height) {
	txt = "<div style='width: "+width+"px; height: '" + height + ";'><img src='"+image+"' style='cursor: pointer; ' onclick='closeWait();'></div>";
	message(txt);
}

function loadApprovals(regionid) {
	url = "index.php?n=library&o=get_approvals&id=" + parseInt(regionid);
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_loadApprovals;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _loadApprovals() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret1=response.getElementsByTagName("content");
		ret2=response.getElementsByTagName("name");

		el=document.getElementById("divApprovalsList");
		el.innerHTML = getXMLNode(ret1);

		el=document.getElementById("regionName");
		el.innerHTML = getXMLNode(ret2);
		
		closeWait();
		showTab(selectedTab);

	}

}

function searchPanels() {
	el = document.getElementById("searchPanelField");
	url = "index.php?n=enduser&o=check_panels&txt=" + encode(el.value);
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_searchPanels;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _searchPanels() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("ret");
		ret = getXMLNode(ret);
		if (ret == "no")
		{
			closeWait();
			el = document.getElementById("searchPanelField");
			window.location='index.php?n=enduser&o=show_panels&txt=' + encode(el.value);
		} else {
			message(ret);
		}

	}

}

function playVideo(id) {
	txt = '<div style="width: 695px; height: 360px;">';
	txt += '        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="695" height="360">';
	txt += '          <param name="movie" value="swf/video.swf" />';
	txt += '          <param name="quality" value="high" />';
	txt += '          <param name="wmode" value="transparent" />';
	txt += '          <param name="FlashVars" value="id='+id+'" />';
	txt += '		  <param name="allowScriptAccess" value="sameDomain" />';
	txt += '          <embed src="swf/video.swf" FlashVars = "id='+id+'" quality="high" swliveconnect=true allowscriptaccess="sameDomain" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="695" height="360" ></embed>';
	txt += '        </object></div>';
	txt += "<p><center><a class='link-contact' href='#self' onclick='closeWait();'>close popup</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class='link-contact' href='index.php?o=play_video&id="+id+"' target='_blank'>play video in new window</a></center></p>";
	message2(txt);
}

function showSecurityVideo(lang) {
	txt = '<div style="width: 915px; height: 400px;">';
	txt += '        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="915" height="400">';
	txt += '          <param name="movie" value="swf/security_system_basics';
	if (lang) txt += '_' + lang;
	txt += '.swf" />';
	txt += '          <param name="quality" value="high" />';
	txt += '          <embed src="swf/security_system_basics';
	if (lang) txt += '_' + lang;
	txt += '.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="915" height="400"></embed>';
	txt += '        </object></div>';
	message(txt);
}

function showEmailProduct(id) {
	url = "index.php?n=products&o=get_email_form&id=" + encode(id);
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showEmailProduct;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showEmailProduct() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("ret");
		ret = getXMLNode(ret);
		message(ret);
	}
}

var preloadFlag = true;
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function disableFooter() {
//	el = document.getElementById("footer");
//	el.style.position = "static";
}
function updateRegStatus(obj) {
	el1 = document.getElementById('reseller'); 
	el2 = document.getElementById('dealer'); 
	el3 = document.getElementById('distributors'); 
	el1.style.display = 'none'; 
	el2.style.display = 'none'; 
	el3.style.display = 'none'; 
	if (obj.options[obj.selectedIndex].value==22) el2.style.display='block'; 
//	if (obj.options[obj.selectedIndex].value==24) el2.style.display='block';
//	if (obj.options[obj.selectedIndex].value==99) el2.style.display='block';
	if (obj.options[obj.selectedIndex].value==23) el1.style.display='block';
	if (obj.options[obj.selectedIndex].value==21) el3.style.display='block';
	el = document.getElementById('footer'); 
	el.style.position = 'static';

}

function checkRegistrationForm() {
	elem = document.getElementById("Email");
	obj2 = document.getElementById('frmRegister');
	if (validate(obj2)) {
		obj = document.getElementById('GroupID'); 
		retu = true;
		if (obj.options[obj.selectedIndex].value==22 && checkNullFields("Distributor,SalesRep,HowLong,InstallSecurityProducts,InstallFireProducts")) retu = false;
		if (obj.options[obj.selectedIndex].value==23 && checkNullFields("Distributor2,SalesRep2,HowLong2,ResellSecurityProducts,ResellFireProducts")) retu = false;
//		if (obj.options[obj.selectedIndex].value==24 && checkNullFields("Distributor,SalesRep,HowLong,HowMany")) retu = false;
//		if (obj.options[obj.selectedIndex].value==99 && checkNullFields("Distributor,SalesRep,HowLong,HowMany")) retu = false;
//		if (obj.options[obj.selectedIndex].value==23 && checkNullFields("MonitoringStation,Receiver,MoreInfoAboutSurgard")) retu = false;
		if (obj.options[obj.selectedIndex].value==21 && checkNullFields("Distributor3,SalesRep3")) retu = false;
		if (retu)
			verifyEmail(elem);
		else {
			message('Please fill all required fields'); 
			return false;
		}
	} else {
		return false;
	}
}

function _checkRegistrationForm(ret) {
	if (ret == "ok")
	{
			el = document.getElementById("frmRegister");
			el.submit();
	} else {
		el = document.getElementById("Email");
		txt = "<b>An username with this email address already exists!. <br><br>If you have forgot your password, please <a href='index.php?o=send_password&id="+encodeURIComponent(el.value)+"'>click here to have it sent to your email address</a>. <br>If you prefer to register with a different email address, please close this message and update the email address field";
		message(txt);
	}
}

var curHeadline = -1;
function showHeadlines() {
	el = document.getElementById('divHeadlines');
	el.innerHTML = headline[0];
	curHeadline ++;
	setTimeout(updateHeadline, 8000);

}

var curOpacity = 100;
var curOpacityDir = -1;
function updateHeadline() {
	el = document.getElementById('divHeadlines');
	curOpacity = curOpacity + curOpacityDir * 10;
	opacity(el, curOpacity);
	if (curOpacity <= 0 && curOpacityDir < 0)
	{
		curHeadline++;
		if (curHeadline == headline.length) curHeadline = 0;
		el.innerHTML = headline[curHeadline];
		curOpacityDir = 1;
		curOpacity = 0;
	}
	if (curOpacity >= 100 && curOpacityDir > 0)
	{
		setTimeout(updateHeadline, 2000);
		curOpacityDir = -1;
		curOpacity = 100;
		clearTimeout();
	} else {
		setTimeout(updateHeadline, 100);
	}
	

}

function openProfile() {
	el = document.getElementById("divProfile");
	Accordion1.openPanel(el);
}

function showBasket(basketID) {

	url = "index.php?n=library&o=get_basket&id=" + basketID;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showBasket;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showBasket() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
		ret = getXMLNode(ret);
		message4(ret);
	}
}

function shareBasket(basketID) {
	el = document.getElementById('shareArea');
	el.style.display = "block";
}

function doShareBasket(basketID) {
	el = document.getElementById('shareEmail');
	url = "index.php?n=library&o=share_basket&id=" + basketID + "&email=" + encode(el.value);
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_doShareBasket;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _doShareBasket() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
		ret = getXMLNode(ret);
		if (ret == "ok")
		{
			alert("Document package was shared succesfully!");
		} else {
			alert("There was a problem sharing this document package. Please try again!");	
		}
	}
}


function displayFeedback(msg) {
	showOverlay();
	url = "index.php?o=get_feedback_form&err=" + msg;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_displayFeedback;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _displayFeedback() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
		txt = getXMLNode(ret);
		box(txt);
		el = document.getElementById('fEmail');
		el.focus();
	}

}

function sendFeedback() {
	el = document.getElementById("fEmail");
	el2 = document.getElementById("fName");
	el3 = document.getElementById("fComments");
	el4 = document.getElementById("fPhone");

	if (!el.value)
	{
		alert("Please enter your email address!");
		return false;
	}

	if (!el2.value)
	{
		alert("Please enter your name!");
		return false;
	}

	if (!el3.value)
	{
		alert("Please enter your feedback!");
		return false;
	}
	url = "index.php?o=send_feedback&email=" + encode(el.value) + "&phone=" + encode(el4.value) + "&name=" + encode(el2.value) + "&comments=" + encode(el3.value);
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_sendFeedback;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	} 
}


function _sendFeedback() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		message2("<div style='color: #000; padding: 40px;'>Your comments have been received!</div>");
	}
}

function showAddToFolder(docid) {

	url = "index.php?n=library&o=get_folders&id=" + docid;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showAddToFolder;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showAddToFolder() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
		ret = getXMLNode(ret);
		message4(ret);
	}
}

function addToFolder(id, docid) {
	url ="index.php?n=library&o=add_to_folder&id="+id+"&docid=" + docid;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_addToFolder;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _addToFolder() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
//		ret2=response.getElementsByTagName("ret");
//		ret2 = getXMLNode(ret);
//		message(ret2);
		message("Document was added sucessfully!");
	}
}

function createFolder(docid) {
	el = document.getElementById("folderName");
	url ="index.php?n=library&o=add_to_folder&name="+encode(el.value)+"&docid=" + docid;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_addToFolder;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _addToFolder() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
//		ret2=response.getElementsByTagName("ret");
//		ret2 = getXMLNode(ret);
//		message(ret2);
		message("The folder was created sucessfully! The selected document was added to the new folder.");
	}
}



/* BENTEL STUFF */



var sliderLeft = 0;
var sliderCount = 4;
var slideInterval;
var slideTimer = 150;
var slideDirection = 0;
var slideStep = 0;
var slideSteps = 0;
var stepDuration = 10;
var slideLength = 0; //pixels
function slideLeft() {
	el = document.getElementById("slider");
	slideLength = -1 * (el.offsetWidth) + 590;
//	alert(slideLength);;

	if (sliderLeft>=-100) return false;
	slideDirection = 1;
	slideSteps = slideTimer/stepDuration;
	slideInterval = setInterval(slide, stepDuration);
}

function slideRight() {
	el = document.getElementById("slider");
	slideLength = -1 * (el.offsetWidth) + 590;
//	alert(slideLength);;
	
	slideDirection = -1;
	if (sliderLeft <= slideLength) return false;
	slideSteps = slideTimer/stepDuration;
	slideInterval = setInterval(slide, stepDuration);
}

function slide() {
	slideStep ++;
	if (slideStep > slideSteps)
	{
		slideStep = 0;
		clearInterval(slideInterval);
		return true;
	}
	increment = Math.abs(580) / slideSteps;
	el=document.getElementById('slider'); 
	sliderLeft = sliderLeft + increment * slideDirection;
	el.style.marginLeft= sliderLeft + 'px';
	
}

function navigateTo() {
	el = document.getElementById("homelink" + fadeCurrentImage);
	if (el.href == "#") return true;
	if (el.target == "_blank")
	{
		window.open(el.href, "nw", "");
	} else {
		window.location = el.href;
	}
	
}


var featuresCount = 3;
function selectProductFeature2(featureID) {
	for (i=1;i<=featuresCount ;i++ )
	{
		el = document.getElementById('productFeature' + i);
		if (el) el.style.display = 'none';
		el = document.getElementById('productFeatureMenu' + i);
		if (el) setClass(el, "inactive");
	}
	window.location.hash = "tab" + featureID;
	el = document.getElementById('productFeature' + featureID);
	el.style.display = 'block';
	el = document.getElementById('productFeatureMenu' + featureID);
	setClass(el, "active");
//	el = document.getElementById('productFeatureMenuTable');
//	el.style.backgroundImage = "url(images/tab-" +featureID +".jpg)";
	}

function selectProductFeature(featureID) {
	for (i=1;i<=featuresCount ;i++ )
	{
		el = document.getElementById('productFeature' + i);
		if (el) el.style.display = 'none';
		el = document.getElementById('productFeatureMenu' + i);
		if (el) setClass(el, "tab" + i);
	}
	window.location.hash = "tab" + featureID;
	el = document.getElementById('productFeature' + featureID);
	el.style.display = 'block';
	el = document.getElementById('productFeatureMenu' + featureID);
	setClass(el,  "tab" + featureID + "-active");
//	el = document.getElementById('productFeatureMenuTable');
//	el.style.backgroundImage = "url(images/tab-" +featureID +".jpg)";
	}

	var searchResultsCount = 0;
	var curResultHighlight = -1;
	function instantSearch(obj, e) {
		if (!e) var e = window.event;

		if (e.keyCode == 38) {
			for (i=0;i<= searchResultsCount;i++ )
			{
				el =document.getElementById('searchResult' + i);
				if (el) setClass(el, "inactive");
			}
			curResultHighlight --;
			if (curResultHighlight  < 0) curResultHighlight = searchResultsCount - 1;
			el =document.getElementById('searchResult' + curResultHighlight);
			if (el) setClass(el, "active");
			return false;
		}
		if (e.keyCode == 40) {
			for (i=0;i<= searchResultsCount;i++ )
			{
				el =document.getElementById('searchResult' + i);
				if (el) setClass(el, "inactive");
			}
			curResultHighlight ++;
			if (curResultHighlight  > searchResultsCount -1) curResultHighlight = 0;
			el =document.getElementById('searchResult' + curResultHighlight);
			if (el) setClass(el, "active");
			return false;
		}
		searchResultsCount = 0;
		list = ""; 
		srcwhat = obj.value.toLowerCase();
		k = 0;
		for (i = 0; i < srchelp.length; i++)
		{
			if (srchelp[i][2].search(srcwhat) >= 0)
			{
				if (e.keyCode == 13 && curResultHighlight == k) {
					window.location = 'index.php?n=products&o=view&id=' + srchelp[i][0];
					return true;
				}

				list += "<a id=\"searchResult"+k+"\" href=\"index.php?n=products&o=view&id="+srchelp[i][0]+"\">"+ srchelp[i][1] + "</a>";
				searchResultsCount ++;
				k++;
			}
			if (searchResultsCount >= 10) break;
		}
			el = document.getElementById('srcresults');
			el.style.display = "block";
			el.innerHTML = '<img src="images/transparent.gif" width="180" height="1">' + list;
	}


	function showEULA(id) {

	url = "index.php?o=get_eula&id=" + id;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showEULA;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showEULA() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
//		closeWait();
//		showOverlay();
		message2(getXMLNode(ret));
	}

}


function downloadSoftware(id) {
	el = document.getElementById("EULA1");
	el2 = document.getElementById("EULA2");
	if (!el.checked || !el2.checked)
	{
		alert("You must accept the terms of agreement!");
		return false;
	}
	window.open(APP_CMS_PATH + "download.php?t=2&id=" + id ,"nw", "");
}

function showContactsNew(obj, italyonly) {
	
	url = "index.php?o=get_contacts_new&location=" + obj.value + "&italy="  + italyonly;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showContactsNew;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function showContactsNew2(obj, italyonly) {
	
	el = document.getElementById("LocationPlace");
	el.innerHTML = obj.options[obj.selectedIndex].text;
	url = "index.php?o=get_contacts_new2&location=" + obj.value + "&italy="  + italyonly;
	initObj();
	showWait();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showContactsNew;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showContactsNew() {
	closeWait();
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("content");
		closeWait();
//		showOverlay();
		el = document.getElementsByName("contactRegions");
		el[0].selectedIndex = -1;
		el[1].selectedIndex = -1;
		

		el = document.getElementById("results");
		el.innerHTML = getXMLNode(ret);

		ret = response.getElementsByTagName("location");
		for (i=0; i<ret.length ;i++ )
		{
			ret0 = response.getElementsByTagName("locationid");
			ret1 = response.getElementsByTagName("locationc1");
			ret2 = response.getElementsByTagName("locationc2");

			mid = getXMLNode(ret0, i);
			c1 = getXMLNode(ret1, i);
			c2  = getXMLNode(ret2, i);
			if (mid && c1 && c2)
			{
				showMap("contactMap" + mid, c1, c2);
			}
			
		}
	}

}

function showProductsSubmenu() {
	el = document.getElementById('productsSubmenu');
	if (el) el.style.display = "block";

}

function hideProductsSubmenu() {
	el = document.getElementById('productsSubmenu');
	if (el) el.style.display = "none";
}

function showContactSubmenu() {
	el = document.getElementById('contactSubmenu');
	if (el) el.style.display = "block";

}

function hideContactSubmenu() {
	el = document.getElementById('contactSubmenu');
	if (el) el.style.display = "none";
}

function submitSurvey() {
	for (i=1; i<=15; i++)
	{
		el = document.getElementsByName('QuestionID_' + i);
		ck = false;
//		alert(el.length);
//		return false;
		for (k = 0; k< el.length ;k++ )
		{
			if (el[k].checked)
			{
				ck =true;
				break;
			}
		}
		if (!ck)
		{
			alert("We're sorry, but in order to maintain the survey integrity, all questions are mandatory! ");
			return false;
		}
	}

	el = document.getElementById('frmSurvey');
	el.submit();
}
