
//  from header
document._domino_target = "_self";
function _doClick(v, o, t) {
  var url = mothersite_url + "dan/" + lang_country_id + ".nsf/0/0?OpenDocument&Click=" + v;
  if (o.href != null)
    o.href = url;
  else {
    if (t == null)
      t = document._domino_target;
    window.open(url, t);
  }
}


function openSitemapWindow(URL) {
sitemapWin=window.open(URL,'sitemap','width=815,height=600,directories=no,status=yes,scrollbars=yes,resizable=no,menubar=no,toolbar=no');
}
function VisHusPopup(URL) {
w = window.open(URL,"",'width=650,height=500,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=yes,toolbar=no');
}
function openWindow(URL) {
window.open(URL,"",'width=580,height=460,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=yes,toolbar=no');
}
function showHouse(val) {
 hnr = document.housenumber.house.value;
 vhurl = mothersite_url + "web/ds.nsf/house?readForm&Valuta=" + val + "&COMPANY=DAN&Katalognr=" + hnr + "&showallpic=N"
 win=window.open(vhurl,"",'width=660,height=500 left=20, top=20,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=yes,toolbar=no');
}
function newsletterSubscribtion(go2url) {
window.open(go2url + "&email=" + document.newsletter.email.value,"",'width=200,height=100 left=20, top=20,directories=no,status=yes,scrollbars=no,resizable=yes,menubar=no,toolbar=no');
}
//highlight region on map
function showHideRegion(regioncode) {
regionlayer=document.getElementById(regioncode);

if (regionlayer.style.visibility == "visible") {
regionlayer.style.visibility = "hidden";
} else {
regionlayer.style.visibility = "visible";
}
}
function makeDanLink(dateField,language,country)
{
	findValue = document.Husform.elements[dateField].value.split('/')
	if (!findValue[1]){
		findValue = document.Husform.elements[dateField].value.split('.')
	}
	myMonth = findValue[1]
	myYear = "20" + findValue[2]
    
    subcal(gfxDir + 'calendar.php?ReadForm&dateField='+dateField+'&m='+myMonth+'&y='+myYear+'&language='+
            language+'&country='+country + (window["isponotop"] ? '&isponotop=1' : ''))
}
function validateStartDate( theform )
{
   var s1 = theform.fradato.value.indexOf( '/' );
   var s2 = theform.fradato.value.lastIndexOf( '/' );
   var e1 = theform.tildato.value.indexOf( '/' );
   var e2 = theform.tildato.value.lastIndexOf( '/' );
	if (s1==-1 & s2==-1){
	   var s1 = theform.fradato.value.indexOf( '.' );
   	   var s2 = theform.fradato.value.lastIndexOf( '.' );
	}
	if (e1==-1 & e2==-1){
         var e1 = theform.tildato.value.indexOf( '/' );
         var e2 = theform.tildato.value.lastIndexOf( '/' );
	}

  var sy = "200" + Math.abs(theform.fradato.value.substr(s2+1,s2+5));
  var sm = Math.abs(theform.fradato.value.substring(s1+1,s2));
  var sd = Math.abs(theform.fradato.value.substr(0,s1));
   var ey = "200"  + Math.abs(theform.tildato.value.substr(e2+1,e2+5));
   var em = Math.abs(theform.tildato.value.substring(e1+1,e2));
   var ed = Math.abs(theform.tildato.value.substr(0,e1));
var temp = new Date( sy, sm-1, sd+7);
var zD = temp.getDate().toString();
if (zD.length < 2) {zD = '0'+zD};
var zM = eval(temp.getMonth()+1).toString();
if (zM.length < 2) {zM = '0'+zM};
   //  Netscape JS fix
   var zY = temp.getYear() < 1999 ? temp.getYear() + 1900 : temp.getYear();
zY = zY.toString();
  zY=zY.substr(2, 2);
   document.forms['Husform'].tildato.value = zD + "/" + zM + "/" + zY;   
}

function SetIndex( area) 
{     
   if(area==''){
      document.forms['Husform'].Area.value = area;
      document.kort.src= gfxDir + dest_country_name + ".gif";
   } else {
      document.forms['Husform'].Area.value = area;
      document.kort.src= gfxDir + area + ".gif";
   }
}
function SetAreaIndex(areaid, country){
	
	document.getElementById('area').value = areaid;	
	//document.form.Husform.Area.value = areaid;
	if(areaid != ''){
		document.kort.src= gfxDir+country+"map/" + areaid + ".gif";
	}
}
function validateDates(dateset){

					var cdate = new Date();
					
					if((parseInt(document.forms[0].startday.value) > parseInt(document.forms[0].endday.value)) && (parseInt(document.forms[0].endmy.value) <= parseInt(document.forms[0].startmy.value))){
						//Validation, if any, goes here!!
					}
					
					if(dateset == "start"){
						document.getElementById('fradato').value = (zero_format(document.forms[0].startday.value) + "/" + get_month(document.forms[0].startmy.value,cdate) + "/" + get_year(document.forms[0].startmy.value,cdate));
					}
					else if(dateset == "end"){
						document.getElementById('tildato').value = (zero_format(document.forms[0].endday.value) + "/" + get_month(document.forms[0].endmy.value,cdate) + "/" + get_year(document.forms[0].endmy.value,cdate));
					}
					
}
				
function get_month(add,cdate){
	var nowmonth = (cdate.getMonth()+1);
	var tmp = parseInt(nowmonth) + parseInt(add);
	if(tmp > 12){
		tmp = tmp - 12;
	}
	return zero_format(tmp);
}

function get_year(add,cdate){
	var tmp2 = 0;
	var nowmonth = (cdate.getMonth()+1);
	var tmp = parseInt(nowmonth) + parseInt(add);
	if(tmp > 12){
		tmp2 = 1;
	}
	tmp = cdate.getFullYear()+tmp2;
	return tmp.toString();				
}

function zero_format(int){

	var s = int.toString();
	if(s.length == 1){
		return '0'+s;
	}else{
		return s;
	}
}
