// DIV PAGEFUNCTIONS
function closeSearchResult(objName){
	document.getElementById("topSearchresultDiv").style.display="none"
	document.getElementById("topsearching").style.background="#FFFFFF"
}
function showTopSearchResult(){
	topsearchKeyword=document.getElementById("topsearchTxt").value
	if((topsearchKeyword=="")||(topsearchKeyword.length<3)){
		DoCloseSearchResult("topSearchresultDiv");return;
	}
	strURL="/data/topsearch.asp?q="+topsearchKeyword
	//alert(strURL)
	var req = GetXmlHttpObject();
	if (req){
		req.onreadystatechange = function() {
			if ((req.readyState==4 || req.readyState=="complete")){ //når data er returneret
				//alert(req.responseText)
				document.getElementById("topSearchresultDiv").style.display="block"
				document.getElementById("topsearching").style.background="URL(/files/site/images/searchtop_on.gif)"
				document.getElementById("topSearchresult").innerHTML=req.responseText
				req=null
			}
		}
		req.open("GET", strURL, true);
		req.send(null);
	}
}
function closeAfterOneSecound(){
    setTimeout('closeSearchResult("topSearchresultDiv")',1000);
}

function hideBuyContainer(tURL) {
     document.getElementById("basketDetailContainer").innerHTML='<div id="basket-loading-gif"><p></p></div>'
    $('#intoBasketContainer,#basketDetailContainer').unbind("click")//alert(tURL)
    if(tURL!=''){
        document.location.href=tURL
    }else{
        document.location.reload()
    }
    
    return false;
}

function showBuyContainer(pformName){
    var icbdiv=document.createElement("div");
    icbdiv.setAttribute('id', "intoBasketContainer");
    document.body.appendChild(icbdiv)
    //$('body').append('<div id="intoBasketContainer"></div><div id="basketDetailContainer"></div></div>'); 
    $('embed, object, select').css({ 'visibility' : 'hidden' });
     var arrPageSizes = ncms_getPageSize()
    $('#intoBasketContainer').css({
        backgroundColor: "#000", 
        opacity: 0.8, 
        width: arrPageSizes[0], 
        height: arrPageSizes[1]
    }).fadeIn();
    
    var bdcdiv=document.createElement("div");
    bdcdiv.setAttribute('id', "basketDetailContainer");
    document.body.appendChild(bdcdiv)

    var arrPageScroll = ncms_getPageScroll();
    // Calculate top and left offset for the jquery-lightbox div object and show it
    $('#basketDetailContainer').css({
        top:    arrPageScroll[1] + (arrPageSizes[3] / 10),
        opacity: 1
        //,left:   arrPageScroll[0]
    }).show();
    // Assigning click events in elements to close overlay
    $('#intoBasketContainer,#basketDetailContainer').click(function() {
        hideBuyContainer('');  return false;                                    
    });

    updateByContainer(pformName)

    return false;
    //showHideDiv(iVal)
}

function updateByContainer(pformName){
	myform=document.forms[pformName]
	var inputs = [];
	$(':input', myform).each(function() {
		inputs.push(this.name + '=' + escape(this.value));
	})
	jQuery.ajax({
	data: inputs.join('&'),
	url: myform.action,
	timeout: 2000,
	error: function(xhr, status, error) {
		alert(xhr.responseText);  
		return false;
	},
	success: function(r){
		document.getElementById("basketDetailContainer").innerHTML=r
		return false;
		}
	})
	return false;
}

