/* homeconnector.dk - bolig udlejning */
function URLDecode(psEncodeString) {
    var lsRegExp = /\+/g;
    return unescape(String(psEncodeString).replace(lsRegExp, " "));
}
function videoplayerchange(htmlkode) {
    $('#caseimage').find('.container').html( URLDecode(htmlkode) );
}
function showimage(imgsrc, alttext) {
    var $showhtml = imgsrc; // '<img src="' + imgsrc + '" alt="img"' + ' />';
    if(!alttext || alttext==undefined) {
        alttext = 'image';
    }
    $('#caseimage').find('.container img').attr("src", $showhtml);
    $('#caseimage').find('.container').html('<img src="' + imgsrc + '" alt="img" />');
}
function showmap(imgsrc) {
    if(imgsrc.search(/google/i)>0)
        googlemap = '<iframe width="860" height="448" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' + imgsrc + '&amp;iwloc=&amp;&amp;output=embed"></iframe>';
    else
        googlemap = '<div style="margin: 200px auto;" class="hcheader"><a href="' + imgsrc + '" target="_blank">' + ' Link til Kort ' + '</a></div>';
    $('#caseimage').find('.container').html(googlemap);
}
function showvideo(videosrc) {
    // width:860px; height:448px;
    //numpage = $(this).val();
   // numpage2 = $(this).css();
    
    //alert(numpage + ' - ' + numpage2);
    // $('#videoval_' + pagenumber).css('border-bottom', '1px solid white');

    // Not XHTML Compliant but fullscreen mode works in firefox
    $('#caseimage').find('.container').html('<object width="860" height="448"><param name="movie" value="'+ videosrc +'" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="wmode" value="opaque" /><embed src="'+ videosrc +'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="860" height="448" wmode="opaque" /></object>');
    // $('#caseimage').find('.container').html('<object type="application/x-shockwave-flash" width="860" height="448" data="'+ videosrc +'"><param name="movie" value="'+ videosrc +'"><param name="allowFullScreen" value="true"><param name="wmode" value="opaque"><embed src="'+ videosrc +'" type="application/x-shockwave-flash" allowfullscreen="true" width="860" height="448" wmode="opaque" /></object>');

    //
    // XHTML compliant, but no firefox fullscreen
    // $('#caseimage').find('.container').html('<object type="application/x-shockwave-flash" width="860" height="448" data="'+ videosrc +'"><param name="movie" value="'+ videosrc +'" /></object>'); // ?fs=1&hd=1
}
function showvimeovideo(videosrc) {
    $('#caseimage').find('.container').html('<object width="860" height="448"><param name="movie" value="'+ videosrc +'"><param name="allowFullScreen" value="true"><param name="wmode" value="opaque"><embed src="'+ videosrc +'" type="application/x-shockwave-flash" allowfullscreen="true" width="860" height="448" wmode="opaque" /></object>');
}
function moveimgleft() {
    var imgslidecontent = $('#imageslide .slidecontent');
    var imgslide        = $('#imageslide');
    var position      = imgslidecontent.position();
    var imgslidewidth = imgslidecontent.width();
    var imgwidth      = imgslidecontent.find('.content_item').width();
    var $newpos       = 0;
    var numimg        = $('#imageslide .slidecontent .contentpage').length;
    var holepage = false;

    var n = $('#imageslide .slidecontent').queue("fx");
    if(n=='') {
        if(numimg==0) {
            numimg = $('#imageslide .slidecontent .content_item').length;
            pagenumber = 1;
        } else {
            imgwidth      = imgslidecontent.find('.contentpage').width();
            holepage      = true;
        }
        if((-(position.left) + imgslide.width()) < numimg * imgwidth ) {
            $newpos     = '-=' + imgwidth + 'px';
            pagenumber  = -(position.left / imgwidth) + 2;
        } else {
            $newpos     = '=' + numimg * imgwidth + 'px';
            pagenumber  = -(position.left / imgwidth) + 1;
        }
        if(holepage) {            
            $('#imageslide .slidecontent').animate({"left": $newpos}, {duration: "slow", queue: true});
            //resetpagenumbers();
            //$('#interval_' + pagenumber).css('border-bottom', '1px solid white');
        } else {
            $('#imageslide .slidecontent').animate({"left": $newpos}, {duration: "fast", queue: true});
        }
    }
}

function moveimgright() {
    var imgslidecontent = $('#imageslide .slidecontent');
    var imgslide        = $('#imageslide');
    var position        = imgslidecontent.position();
    var imgslidewidth   = imgslidecontent.width();
    var imgwidth        = imgslidecontent.find('.content_item').width();
    var $newpos         = 0;
    var numimg          = $('#imageslide .slidecontent .contentpage').length;
    var holepage = false;

    var n = $('#imageslide .slidecontent').queue("fx");
    if(n=='') {
        if(numimg==0) {
            numimg = $('#imageslide .slidecontent .content_item').length;
        } else {
            imgwidth      = imgslidecontent.find('.contentpage').width();
            holepage      = true;
        }
        if(position.left < 0) {
            $newpos    = '+=' + imgwidth + 'px';
            pagenumber = -(position.left / imgwidth);
        } else {
            $newpos    = '=' + '0px';
            pagenumber = 1;
        }
        if(holepage) {
            $('#imageslide .slidecontent').animate({"left": $newpos}, {duration: "slow", queue: true});
            //resetpagenumbers();
            //$('#interval_' + pagenumber).css('border-bottom', '1px solid white');
        } else {
            $('#imageslide .slidecontent').animate({"left": $newpos}, {duration: "fast", queue: true});
        }
    }
}

function resetpagenumbers() {
    $("a:visible[id*='interval_']").removeClass("pagenumberactive");
}
function showpage(pagenumber) {
    var imgwidth = $('#imageslide .slidecontent .contentpage').width();
    var $newpos  = -((imgwidth * pagenumber) - imgwidth);
    $('#imageslide .slidecontent').animate({"left": $newpos}, {duration: "slow", queue: false});
    
    //resetpagenumbers();
    //$('#interval_' + pagenumber).css('border-bottom', '1px solid white');
}

function validateSearch() {
   var iChars = "!@#$%^&*()+=-[]\\\';/{}|\":<>?~_"; // "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~_"
   var data = $('#searchtext').val();
   for (var i = 0; i < data.length; i++) {
  	if (iChars.indexOf(data.charAt(i)) != -1) {
  	  alert ("Søgningen indeholder tegn. \nDer er ugyldige til søgning.");
  	return false;
  	}
  }
}
function validateContact() {
    /*
   var iChars = "!#$%^&*()+=-[]\\\';/{}|\":<>?~_"; // "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~_"
   var data = $('#contact_form');
   alert('checking');
   $('#contact_form').find('input')
   for (var i = 0; i < data.length; i++) {
  	if (iChars.indexOf(data.charAt(i)) != -1) {
  	  alert ("Kontakt oplysningerne indeholder tegn. \nDer er ugyldige for feltet.");
  	return false;
  	}
  }
  */
  
  return true;
}
if( navigator.userAgent.match(/Android/i) ||
 navigator.userAgent.match(/webOS/i) ||
 navigator.userAgent.match(/iPhone/i) ||
 navigator.userAgent.match(/iPod/i)
 ){
    youtube_video_hd=0;
} else {
    var youtube_video_hd=0;
}

