

/* ADDS STYLESHEET FOR MOZILLA */
var detect = navigator.userAgent.toLowerCase(); 
var OS,browser,version,total,thestring; 

if (checkIt('konqueror')) 
{ 
browser = "Konqueror"; 
} 
else if (checkIt('msie')) browser = "ie"; 
else if (!checkIt('compatible')) 
{ 
browser = "Netscape" 
version = detect.charAt(8); 
} 
else browser = "unknown browser"; 

function checkIt(string) 
{ 
place = detect.indexOf(string) + 1; 
thestring = string; 
return place; 
} 
if (browser == "Netscape")
{
document.write('<link rel="stylesheet" type="text/css" href="/css/style_moz.css">'); 
}


/*  Explorer-fix  */
function ExplorerFix() 
{ for (a in document.links) document.links[a].onfocus =
document.links[a].blur; 
}
if(document.all) document.onmousedown = ExplorerFix;


/*  Preload function  */
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/*  PopUp functions  */
function popUp(url,width,height,marginTop,marginLeft,scrollBar)
{
newWindow = window.open(url,'newwindow',
'width=' + width +
',height=' + height +
',toolbar=no,directories=no,status=no,resize=no,menubar=no' +
',top=' + marginTop +
',left=' + marginLeft +
',scrollbars=' + scrollBar);
}


function popSite(url,width,height,marginTop,marginLeft,scrollBar)
{
newWindow = window.open(url,'newwindowsite',
'width=' + width +
',height=' + height +
',toolbar=no,directories=no,status=no,resize=no,menubar=no' +
',top=' + marginTop +
',left=' + marginLeft +
',scrollbars=' + scrollBar);
}

/*  Mouse-over function  */

// changeImage
function changeImage(id,theImage)
	{	
	if (document.images) 
		{
		document.images[id].src=(theImage); 
		}
	}
//getObject,show and hide belong together
function getObject(obj){ 
var theObj; 
if(document.all) theObj = eval('document.all.'+ obj +'.style'); 
if(document.layers) theObj = eval('document.'+ obj); 
if(document.getElementById) theObj = document.getElementById(obj).style; 
return theObj; 
} 
//function show
function show(obj){ 
var theObj = getObject(obj); 
theObj.visibility = 'visible'; 
} 
//function hide
function hide(obj){ 
var theObj = getObject(obj); 
theObj.visibility = 'hidden'; 
} 


function changeImgLayer(id,theImage)
	{	
	if (is.nav) {
		document.mape.document.images[id].src=(theImage); 
		}
		if (is.ie) {
		document.images[id].src=(theImage);
		}
	}
	
//nav rollover
	function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

// Functions that swaps down images
function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

// Functions that swaps images
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// Freetextbox wordclean function

function FtbWordClean(el) {
	var text = el.designEditor.document.body.innerHTML;
	
	text=text.replace(/<FONT[^>]*>/gi,"");
	text=text.replace(/<\/FONT>/gi,"");
	text=text.replace(/<U>/gi,"");
	text=text.replace(/<\/U>/gi,"");
	text=text.replace(/<H[^>]*>/gi,"");
	text=text.replace(/<\/H[^>]*>/gi,"");
	
	// Change these tags.
	text=text.replace(/<BR[^>]*>/gi,"&singlebreak");
	
	text=text.replace(/<B[^>]*>/gi,"&bold");
	text=text.replace(/<\/B[^>]*>/gi,"&cbold");
	text=text.replace(/<STRONG[^>]*>/gi,"&bold");
	text=text.replace(/<\/STRONG[^>]*>/gi,"&cbold");

	text=text.replace(/<I[^>]*>/gi,"&ital");
	text=text.replace(/<\/I[^>]*>/gi,"&cital");
	text=text.replace(/<EM[^>]*>/gi,"&ital");
	text=text.replace(/<\/EM[^>]*>/gi,"&cital");
	
	text=text.replace(/<UL[^>]*>/gi,"&ultag");
	text=text.replace(/<LI[^>]*>/gi,"&litag");
	text=text.replace(/<OL[^>]*>/gi,"&oltag");
	text=text.replace(/<\/OL>/gi,"&olctag");
	text=text.replace(/<\/LI>/gi,"&lictag");
	text=text.replace(/<\/UL>/gi,"&ulctag");
	

	text=text.replace(/<P[^>]*>/gi,"&parag");
	text=text.replace(/<\/P>/gi,"&cparag");
	
	/*
	text=text.replace(/”/gi,'\"');
	text=text.replace(/“/gi,'\"');
	text=text.replace(/„/gi,'\"');
	text=text.replace(/mailto:/gi,'\"');
	text=text.replace(/Ä/g,"&Auml;");
	text=text.replace(/Ö/g,"&Ouml;");
	text=text.replace(/Ü/g,"&Uuml;");
	text=text.replace(/ä/g,"&auml;");
	text=text.replace(/ö/g,"&ouml;");
	text=text.replace(/ü/g,"&uuml;");
	text=text.replace(/ß/gi,"&szlig;");	
	*/
	
	text=text.replace(/&lt;[^>]&gt*;/gi,"");
	text=text.replace(/&lt;\/[^>]&gt*;/gi," ");
	text=text.replace(/<o:[^>]*>/gi,"");
	text=text.replace(/<\/o:[^>]*>/gi,"");
	text=text.replace(/<\?xml:[^>]*>/gi,"");
	text=text.replace(/<\/?st[^>]*>/gi,"");
	text=text.replace(/<[^>]*</gi,"<");
	text=text.replace(/<SPAN[^>]*>/gi,"");
	text=text.replace(/<SPAN[^class]*>/gi,"");
	text=text.replace(/<\/SPAN>/gi,"");
	//text=text.replace(/<\/A>/gi,"");
	
	// Clear the inner parts of other tags.
	text=text.replace(/style=[^>]*"/g,' ');
	text=text.replace(/style=[^>]*'/g," ");
	text=text.replace(/style=[^>]*>/g,">");
	text=text.replace(/lang=[^>]*>/g,">");
	text=text.replace(/name=[^>]* /g,"");
	text=text.replace(/name=[^>]*>/g,">");
	//text=text.replace(/<A[^>]*>/g,"");
	
	//text=text.replace(/<p[^>]*>/gi,"<p>");

	
	// Put the tags back
	text=text.replace(/&singlebreak/g,"<BR>");
	
	text=text.replace(/&bold/g,"<B>");
	text=text.replace(/&cbold/g,"</B>");

	text=text.replace(/&ital/g,"<EM>");
	text=text.replace(/&cital/g,"</EM>");

	text=text.replace(/&ultag/g,"<UL>");
	text=text.replace(/&litag/g,"<LI>");
	text=text.replace(/&oltag/g,"<OL>");
	text=text.replace(/&olctag/g,"<\/OL>");	
	text=text.replace(/&lictag/g,"<\/LI>");
	text=text.replace(/&ulctag/g,"<\/UL>");

	text=text.replace(/&parag/g,"<P>");
	text=text.replace(/&cparag/g,"</P>");
	
	el.designEditor.document.body.innerHTML = text;
};

///xmlhttp requersts


function getXmlHttpPrefix() {
	if (getXmlHttpPrefix.prefix)
		return getXmlHttpPrefix.prefix;
	
	var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
	var o;
	for (var i = 0; i < prefixes.length; i++) {
		try {
			// try to create the objects
			o = new ActiveXObject(prefixes[i] + ".XmlHttp");
			return getXmlHttpPrefix.prefix = prefixes[i];
		}
		catch (ex) {};
	}
	
	throw new Error("Could not find an installed XML parser");
}

// XmlHttp factory
function XmlHttp() {}

XmlHttp.create = function () {
	try {
		if (window.XMLHttpRequest) {
			var req = new XMLHttpRequest();
			
			// some versions of Moz do not support the readyState property
			// and the onreadystate event so we patch it!
			if (req.readyState == null) {
				req.readyState = 1;
				req.addEventListener("load", function () {
					req.readyState = 4;
					if (typeof req.onreadystatechange == "function")
						req.onreadystatechange();
				}, false);
			}
			
			return req;
		}
		if (window.ActiveXObject) {
			return new ActiveXObject(getXmlHttpPrefix() + ".XmlHttp");
		}
	}
	catch (ex) {}
	// fell through
	throw new Error("Your browser does not support XmlHttp objects");
};



function loadTextSync(sUri) {
   var xmlHttp = XmlHttp.create();
   var async = false;
   xmlHttp.open("GET", sUri, async);
   xmlHttp.send(null);
   return xmlHttp.responseText; // responseText : String
}

function loadSubCategories(id)
{
    return loadTextSync('/GetSubCategories.ashx?mainid=' + id);
}



    
    function closeContentDiv()
    {
        var el = document.getElementById('popUpContent');
        el.style.display = 'none';
        currentShownDiv = '';
    }
    function showContentDiv(content, title)
    {
        var el = document.getElementById('popUpContent');
        content = WrapContent(content, title);
        el.innerHTML = content;
        el.style.display = 'block';
    
    }
    function WrapContent(content, title)
    {
        var header = '<div class="header_related" style="margin-bottom:5px;"><div style="float:left">' + title + '</div><div style="text-align:right"><a href="javascript:closeContentDiv()" style="color:white">x</a>&nbsp;</div></div>';
        var footer = '<br><br><div style="text-align:right;widht:100%;"><a href="javascript:closeContentDiv()">Close</a></div>';
        
        return header + content + footer;
    }
    function toggleDiv(elid)
    {
        var el = document.getElementById(elid);
        if (el != null)
        {
            if (el.style.display == 'block')
            {
                el.style.display = 'none';
            }
            else
            {
                el.style.display = 'block';
            }
        }        
    }
    function showDiv(elid)
    {
        var el = document.getElementById(elid);
        if (el != null)
        {
            el.style.display = 'block';
        }        
        enableValidators(el.childNodes, true);
    }
    function hideDiv(elid)
    {
        var el = document.getElementById(elid);
        if (el != null)
        {
            el.style.display = 'none';
        }    
        enableValidators(el.childNodes, false);    
        
    }
    function enableValidators(children, enable)
    {
        if (children != null)
        {
            for(var i=0; i< children.length;i++)
            {
                if(children[i].controltovalidate != null)
                {
                    ValidatorEnable(children[i], enable);
                  //  alert(children[i].id);
                }
                enableValidators(children[i].childNodes, enable);
            }
            
        }
    }

var FTB_LinkPopUpHtml = new String("\
<html><body> \
<head>\
<title>Link Editor</title>\
<style type='text/css'>\
html, body { \
	background-color: #ECE9D8; \
	color: #000000; \
	font: 11px Tahoma,Verdana,sans-serif; \
	padding: 0px; \
} \
body { margin: 5px; } \
form { margin: 0px; padding: 0px;} \
table { \
  font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
  margin-top: 5px; \
  margin-bottom: 5px; \
} \
h3 { margin: 0; margin-top: 4px;  margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
button { width: 75px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
.space { padding: 2px; } \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
.f_title { text-align:right; }\
.footer { border-top:2px solid #90A8F0; padding-top: 3px; margin-top: 4px; text-align:right; }\
</style>\
<script type='text/javascript'>\
function insertLink() {\
	ftb = window.launchParameters['ftb'];\
	link = ftb.GetNearest('a');\
	href = document.getElementById('link_href');\
	if (href.value == '') {\
		alert('You must enter a link');\
		return false;\
	}\
	if (!link) {\
		ftb.ExecuteCommand('createlink',null,href.value);\
		link = ftb.GetNearest('a');\
	}\
	updateLink(link);\
}\
function updateLink(link) {\
	if (link) {\
		href = document.getElementById('link_href');\
		title = document.getElementById('link_title');\
		target = document.getElementById('link_target');\
		cssClass = document.getElementById('link_cssClass');\
		targetVal = target.options[target.selectedIndex].value;\
		customtarget = document.getElementById('link_customtarget');\
		link.href = href.value;\
		link.title = title.value;\
		link.className = cssClass.value;\
		if (targetVal == '_custom') link.target = customtarget.value; else link.target = targetVal;\
	}\
}\
function link_target_changed() {\
	list = document.getElementById('link_target');\
	customtarget = document.getElementById('link_customtarget');\
	if (list.options[list.options.selectedIndex].value == '_custom')\
		customtarget.style.display = '';\
	else\
		customtarget.style.display = 'none';\
}\
</script>\
</head>\
<body>\
<form action=''> \
<h3>Link Editor</h3> \
<fieldset><legend>Link Properties</legend><table>\
<tr><td class='f_title'>URL</td>\
<td><input type='text' id='link_href' style='width:250px;' /></td></tr>\
<tr><td class='f_title'>Title</td>\
<td><input type='text' id='link_title' style='width:250px;' /></td></tr>\
<tr><td class='f_title'>Target</td>\
<td><select id='link_target' style='width:150px;' onchange='link_target_changed();'>\
<option value=''>None</option>\
<option value='_blank'>New Window (_blank)</option>\
<option value='_top'>Top Frame (_top)</option>\
<option value='_parent'>Parent Frame (_parent)</option>\
<option value='_self'>Same Frame (_self)</option>\
<option value='_custom'>Custom Target</option>\
</select>&nbsp;\
<input type='text' id='link_customtarget' style='width:95px;display:none;' /> \
</td></tr>\
<tr style='display:none;'><td class='f_title'>Class</td>\
<td><input type='text' id='link_cssClass' style='width:250px;' /></td></tr>\
</table>\
</fieldset>\
<div class='footer'>\
<button type='button' name='insertLinkButton' id='insertLinkButton' onclick='insertLink();window.close();'>OK</button>\
<button type='button' name='cancel' id='cancelButton' onclick='window.close();'>Cancel</button>\
</div>\
<script type='text/javascript'>\
function load() {\
	ftb = window.launchParameters['ftb'];\
	link = ftb.GetNearest('a');\
	href = document.getElementById('link_href');\
	title = document.getElementById('link_title');\
	target = document.getElementById('link_target');\
	customtarget = document.getElementById('link_customtarget');\
	cssClass = document.getElementById('link_cssClass');\
	if (link) {\
		href.value = link.href;\
		title.value = link.title;\
		cssClass.value = link.className;\
		if (link.target == '' || link.target == '_blank' || link.target == '_top' || link.target == '_self' || link.target == '_parent')\
			window.opener.FTB_SetListValue(target,link.target,true);\
		else\
			window.opener.FTB_SetListValue(target,'_custom',false);\
		\
		if (target.options[target.options.selectedIndex].value == '_custom') {\
			customtarget.style.display='';\
			customtarget.value = link.target;\
		}\
	}\
}\
</script>\
</form> \
</body> \
</html>");


function CreateLink2(el) {
	// impliment pro feature of PopUp window
	
	var linkWin = window.open("","linkWin","width=350,height=155");
	if (linkWin) {
		linkWin.focus();
	} else {
		alert("Please turn off your PopUp blocking software");
		return;
	}
	
	linkWin.document.body.innerHTML = '';
	linkWin.document.open();	
	linkWin.document.write(FTB_LinkPopUpHtml);
	linkWin.document.close();	
	
	launchParameters = new Object();
	launchParameters['ftb'] = el;
	linkWin.launchParameters = launchParameters;
	linkWin.load();
};    

function ShowHidePublicationYearMax(selectedValue) {
    var _publicationYearMax = document.getElementById("PublicationYearMax");
        
    if (_publicationYearMax.style.display == "none" && selectedValue == "Between") {
        _publicationYearMax.style.display = "inline";
    } else {
        _publicationYearMax.style.display = "none";
    }
}