// -----------------------------------------------------------------------------
// Admin
// -----------------------------------------------------------------------------



function showAbout(version, edition, language) {
  alert("NOVUS " + edition + " Edition " + "(" + language + ") - version " + version +" - copyright 1999-2007 Laboremus Software AS")
}



// -----------------------------------------------------------------------------
// Forum
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// Search through source string and remove characters contained in 'exludeChars'
// -----------------------------------------------------------------------------
function filterExclude(source, excludeChars) {
 	var r = "";
	var s = source;
	var i, c;

	for (i = 0; i < s.length; i++) {
		c = s.charAt(i);
		if (excludeChars.indexOf(c) == -1) r += c;
	}
	return r;
}

// -----------------------------------------------------------------------------
// Check if input is empty or only contains blanks
// -----------------------------------------------------------------------------
function isBlank(el) {
	var s = el.value;
	s = filterExclude(s, " ");
	return s.length <= 0;
}


// -----------------------------------------------------------------------------
// Check input fields of the message form
// -----------------------------------------------------------------------------
function checkMessageInputFields(form, language) {

        var alertMsg

	switch (language) {
	  case 1:
	    alertMsg = "You must complete the fields: \n";
	    break;
	  otherwise:
	    alertMsg = "Du må fylle ut feltene: \n";
	    break;
        }	 

	var valid = true;

	if (isBlank(form.msg_subject)) {
	     valid = false;
 	     alertMsg += "\n- " + form.msg_subject.title;
	}

	if (isBlank(form.msg_first_name)) {
	     valid = false;
 	     alertMsg += "\n- " + form.msg_first_name.title;
	}

	if (isBlank(form.msg_body)) {
	     valid = false;
 	     alertMsg += "\n- " + form.msg_body.title;
	}

	if (!valid) alert(alertMsg);

	return valid;
}



// -----------------------------------------------------------------------------
// ActiveX
// -----------------------------------------------------------------------------


// After a copyright dispute IE needs a confirmation before allowing ActiveX objects to run on a webpage 
// .. ... unless it's included in a javascript file.

function printFlash(strFile, intWidth, intHeight, strAlign, strURL, strTarget, strDescription) {
  document.write(genFlash(strFile, intWidth, intHeight, strAlign, strURL, strTarget, strDescription));
} // printFlash


function genFlash(strFile, intWidth, intHeight, strAlign, strURL, strTarget, strDescription) {
	 var	strFlash;
	 var	strWidthAttribute, strHeightAttribute, strAlignAttribute, strAltAttribute;
	 var	strTargetAttribute;
	 var    strQuery;

	 var strLineBreak = "";
	 
	 strWidthAttribute  = genAttribute('width' , intWidth      );
	 strHeightAttribute = genAttribute('height', intHeight     );
	 strAlignAttribute  = genAttribute('align' , strAlign      );
	 strTargetAttribute = genAttribute('target', strTarget     );
	 strAltAttribute    = genAttribute('alt'   , strDescription);

	 if (strURL != '') {
	   strQuery = '\?clickTAG=' + strURL;
	   strFile = strFile + strQuery;
	 }

	 strFlash = '<object ' + strLineBreak + ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' + strLineBreak + ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ' + strLineBreak + strWidthAttribute + strHeightAttribute + strAlignAttribute + '>' + strLineBreak + '<param name="movie" value="' + strFile + '">' + strLineBreak + '<param name="quality" value="high">' + strLineBreak + '<param name="wmode" value="transparent">' + strLineBreak + '<embed ' + strLineBreak + ' type="application/x-shockwave-flash" ' + strLineBreak + ' pluginspage="http://www.macromedia.com/go/getflashplayer" ' + strLineBreak + ' src="' + strFile + '" ' + strLineBreak + strWidthAttribute + strHeightAttribute + strAlignAttribute + strAltAttribute + ' quality="high" ' + strLineBreak + ' wmode="transparent" ' + strLineBreak + '> ' + strLineBreak + '</embed> ' + strLineBreak + '</object>' + strLineBreak;

	 if (strURL != '') {
	     strFlash = '<a href="' + strURL + '" ' + strTargetAttribute + '>' + strFlash + '</a>';
	 }
	 
	 return strFlash;
} // genFlash



function displayVideo(strSrc, strAutoplay, strCache, strType, strLoop, strBgcolor, strKioskmode, strController, intWidth, intHeight){
  document.write(genVideo(strSrc, strAutoplay, strCache, strType, strLoop, strBgcolor, strKioskmode, strController, intWidth, intHeight));
} // displayVideo


function genVideo(strSrc, strAutoplay, strCache, strType, strLoop, strBgcolor, strKioskmode, strController, intWidth, intHeight) {
  var strVideo;
  var strWidthAttribute, strHeightAttribute;
  
  var strClassID     = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';
  var strCodeBase    = 'http://www.apple.com/qtactivex/qtplugin.cab';
  var strPluginspage = 'http://www.apple.com/quicktime/download/';
  
  var strLineBreak = "";
  
  // strWidthAttribute  = genAttribute('width' , intWidth      );
  // strHeightAttribute = genAttribute('height', intHeight     );
  
  strVideo = '<object ' + strLineBreak + ' classid = "' + strClassID + '" ' + strLineBreak + ' codebase = "' + strCodeBase + '" ' + strLineBreak + ' width = "' + intWidth + '" ' + strLineBreak + ' height = "' + intHeight + '" ' + strLineBreak + ' >' + strLineBreak + ' <param name="src" value="' + strSrc + '" />' + strLineBreak + ' <param name="autoplay" value="' + strAutoplay + '" />' + strLineBreak + ' <param name="cache" value="' + strCache + '" />' + strLineBreak + ' <param name="type" value="' + strType + '" />' + strLineBreak + ' <param name="loop" value="' + strLoop + '" />' + strLineBreak + ' <param name="bgcolor" value="' + strBgcolor + '" />' + strLineBreak + ' <param name="kioskmode" value="' + strKioskmode + '" />' + strLineBreak + ' <param name="controller" value="' + strController + '" />' + strLineBreak + '<embed ' + strLineBreak + ' src = "' + strSrc + '" ' + strLineBreak + ' autoplay = "' + strAutoplay + '" ' + strLineBreak + ' cache = "' + strCache + '" ' + strLineBreak + ' type = "' + strType + '" ' + strLineBreak + ' loop = "' + strLoop + '" ' + strLineBreak + ' bgcolor = "' + strBgcolor + '" ' + strLineBreak + ' kioskmode = "' + strKioskmode + '" ' + strLineBreak + ' pluginspage = "' + strPluginspage + '" ' + strLineBreak + ' controller = "' + strController + '" ' + strLineBreak + ' width = "' + intWidth + '" ' + strLineBreak + ' height = "' + intHeight + '" ' + strLineBreak + ' />' + strLineBreak + '</object>' + strLineBreak;

  return strVideo;
} // genVideo


function genAttribute(strField, strValue) {
  var strAttribute;

  if (strValue != '') {
    strAttribute = ' ' + strField + ' = ' + strValue + ' ';
  } else {
    strAttribute = '';
  }

  return strAttribute;
} // genAttribute


// -----------------------------------------------------------------------------
// General
// -----------------------------------------------------------------------------



function text2html(strText) {
   var re, strHTML;

   re = /\n\n/g;
   strHTML = strText.replace(re, "<P>");

   re = /\n/g;
   strHTML = strHTML.replace(re, "<BR>");

   return strHTML;
}


function writeText(strBoolean, strData) {
	if (strBoolean == "True")
		document.write(text2html(strData));
	else
		document.write(strData);
}


/*fjerner og viser SØK i søkefeltet*/
function clearField(field,defText){
    

    if((field.value==defText)){
        field.value="";
        $("#"+field.id).css("color","#000000");
    }
    else
        field.value = field.value;
}

function checkField(field,defText,x){
    
    if(field.value==""){
        field.value=defText
        $("#"+field.id).css("color","#cccccc");
    }
    else
        if(x) checkMail(field.value);
}


