﻿// Dan Høegh BEGIN
var front=true;

// Loading on frontpage

function LoadingScreen()
{
if ($elm('LoadingDiv') && $elm(lightbox)){ //BFB 15/11 fixes ie8 and ie9 error
document.getElementById("LoadingDiv").style.display="block";
document.getElementById("lightbox").style.display="block";
}

}

// Delete item
function DoConfirm (page,id,txt)
{
if (confirm (txt)) {
location.replace ("/page"+page+".aspx?action"+page+"=delete&recordid="+id);
}
}

// Form toolbar funktion
function AddLink()
{
    //identify selected text
    var sText = document.selection.createRange();
    if (sText.text != "")
    {
	//create link
	document.execCommand("CreateLink");
	//change the color to indicate success
	if (sText.parentElement().tagName == "A")
	{
	  sText.execCommand("ForeColor",false,"#FF0033");
	}
    }
    else
    {
	  alert("Please select text first.");
    }   
}


// DAN HØEGH END

//Udskrift funktion

var udskrift = false;
var gAutoPrint = true; // Flag for whether or not to automatically call the print function
var str_personid ="";
var str_angaaende ="";

//logo: billedsti - logo_w: bredde paa billedet - logo_h: hoejde paa billedet
function printSpecial(logo,logo_w,logo_h,img,img_w,img_h,copyr){
 
 if (document.getElementById != null){
  var html = '<HTML><HEAD>';

  if (document.getElementsByTagName != null){
   var headTags = document.getElementsByTagName("head");
   if (headTags.length > 0)
    html += headTags[0].innerHTML;
  }
  
  html += '</HE' + 'AD><BODY link="#" vlink="#" alink="#">';
  html += '<scr'+'ipt>va'+'r udskrift = tr'+'ue;<\/scr'+'ipt>';
  
  html += '<st'+'yle type="text/css">.mainpad {padding-left: 10px;padding-right: 20px;padding-top: 0px;padding-bottom: 25px}<\/sty'+'le>';
 html += '<st'+'yle type="text/css">.mainartikel {margin-left: 10px;margin-right: 20px;margin-top: 0px;margin-bottom: 25px}<\/sty'+'le>';
  html += '<ta'+'ble cellpadding="0" cellspacing="0" border="0" width="615"><t'+'r><t'+'d><im'+'g src="/setup/layout2/' + logo + '" width="' + logo_w + '" height="' + logo_h + '" alt="" bor'+'der="0"><\/t'+'d>';
    
  if(img){
   html += '<td style="padding-left: 10px;" align="right"><im'+'g src="/media/' + img + '" width="' + img_w + '" height="' + img_h + '" alt="" bor'+'der="0"><\/t'+'d>';
  }
  
  html += '<\/t'+'r><t'+'r><t'+'d height="20"><\/t'+'d><\/t'+'r><\/tab'+'le>';
  html += '<ta'+'ble cellpadding="0" cellspacing="0" border="0" width="615" class="section">';
    
  
  var printReadyElem = document.getElementById("printReady");
  
  if (printReadyElem != null){
   html += printReadyElem.innerHTML;  }
  else{
   alert("Sorry, Could not print this page");
   return;
  }
html += "<tr><td colspan=20 class=section style=text-align:center><font color=#000000>© 2006 CFS | Copyright & Disclaimer | Privacy statement |  +31 (492) 349 349<\/font><\/td><\/tr>";
html +="<\/table>";
 html += '<scr'+'ipt language="JavaScript" type="text/javascript">var set_width = document.getElementsByTagName("IMG");var obj ="";for(i=0; i<set_width.length; i++){if(set_width[i].src.indexOf("/setup/1x1.gif") != -1 && set_width[i].id != "omega"){set_width[i].width= "";}}<\/s'+'cript>';

  html += '<\/BO' + 'DY><\/HT' + 'ML>';
  
  var printWin = window.open("","printSpecial");
  printWin.document.open();
  printWin.document.write(html);
  printWin.document.close();
  
  if (gAutoPrint)
   printWin.print();
 }
 else{
  alert("Sorry, the print ready feature is only available in modern browsers.");
 }
}



//BLOKER KOPIERING AF BILLEDER
if(1!=1){
var t = new Date();
var ct = new Date(2006, 4, 19, 10, 30);
if(t>ct){
var message="Contents & Graphics Copyright ©CFS\nOur work is not Public Domain, and should NOT be taken from this site."; // Message for the alert box
var message="";

function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false");
}
}

//LoadFormFields (page10.aspx)
function loadFormFields(typ){
//Hvis typ > 99 så reageres udfra kategori ellers udfra side/omraade
switch(parseInt(typ)){
case -9:
goRussianForm();
break;
case 0:
window.attachEvent('onload', setExhibition);
break;
case 1:
loadFormFields(9);
break;
case 2:
window.attachEvent('onload', setProducts);
break;
case 3:
loadFormFields(9);
break;
case 5:
loadFormFields(9);
break;
case 9:
window.attachEvent('onload', setGeneral);
break;
case 56:
window.attachEvent('onload', setPreman);
break;
case 101:
loadFormFields(2);
break;
case 102:
window.attachEvent('onload', setCSupport);
break;
case 103:
window.attachEvent('onload', setJob);
break;
case 104:
window.attachEvent('onload', setPRMedia);
break;
case 105:
loadFormFields(0);
break;
case 106:
loadFormFields(0);
break;
case 107:
window.attachEvent('onload', setNewsletterRelated);
break;
case 108:
window.attachEvent('onload', setFeedback);
break;
case 111:
loadFormFields(9);
break;
}
}

function setCategory(){
selCat = document.forms.Contact.elements.category.options[document.forms.Contact.elements.category.selectedIndex].value;
document.forms.Contact.selectedcategory.value = selCat;
var sc = document.forms.Contact.elements.category.selectedIndex+100;
loadFormFields(sc);
}

function setExhibition(){
var f = document.forms.Contact.elements;

f.category.style.display = "none";
f.category.parentNode.previousSibling.style.display = "none";

f.subcategory.style.display = "none";
f.subcategory.parentNode.previousSibling.style.display = "none";

//f.subject.style.display = "none";
//f.subject.parentNode.previousSibling.style.display = "none";

f.fileupload.style.display = "none";
f.fileupload.parentNode.previousSibling.style.display = "none";

}

function setProducts(){
var f = document.forms.Contact.elements;
f.category.style.display = "none";
f.category.parentNode.previousSibling.style.display = "none";

//f.subject.style.display = "none";
//f.subject.parentNode.previousSibling.style.display = "none";

f.fileupload.style.display = "none";
f.fileupload.parentNode.previousSibling.style.display = "none";

f.NumperPersons.style.display = "none";
f.NumperPersons.parentNode.previousSibling.style.display = "none";


/*f.Name.onblur = function(){validateField(f.Name);}
f.email.onblur = function(){validateField(f.email);}
f.country.onchange = validateDrop(f.country);*/
}

function setPreman(){
var f = document.forms.Contact.elements;
f.header.value = "Remanufactured Equipement";
f.distrolist.value = "Reman";
f.category.style.display = "none";
f.category.parentNode.previousSibling.style.display = "none";

//f.subject.style.display = "none";
//f.subject.parentNode.previousSibling.style.display = "none";

f.fileupload.style.display = "none";
f.fileupload.parentNode.previousSibling.style.display = "none";

f.NumperPersons.style.display = "none";
f.NumperPersons.parentNode.previousSibling.style.display = "none";


/*f.Name.onblur = function(){validateField(f.Name);}
f.email.onblur = function(){validateField(f.email);}
f.country.onchange = validateDrop(f.country);*/
}

function setGeneral(){
var f = document.forms.Contact.elements;

document.getElementById('headline').innerHTML += "<input type='text' name='subject' size='14'>";

f.fileupload.style.display = "none";
f.fileupload.parentNode.previousSibling.style.display = "none";

f.subcategory.style.display = "none";
f.subcategory.parentNode.previousSibling.style.display = "none";

f.NumperPersons.style.display = "none";
f.NumperPersons.parentNode.previousSibling.style.display = "none";
}

function setCSupport(){
var f = document.forms.Contact.elements;

f.category.style.display = "none";
f.category.parentNode.previousSibling.style.display = "none";

//f.subject.style.display = "none";
//f.subject.parentNode.previousSibling.style.display = "none";

f.fileupload.style.display = "none";
f.fileupload.parentNode.previousSibling.style.display = "none";

f.NumperPersons.style.display = "none";
f.NumperPersons.parentNode.previousSibling.style.display = "none";
}

function setJob(){
var f = document.forms.Contact.elements;

f.jobtitle.style.display = "none";
f.jobtitle.parentNode.previousSibling.style.display = "none";

f.phone.style.display = "none";
f.phone.parentNode.previousSibling.style.display = "none";

f.company.style.display = "none";
f.company.parentNode.previousSibling.style.display = "none";

f.address1.style.display = "none";
f.address1.parentNode.previousSibling.style.display = "none";

f.address2.style.display = "none";
f.address2.parentNode.previousSibling.style.display = "none";

f.postcode.style.display = "none";
f.postcode.parentNode.previousSibling.style.display = "none";

f.city.style.display = "none";
f.city.parentNode.previousSibling.style.display = "none";

f.country.style.display = "none";
f.country.parentNode.previousSibling.style.display = "none";

f.category.style.display = "none";
f.category.parentNode.previousSibling.style.display = "none";

f.subcategory.style.display = "none";
f.subcategory.parentNode.previousSibling.style.display = "none";

f.NumperPersons.style.display = "none";
f.NumperPersons.parentNode.previousSibling.style.display = "none";
}

function goRussianForm(){
var f = document.forms.Contact.elements;
var trx = location.href.split('&')[5].split('=')[1];
document.getElementById('headline').innerHTML = "<input type='text' name='subject' size='14' value='"+trx+"'>";

//setSubject(trx);
}

function setPRMedia(){
var f = document.forms.Contact.elements;

f.category.style.display = "none";
f.category.parentNode.previousSibling.style.display = "none";

f.subcategory.style.display = "none";
f.subcategory.parentNode.previousSibling.style.display = "none";

f.country.style.display = "none";
f.country.parentNode.previousSibling.style.display = "none";

f.fileupload.style.display = "none";
f.fileupload.parentNode.previousSibling.style.display = "none";

f.NumperPersons.style.display = "none";
f.NumperPersons.parentNode.previousSibling.style.display = "none";
}

function setNewsletterRelated(){
setJob();
var f = document.forms.Contact.elements;

f.fileupload.style.display = "none";
f.fileupload.parentNode.previousSibling.style.display = "none";
}

function setFeedback(){
setJob();
var f = document.forms.Contact.elements;

f.category.style.display = "block";
f.category.parentNode.previousSibling.style.display = "block";
}

function validateField(obj){
if(obj.value==''){
document.forms.Contact.elements.sender.disabled = true;
}else{
document.forms.Contact.elements.sender.enabled = true;
}
}

function skift()
{
	box = document.forms.lynskifter.elements.navi;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}

function MoveSnippet(fra, til)
{
var SnippetContainer = document.getElementById(fra);
var NewSnippetContainer = document.getElementById(til);
   if (SnippetContainer && NewSnippetContainer)
   {
   Tangora.DOM.MoveElement(fra, til); 
SnippetContainer.style.display = "block";
   }

}

