
//GET USER PARAMETER
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
function setMyKonfiguratorPrices(tabType, ID, pcType, computerID){
if(document.getElementById(computerID+"minDB")){
	var minDB = document.getElementById(computerID+"minDB").value;
}
if(document.getElementById(computerID+"DB")){
	var DB = document.getElementById(computerID+"DB").value;
}
if (computerID==0){
	window.location='myProfile.php?tabType='+tabType+'&ID='+ID+'&type='+pcType+'&computerID='+computerID+'&DB='+DB;
} else if (minDB.length>0 && DB.length>0 && minDB > 0 && DB >0){
	window.location='myProfile.php?tabType='+tabType+'&ID='+ID+'&type='+pcType+'&computerID='+computerID+'&minDB='+minDB+'&DB='+DB;
} else {
	alert("MinDB og DB skal være større end 0");
}
}

function hideShowSearchAdvPopBox(){

if(document.getElementById('searchAdvanvedPopBox')){

				if (document.getElementById('searchAdvanvedPopBox').className=='searchAdvancedPop'){

					Effect.SlideUp('searchAdvanvedPopBox', {duration: 0.25});
					document.getElementById('searchAdvanvedPopBox').className='searchAdvancedPopHide';
					//document.getElementById('minMaxIcon'+ID).src='imgNewDesign/boxTop'+type+'MaxIcon.gif';

} else {

					Effect.SlideDown('searchAdvanvedPopBox', {duration: 0.25});				

					document.getElementById('searchAdvanvedPopBox').className="searchAdvancedPop";

//document.getElementById('minMaxIcon'+ID).src='imgNewDesign/boxTop'+type+'MinIcon.gif';					
				}
			}
	}
	var performingSearch = 0;
	var	searchWindow = null;
	
function makeSearchWindow(){	
	searchWindow = new Window("searchResult", {
			className:"alphacube", 
			title: "S&oslash;geresultat: "+document.getElementById("topTextSearchInput").value, 
			width:988, 
			height:600,
			left:5,
			top:38,
			resizable: false,
			minimizable:false, 
			maximizable:false, 
			draggable: false, 
			destroyOnClose: true, 
			wiredDrag:false, 
			url: "ajax/generateTextSearch.php?q="+document.getElementById("topTextSearchInput").value, 
			showEffectOptions: {duration:0.25}, hideEffectOptions: {duration:0.25}}
		)
}
function performTextSearch(input){
	if (input.value!=""){		
			if (performingSearch == 0){
				performingSearch = 1;
				setTimeout("updateSearchResult()", 1000);
			}
		} else {
			searchWindow.destroy();
		}
	}

	function updateSearchResult(input) {
	performingSearch = 0;
	if (searchWindow == null){
		makeSearchWindow();
		searchWindow.show();
	} else{
		searchWindow.setTitle("S&oslash;geresultat: "+document.getElementById("topTextSearchInput").value);
		searchWindow.setURL("ajax/generateTextSearch.php?q="+document.getElementById("topTextSearchInput").value);
		searchWindow.refresh();
	}
	}
	
	function popUp(id, url, title){
		
	
// Windows with an URL as content
	win2 = new Window(id, {
		className:"alphacube", 
		title: title, 
		width:600, height:400,
		resizable: true,
		minimizable:true, 
		maximizable:true, 
		draggable: true, 
		destroyOnClose: true, 
		wiredDrag:false, 
		url: url, 
		showEffectOptions: {duration:0.25}, hideEffectOptions: {duration:0.25}}
	)
	win2.showCenter();
	win2.show();

//		Dialog.alert({url: "info_panel.html", options: {method: 'get'}}, {className: "lighting", width:540, okLabel: "Close"});
		
	}
	
	
	   // <![CDATA[
var currentID = '';
function updateBox(ID) {
currentID = 'box'+ID;
if (ID=="Tilbud" || ID=="Prisfald" || ID=="Nye" || ID=="Populaere" || ID=="Tilbehor"){	
var URL = 'ajax/generateBox.php?varenummer='+gup("varenummer")+'&gruppe_id='+gup("gruppe_id")+'&boxid='+ID
} else {
//var URL = 'ajax/generateBox.php?varenummer='+gup("varenummer")+'&gruppe_id='+gup("gruppe_id")+'&boxid='+ID	
var URL = 'ajax/generateBox.php?boxid='+ID
}
var ajax = new Ajax.Updater(
         currentID, URL
         , 
         {method:'post', 
		 onComplete: showBox
          }
	);
}

function showBox(req)
{

$(currentID).innerHTML = req.responseText;

}
function productPageHelp(type){
	alert(type);
		win2 = new Window("productPageHelp"+type, {
		className:"alphacube", 
		title: "Hj&aelig;lp: "+type, 
		width:600, height:400,
		resizable: true,
		minimizable:true, 
		maximizable:true, 
		draggable: true, 
		destroyOnClose: true, 
		wiredDrag:false, 
		url: "help.php?ID="+type, 
		showEffectOptions: {duration:0.25}, hideEffectOptions: {duration:0.25}}
		);
		
		win2.showCenter();
		win2.show();
}
function tabHelp(type) {
		var obj;
		var tabs = document.getElementById("tabMenuContainer").getElementsByTagName("DIV");
		var len = tabs.length;
		
		for (var i = 0; i < len; i++){
			if (tabs[i].className == "tabMenuSelected")
			{
				obj = tabs[i];				
				i = len;
			}
		}
		win2 = new Window("tabHelp"+obj.id, {
		className:"alphacube", 
		title: "Hj&aelig;lp: "+obj.id, 
		width:600, height:400,
		resizable: true,
		minimizable:true, 
		maximizable:true, 
		draggable: true, 
		destroyOnClose: true, 
		wiredDrag:false, 
		url: "help.php?ID="+obj.id, 
		showEffectOptions: {duration:0.25}, hideEffectOptions: {duration:0.25}}
	);
	
	win2.showCenter();
	win2.show();
}

function nobuyFrontBox(ID){
	if(document.getElementById(ID)){

	} 
	else {	
		win2 = new Window(ID, {
			className:"alphacube", 
			title: "Kan vi hj&aelig;lpe...?", 
			width:600, height:400,
			resizable: true,
			minimizable:true, 
			maximizable:true, 
			draggable: true, 
			destroyOnClose: true, 
			wiredDrag:false, 
			url: "help.php?ID="+ID, 
			showEffectOptions: {duration:0.25}, hideEffectOptions: {duration:0.25}}
		)
		
	
	win2.showCenter();
	win2.show();
	}
}

function smsKurvHelp(ID, bestil_check, title, checked, mobilnr, type){
	if(bestil_check>0 && checked != true){
		win2 = new Window("frontHelp"+ID, {
		className:"alphacube", 
		title: title, 
		width:450, height:250,
		resizable: true,
		minimizable:true, 
		maximizable:true, 
		draggable: true, 
		destroyOnClose: true, 
		wiredDrag:false, 
		url: "help.php?ID="+ID+"&mobilnr="+mobilnr+"&type="+type, 
		showEffectOptions: {duration:0.25}, hideEffectOptions: {duration:0.25}}
		);
		win2.showCenter();
		win2.show();
	} 
	else {	
	}
}

function fronBoxHelp(ID){
	if(document.getElementById('frontHelp'+ID)){

	} 
	else {	
		win2 = new Window("frontHelp"+ID, {
		className:"alphacube", 
		title: "Hj&aelig;lp: "+ID, 
		width:600, height:400,
		resizable: true,
		minimizable:true, 
		maximizable:true, 
		draggable: true, 
		destroyOnClose: true, 
		wiredDrag:false, 
		url: "help.php?ID="+ID, 
		showEffectOptions: {duration:0.25}, hideEffectOptions: {duration:0.25}}
	)
		
	
	win2.showCenter();
	win2.show();
	}
}
	function showHelp(ID){
		if(document.getElementById('frontBoxHelp'+ID)){
			document.getElementById('frontBoxHelp'+ID).innerHTML ="<img alt=\"Hj&aelig;lp\" title=\"Hj&aelig;lp\" src=\"imgNewDesign/orderQ.png\">";
		}
	}
	function hideHelp(ID){
		if(document.getElementById('frontBoxHelp'+ID)){
			document.getElementById('frontBoxHelp'+ID).innerHTML ="<img alt=\"\" src=\"imgNewDesign/iconTrans.png\">";
		}
	}

	function maxMinHelpFrontBox(type, ID){
		if(document.getElementById('frontBoxHelp'+ID)){
			if (document.getElementById('frontBoxHelp'+ID).innerHTML.indexOf('Trans.png')>0){
				maxMinFrontBox(type, ID);
			} else {
				fronBoxHelp(ID);
			}
		}
	}
	function maxMinFrontBox(type, ID){

			if (type == 'personal'){
				type = 'Personal';
			} else if (type=='product') {
				type = 'Product'; 
			}

			if(document.getElementById('frontBoxNo'+ID)){
				if (document.getElementById('frontBoxNo'+ID).className=='frontBoxContentCellDiv'){
					new Ajax.Request('ajax/setCookie.php?name=frontbox_'+ID+'&value='+0, {asynchronous:true});
					if (ID=="Nyheder"){	
						var now = new Date();
						new Ajax.Request('ajax/setCookie.php?name=newsVisit&value='+now.getDate()+'-'+(now.getMonth()+1)+'-'+(now.getFullYear()), {asynchronous:true});
					}
					Effect.SlideUp('frontBoxNo'+ID, {duration: 0.25});
					document.getElementById('frontBoxNo'+ID).className='frontBoxContentCellDivHide';
					document.getElementById('minMaxIcon'+ID).src='imgNewDesign/boxTop'+type+'MaxIcon.gif';
					hideHelp(ID);
				} else {
					var updateNow = '0';
					if (document.getElementById('box'+ID).innerHTML == '') {
						updateNow = '1';
						document.getElementById('box'+ID).innerHTML = '<center><img src="imgNewDesign/load.gif" width="170"/></center>';
					}
					new Ajax.Request('ajax/setCookie.php?name=frontbox_'+ID+'&value='+1, {asynchronous:true});
					Effect.SlideDown('frontBoxNo'+ID, {duration: 0.25});
					document.getElementById('frontBoxNo'+ID).className="frontBoxContentCellDiv";
					document.getElementById('minMaxIcon'+ID).src='imgNewDesign/boxTop'+type+'MinIcon.gif';
					if (updateNow == '1') {
						updateBox(ID);
					};
					showHelp(ID);
				}
			}
	
	
	}

	
var mouseOverMenu = false;
var currentContainer ='';

function updateContainer(container,url) {
currentContainer = container;
var ajax = new Ajax.Updater(
         currentContainer,
         url, 
         {method:'post', 
		 onComplete: showContainer
          }
	);
}

function showContainer(req)
{
$(currentContainer).innerHTML = req.responseText;
var currentContainer =''; 
}

function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function setcookie(name, value) 
	{ 
	document.cookie= name + "=" + escape(value); 
	} 
	
	function checkDandomain() {
		if (document.confform.dandomain.checked) {
			document.getElementById('dandomaincontainer').style.display= 'block';
		}
		else {
			document.getElementById('dandomaincontainer').style.display= 'none';
		}
	}

function putLoaderInContainer(id) {
	document.getElementById(id).innerHTML = '<center>LOADING<br /><img src="img/loading.gif" /></center>';
	}
		// ]]>