function FindObj(s){
    return document.getElementById(s)
}


function MM_validateForm() { //v4.0
 
  var boolSubmit=true,firstName='id_nameFirst',lastName='id_nameLast',address='id_adr',zipcode='id_zipcode',city='id_city',phone='id_phone',strEmail='id_customerEmail',accept='acceptterms';
    if (FindObj(firstName).value==''){
        alert('Du har ikke udfyldt dit fornavn!')
        boolSubmit=false;
    }
    
    else if (FindObj(lastName).value==''){
        boolSubmit=false;
        alert('Du har ikke skrevet dit efternavn')
    }
    else if (FindObj(address).value==''){
        alert('Du har ikke skrevet din adresse');
        boolSubmit=false;
    }else if (FindObj(zipcode).value==''){
        alert('Du har ikke skrevet dit Postnr.');
        boolSubmit=false;
    }else if (FindObj(city).value==''){
        alert('Du har ikke skrevet navnet på din by')
        boolSubmit=false;
    }else if (FindObj(phone).value==''){
        alert('Du har ikke skrevet dit telefonnr.');
        boolSubmit=false;
    }else if ((FindObj(strEmail).value=='E-Mail') || (FindObj(strEmail).value=='')){
        alert('Du har glemt at udfylde din e-Mail!');
        boolSubmit=false;
    }else if (!FindObj(accept).checked){
        alert('Du skal acceptere vores handelsbetingelser for at bekræfte ordren');
        boolSubmit=false;
    }

    return boolSubmit;
}

function MyObject()
{
   this.Property = 'href';
}

function querySt(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i=0;i<gy.length;i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}


function changeImage(obj,oldsrc,newsrc)
{
    x=obj;
  var v = x.src;
  if(v == oldsrc){
    v = newsrc;
  }else{
    v = oldsrc;
  }
    x.setAttribute("src", v);	  
}

function setCookie(c_name,value,expiredays){
//alert(value);
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function DisableChoiches(disableValue){

    var runthis;
    if (disableValue){
        runthis=true
    }else{
        runthis=false
    }
    var rads = document.search.partofcollection;
    if (rads!=null) {
        for(var i=0; i<rads.length;i++ ) 
        { 
            if (runthis) {
                document.search.partofcollection[i].disabled = true; 
            } 
            else
            {
                document.search.partofcollection[i].disabled = false; 
            
            }
        }

        
        if (runthis) {
            document.getElementById('id_headline').style.color='#ACA899';
            document.getElementById('id_levenrandoer').style.color='#ACA899';
            document.getElementById('id_collHeadline').style.color='#ACA899';                 
        }else {
            document.getElementById('id_headline').style.color='';;
            document.getElementById('id_levenrandoer').style.color='';
            document.getElementById('id_collHeadline').style.color='';            
        }

        for(var a=1; a<4;a++) {
            if (runthis){
                document.getElementById('id_collection_span'+a).style.color='#ACA899';
            }else
            {
                document.getElementById('id_collection_span'+a).style.color='';            
            }
        
        }

        for(var a=1; a<5;a++) {
            if (runthis){
                document.getElementById('id_href_preSelect'+a).disabled=true;
                //document.getElementById('id_href_preSelect'+a).href="#";            
                document.getElementById('id_href_preSelect'+a).style.textDecoration='none';
                document.getElementById('id_href_preSelect'+a).style.cursor='default';
                document.getElementById('id_href_preSelect'+a).removeAttribute("href");
                //document.anchors("name_preSelect"+a).removeAttribute("href")
                // 
                changeImage(document.getElementById('sicon_'+a),document.getElementById('sicon_'+a).src,"../gfx/browse_next_disabled_3.gif")
            }else{
                document.getElementById('id_href_preSelect'+a).disabled=false;
                document.getElementById('id_href_preSelect'+a).style.textDecoration='underline';
                document.getElementById('id_href_preSelect'+a).style.cursor='pointer';
                document.getElementById('id_href_preSelect'+a).setAttribute("href","href");            
                document.getElementById('id_href_preSelect'+a).href="javascript:preSelect("+a+");";
                changeImage(document.getElementById('sicon_'+a),document.getElementById('sicon_'+a).src,getCookie("srcname"));
            }
        }

        var radsProvider = document.search.provider;
        for(var i=0; i<radsProvider.length;i++ ) 
        { 
                if (runthis){
                document.search.provider[i].disabled = true; 
                }                else
                {
                document.search.provider[i].disabled = false; 
                }
        }

    
        //document.getElementById('provall').disabled=true;
        var total=(document.getElementById('id_totalProviders').value);
        //alert(total);
        

        var providerids=document.getElementById("id_providersids").value;
        splitProviderids = providerids.split("|");
        
        for(var b=1; b<total;b++) {
        
            if(runthis) {
            document.getElementById('id_href_provider_'+b).disabled=true;
            document.getElementById('id_href_provider_'+b).style.textDecoration='none';
            document.getElementById('id_href_provider_'+b).style.cursor='default';
            document.getElementById('id_href_provider_'+b).style.color='#ACA899';

            
            //document.getElementById('id_href_provider_'+b).href='';
            document.getElementById('id_href_provider_'+b).removeAttribute("href")
            }else {
            
            document.getElementById('id_href_provider_'+b).disabled=false;
            document.getElementById('id_href_provider_'+b).style.textDecoration='underline';
            document.getElementById('id_href_provider_'+b).style.cursor='pointer';
            document.getElementById('id_href_provider_'+b).style.color='';            
            document.getElementById('id_href_provider_'+b).setAttribute("href","href"); 

            document.getElementById('id_href_provider_'+b).href='browse.asp?providerid='+splitProviderids[b];         
            
            }
        }
        
    }    
    
}        

function isImageOk(img) {
    if (!img.complete) {
        return false;
    }

    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        return false;
    }

    // No other way of checking: assume it's ok.
    return true;
    
}

function getImage(pExistingImageID, pImageURL){
    var img = document.createElement('img');
    img.onload = function (evt) {
        document.getElementById(pExistingImageID).src=this.src;
        document.getElementById(pExistingImageID).width=this.width;
        document.getElementById(pExistingImageID).height=this.height;
    }
    img.src = pImageURL;
    
    return false;
}
function ChangeDropDownValue(obj,intValue){
obj.options[intValue].selected = true;
ChangeActionName(obj);
//return;
}

function ChangeActionName(obj) {

    var SelectedSearchValue;
    var actionValue;
    SelectedSearchValue=obj.options[obj.selectedIndex].value
    if (SelectedSearchValue==0) {
        actionValue='search.asp';
        document.search.action = actionValue
        DisableChoiches(false);
       
    }else if (SelectedSearchValue==1) {
        actionValue='search.asp';
        document.search.action = actionValue
        DisableChoiches(true);        
    }else if(SelectedSearchValue==2) {
        actionValue='searchx.asp';
        document.search.action = actionValue
        DisableChoiches(true);        
    }
}


function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function KeepCount(id,formid,totalid) {
var NewCount = 0
var bool=true
	var c;
	var el_collection=formid.selBox
	for(c=0;c<el_collection.length;c++){
	    if (el_collection[c].value!='') {
        	NewCount=NewCount+1
	    }
	}
    if (NewCount > 0)
    {
        if (totalid=='myfiles') {
            document.getElementById('textarea').style.visibility='visible'
            document.getElementById('boxarea').style.visibility='visible'    
        }
        if (totalid=='coll') {
            document.getElementById('textarea').style.visibility='visible'
            document.getElementById('boxarea').style.visibility='visible'    
        }        
    }
    if (NewCount >10)
    {
    alert('En download-fil kan max indeholde 10 billleder')
        if (totalid=='myfiles') {document.dlsingle.selBox}

        if (totalid=='coll') {document.collectiondownload.selBox;}    
        id.selectedIndex=0;
        return false;
    }
    
    if (totalid=='myfiles') {
	    document.getElementById('idmyfiles').style.visibility='visible'    
	}
    if (totalid=='coll') {
	    document.getElementById('idmyfiles').style.visibility='visible'    
	}	

    if (totalid=='myfiles') {
        document.getElementById('idmyfiles').innerHTML='[ '+NewCount+' ]';
    }
    if (totalid=='coll') {
        document.getElementById('idmyfiles').innerHTML='[ '+NewCount+' ]';
    }
    
    if(id=='dl'){
        if(NewCount>0){
        formid.submit();
            
        }else {
        alert("Vælg størrelse på billeder til download")
        }
    }
}
function clearDropdownbox(formid) {
	var c;
	var el_collection=formid.selBox
	for(c=0;c<el_collection.length;c++){
	    if (el_collection[c].value!='') {
        	el_collection[c].value=''
	    }
	}
	document.getElementById('textarea').style.visibility='hidden'
	document.getElementById('boxarea').style.visibility='hidden'	
    document.getElementById('idmyfiles').style.visibility='hidden'

}
function KeepCount1(id,formid,totalid) {
var NewCount = 0
	var c;
	var el_collection=formid.chkbox;
	for(c=0;c<el_collection.length;c++){
	    if (el_collection[c].checked==true) {
        	NewCount=NewCount+1
	    }
	}
    

    if (NewCount > 0)
    {
    document.getElementById('divZipfilename').style.visibility='visible'
    }else{
        document.getElementById('divZipfilename').style.visibility='hidden'
    }
    
    if (NewCount > 10)
    {
    alert('Du kan KUN downloade 10 billeder ad gangen!')
    document.collectiondownload; return false;
    }
    
    if (totalid=='myfiles') {
        formid.idmyfiles.value=' - [ '+NewCount+' ]';
    }
    if (totalid=='coll') {
        formid.idcoll.value=' - [ '+NewCount+' ]';
    }
    
    if(id=='dl'){
        if(NewCount>0){
        formid.submit();
            
        }else {
        alert("Du skal vælge min. et billede til at downloade!")
        }
    }
    

}
 function getScreenWidth () {
     var w=window.screen.availWidth;
     document.getElementById('div1').style.width=w-440;
     document.getElementById('div2').style.width=w-250;

     //document.getElementById('div1').style.visibility='hidden'
      //document.getElementById('div2').style.visibility='hidden'
 }
 
function email_check() {
    
	    var regexp = /^\s*\S+@\S+\.\S\S\S?\s*$/;
	    var emailcheck = regexp.test(Email);
	    return emailcheck;
    }


       function HideDiv(status) {
    v='visible'
    h='hidden'
    if (document.getElementById('Popup').style.visibility == status) {
        document.getElementById('Popup').style.visibility = v;
        }else{
        document.getElementById('Popup').style.visibility = h;
        }
    }
    
    function Show(evt,elementid) {
        /* get the mouse left position */
         /* x = evt.x + document.body.scrollLeft + 10; */

        /* get the mouse top position  */
        /*y = evt.y + document.body.scrollTop + 0;*/

        /* display the pop-up */
        id_popup=document.getElementById('Popup');
        id_dropdownbox=document.getElementById('dropdownbox');

        id_dropdownbox.style.visibility='hidden';
        id_popup.style.display="block";
      
        /*winW = ((document.body.clientWidth)/2) - 100
        winH = ((document.body.clientHeight)/2) - 100*/
        
        id_popup.style.width=document.body.clientWidth;
        /*id_popup.style.height=document.body.clientHeight*/
        
        /*id_popup.style.left = parseInt(520);*/
        id_popup.style.left = parseInt(0);
        /* set the pop-up's top */
        id_popup.style.top = parseInt(75);
    }
    
    function Hide(evt)
    {
        /* hide the pop-up */
        id_popup=document.getElementById('Popup')
        id_popup.style.display="none";
    }

function formValidate () {

        formname=document.forms.frmLogin1
        Email = formname.email.value;
        Pass = formname.pass.value;
        ok=true

        if (!email_check()) {
            alert ("Please write an correct e-mail address!")
            formname.email.style.backgroundColor="#f0f0f0";
            formname.email.focus();
            ok=false
            
        }else if (Pass=="") {
            alert ("Please write your password!")
            formname.email.focus();
            ok=false
        }
        return ok
        
}



function controlCD (string) {
if (string==false) {
    alert ("Please select the resolution(s) size(s)")
    }
}
function controlSI (string) {

if (string==false) {
    alert ("Please select images to download")
    }
}
function DownloadLinkhidden(id) {
    if (document.getElementById('dl_'+id).style.visibility="visible"){
        document.getElementById('dl_'+id).style.visibility="hidden"
        }
        }
    
function DownloadLinkVisible(id) {
    if (document.getElementById('dl_'+id).style.visibility="hidden"){
        document.getElementById('dl_'+id).style.visibility="visible"
        }
        }
function checkBefore(id,collid,providerid) {
        
        
        document.getElementById('id_downloadCD').value=id;
        document.getElementById('id_collid').value=collid;
        document.getElementById('id_providerid').value=providerid;
        document.forms.downloadfiles.submit();

    }
function checkBeforeSI(id) {
        document.getElementById('id_downloadSI').value=id;
        
    }
function hidebar(){
		if (document.getElementById('id_progress').style.visibility=="hidden"){
			document.getElementById('id_progress').style.visibility="visible";
			document.getElementById('id_content').style.visibility="hidden";			
			}
		else {
			document.getElementById('id_progress').style.visibility="hidden";
			document.getElementById('id_content').style.visibility="visible";
			}
        }
function beforeUnload(){
window.close();
}        