//var clientPC = navigator.userAgent.toLowerCase(); // Get client info
//var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
//                && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1));
//var is_safari = ((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1));
//var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ));
//if (clientPC.indexOf('opera')!=-1) {
//    var is_opera = true;
//    var is_opera_preseven = (window.opera && !document.childNodes);
//    var is_opera_seven = (window.opera && document.childNodes);
//}

function hov(loc,cls){
	if(loc.className)
	loc.className=cls;
}


function OpenCertDetails()
{
	thewindow = window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=DEPREY1', 'anew', config='height=400,width=450,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}
function openPicture(w,h,img,title) {
	props = 'width='+w+', height='+h+', left=0, top=0, toolbar=no, menubar=no, status=no, location=no, scrollbars=no, resizable=no';
	window.open('/picbox.php?title='+title+'&imf='+img, 'Picture', props);
}
function openPopupHelp(w,h,pagename,section,lang) {
	page='/help.php?pagename='+pagename+'&lang='+lang+'#'+section;
	props = 'width='+w+', height='+h+', left=0, top=0, toolbar=no, menubar=no, status=no, location=no, scrollbars=yes, resizable=yes';
	ow=window.open(page, 'Help', props);
	ow.focus();
}
function openPopup(w,h,key,title) {
	props = 'width='+w+', height='+h+', left=0, top=0, toolbar=no, menubar=no, status=no, location=no, scrollbars=yes, resizable=yes';
	ow=window.open('/preview.php?title='+title+'&p='+key, 'Preview', props);
	ow.focus();
}
function openPopupT(w,h,key) {
	props = 'width='+w+', height='+h+', left=0, top=0, toolbar=no, menubar=no, status=no, location=no, scrollbars=yes, resizable=yes';
	page='/test.php?p='+key;
	ow=window.open(page, 'Test', props);
	ow.focus();
}
function openPopupQ(w,h,key,title) {
	props = 'width='+w+', height='+h+', left=0, top=0, toolbar=no, menubar=no, status=no, location=no, scrollbars=yes, resizable=yes';
	ow=window.open('/preview_question.php?title='+title+'&p='+key, 'Preview', props);
	ow.focus();
}
function openPopupGen(url,w,h,title) {
	props = 'width='+w+', height='+h+', left=0, top=0, toolbar=no, menubar=no, status=no, location=no, scrollbars=yes, resizable=yes';
	ow=window.open(url, title, props);
	ow.focus();
}
function doityes(msg) {
	var truthBeTold = window.confirm(msg);
	if (truthBeTold) {
		return true;
	}
	return false;
}
function doit() {
	document.echoq.submit();
}
function doittypechange() {
//	form = document.getElementById('echoq');
//	len = document.getElementById('length');
//	prec = document.getElementById('precise');
//	len.value=0;
//	prec.value=0;
//	form.submit();
	document.echoq.length.value=0;
	document.echoq.precise.value=0;
	document.echoq.refresh.value=1;
	document.echoq.submit();
}

function swap(src, dst) {
	document.echoq.src.value=src;
	document.echoq.dst.value=dst;
	document.echoq.submit();
}
function acton(qn, val) {
	document.echoq.qid.value=qn;
	document.echoq.actionafter.value=val;
	document.echoq.dact.value=1;
	document.echoq.submit();
}
function actony(qn, val) {
	document.echoq.qid.value=qn;
	document.echoq.actionafter.value=val;
	document.echoq.dacty.value=1;
	document.echoq.submit();
}
function actonn(qn, val) {
	document.echoq.qid.value=qn;
	document.echoq.actionafter.value=val;
	document.echoq.dactn.value=1;
	document.echoq.submit();
}
function actonchoice(chid, val) {
	document.echoq.chid.value=chid;
	document.echoq.actionafter.value=val;
	document.echoq.dactc.value=1;
	document.echoq.submit();
}
function remove(qid) {
	document.echoq.elements['tab'].value='order';
	document.echoq.qid.value=qid;
	document.echoq.dst.value=-1;
	document.echoq.submit();
}
function editq(num) {
	document.echoq.elements['tab'].value='question';
	document.echoq.qid.value=num;
	document.echoq.submit();
	return false;
}
function copyq(num) {
	document.echoq.elements['tab'].value='order';
	document.echoq.qid.value=num;
	document.echoq.dact.value=99;
	document.echoq.submit();
	return false;
}
function newq(num) {
	document.echoq.elements['tab'].value='question';
	document.echoq.q.value='q';
	document.echoq.submit();
	return false;
}
function addsubq(val,parent,choice) {
	document.echoq.elements['tab'].value='question';
	document.echoq.q.value=val;
	document.echoq.qp.value=parent;
	document.echoq.qc.value=choice;
	document.echoq.submit();
	return false;
}

function MM_displayStatusMsg(msgStr) { //v1.0
	status=msgStr;
	document.MM_returnValue = true;
}

//var StoreLang;

function EnableNextSelector(obj)
{

	if (obj.name == "selection1")
	{
		//for (i = 0; i < document.templateselector2.selection2.options.length; i++)
		//document.templateselector2.selection2.remove[i];
		document.templateselector2.selection2.options.length = 0;
		var x = obj.selectedIndex;
		var y = LangOptions[x];
		var z = Cat1Options[y];
		x = z.length;
		for (i=0; i < x-1; i++)
		document.templateselector2.selection2.options[i]=  new Option (Cat1Options[y][i]);
		document.templateselector2.selection2.disabled=false;
		document.templateselector3.selection3.disabled=true;
		document.templateselector4.selection4.disabled=true;
		document.templateselector5.selection5.disabled=true;
		document.templatechoiceform.templatechoicebutton.disabled=true;

		StoreLang = y;
	}

	if (obj.name == "selection2")
	{
		document.templateselector3.selection3.options.length = 0;
		var x = obj.selectedIndex;
		var y = document.templateselector2.selection2.options[obj.selectedIndex].text
		var z = Cat2Options[y];
		x = z.length;
		for (i=0; i < x-1; i++)
		document.templateselector3.selection3.options[i]=  new Option (Cat2Options[y][i]);
		document.templateselector3.selection3.disabled=false;
		document.templateselector4.selection4.disabled=true;
		document.templateselector5.selection5.disabled=true;
		document.templatechoiceform.templatechoicebutton.disabled=true;
	}

	if (obj.name == "selection3")
	{
		document.templateselector4.selection4.options.length = 0;
		var x = obj.selectedIndex;
		var y = document.templateselector3.selection3.options[obj.selectedIndex].text
		var z = Cat3Options[y];
		x = z.length;
		for (i=0; i < x-1; i++)
		document.templateselector4.selection4.options[i]=  new Option (Cat3Options[y][i]);
		document.templateselector4.selection4.disabled=false;
		document.templateselector5.selection5.disabled=true;
		document.templatechoiceform.templatechoicebutton.disabled=true;
	}

	if (obj.name == "selection4")
	{
		document.templateselector5.selection5.options.length = 0;
		var x = obj.selectedIndex;
		var y = document.templateselector4.selection4.options[obj.selectedIndex].text
		var z = TemplateOptions[y];
		x = z.length;
		for (i=0; i < x-1; i++)
		document.templateselector5.selection5.options[i]=  new Option (TemplateOptions[y][i]);
		document.templateselector5.selection5.disabled=false;
		document.templatechoiceform.templatechoicebutton.disabled=true;
	}

	if (obj.name == "selection5")
	{
		/*var FinalChoice = StoreLang
		+ " # "  + document.templateselector2.selection2.options[document.templateselector2.selection2.selectedIndex].text
		+ " # " + document.templateselector3.selection3.options[document.templateselector3.selection3.selectedIndex].text
		+ " # " + document.templateselector4.selection4.options[document.templateselector4.selection4.selectedIndex].text
		+ " # " + document.templateselector5.selection5.options[document.templateselector5.selection5.selectedIndex].text;*/

		FinalChoice = TemplateOptionSID[document.templateselector5.selection5.options[document.templateselector5.selection5.selectedIndex].text];
		FinalChoice = FinalChoice.slice(0,FinalChoice.length-1);

		document.templatechoiceform.where.value    = "new";
		document.templatechoiceform.sid.value      = FinalChoice;
		document.templatechoiceform.new_state.value = "copy";

		document.templatechoiceform.templatechoicebutton.disabled=false;
	}
}
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('content').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
			}
			else {
				footerElement.style.top = '0px';
			}
		}
	}
}

function setMailingOptions(obj)
{
	if (obj.name == "s2_radio3")
	{
		if (document.mailform.s2_radio3.checked==true)
		{
			document.mailform.s2_edit_nonrespondents.disabled=false;
			document.mailform.s2_radio1.checked=false;
			document.mailform.s2_radio2.checked=false;
		}
		else
		{
			document.mailform.s2_edit_nonrespondents.disabled=true;
			document.mailform.s2_radio3.checked=false;
			document.mailform.s2_radio1.checked=true;
			document.mailform.s2_radio2.checked=true;
		}
	}
	if (obj.name == "s2_radio1" || obj.name == "s2_radio2" )
	{
		if(document.mailform.s2_radio1.checked==false && document.mailform.s2_radio2.checked==false)
		{			
			document.mailform.s2_edit_nonrespondents.disabled=false;
			document.mailform.s2_radio1.checked=false;
			document.mailform.s2_radio2.checked=false;
			document.mailform.s2_radio3.checked=true;
		}
		else
		{
			document.mailform.s2_edit_nonrespondents.disabled=true;
			document.mailform.s2_radio3.checked=false;
		}
	}
}