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) {

	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">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="login-row">';
	txt += '<div class="login-label">Please note: Extended Site Access is for Authorized DSC Dealers only.</div> ';
	txt += '</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 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="login-row">';
	txt += '<div style="padding: 20px 10px 0px 10px">Please note: Extended Site Access is for Authorized DSC Dealers only.</div> ';
	txt += '</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);
	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");
	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) {
	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">Retrieve Password </div>';
	if (msg) txt += '<div class="login-error">' + msg +  ' </div>';
	txt += '<div class="login-row">';
	txt += '<div class="login-label">Email</div>';
	txt += '<div class="login-field-holder"><input class="login-field" id="email" type="text" /> </div>';
	txt += '</div>';
	txt += '<div class="login-bttn-row">';
	txt += '<div class="bttn-eventpop"><a href="#self" onclick="forgot();">Retrieve</a></div> ';
	txt += '</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>';
	showAlert(txt);
}

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";
	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);
}

function showImagePopup2(image, image2, wd, ht) {
	if (wd >= 800 || !wd) wd = 800;
	if (!ht || ht >= 800) ht = 800;
	message2("<div style='text-align: center'><a href=\"http://cms.dsc.com/download.php?t=3&file="+image2+"\"target=\"_blank\"><img width=\""+wd+"\"  src='" +image+ "'><br><br>Download High Resolution Image</a></div>", wd, ht);
}

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('monitoring'); 
	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,HowMany")) 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("Distributor2,SalesRep2")) 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);
}