function fuPopWin(myUrl,myWidth,myHeight){
	var winWidth = screen.width;
	var winHeight= screen.height;
	var myX= (screen.availWidth/2) - (winWidth/2);
	var myY= (screen.availHeight/2) - (winHeight/2);
	var myWin= window.open(myUrl,'winpop','screenX=0,screenY=0,left=0,top=0 ,width='+winWidth+',height='+winHeight+',toolbar=1,location=1,directories=1,status=1,scrollbars=1,resizable=1');

}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function showPicJQ (whichpic) {

        $j("#placeholder").attr("src",whichpic);

}

function clearDefault(el) {
if (el.defaultValue==el.value) el.value = ""
}

	function fnIPdocument_GetElementsById(strId, objDoc){
		try{
			if (!objDoc) objDoc = document;
			return fnIPdocument_GetElementChildsById(objDoc, strId);
		}catch(e){
		}
	}

	function fnOpenDaVinci(){
		window.showModelessDialog('app/DaVinci/CompanyList.php?newwindow=1&onlylist=1',window,'scroll:on;dialogHeight:520px;dialogWidth:650px;edge:Raised;center:Yes;help:No;resizable:Yes;status:No;');
	}
	function fnIPdocument_GetElementChildsById(obj, strId){
		try{
			if (!obj) obj = document;

			if (document.all){
				if (!obj.all[strId]){
					var aryObject = new Array();
					aryObject[0] = null;
					return aryObject;
				}
				if (!obj.all[strId].length || (obj.all[strId].tagName == "SELECT" && !obj.all[strId][0].length)){
					var aryObject = new Array();
					aryObject[0] = obj.all[strId];
					return aryObject;
				}
				return obj.all[strId];
			}

			if (document.childNodes){
				var aryReturn = new Array();
				aryReturn = fnIPdocument_GetElements(obj, strId, aryReturn, "ID");
				if (!aryReturn.length){
					var aryObject = new Array();
					aryObject[0] = null;
					return aryObject;
				}else return aryReturn;
			}

			return null;
		}catch(e){
		}
	}

	function fnIPdocument_GetElements(obj, strId, aryReturn, strMode){
		try{
			for (var i=0; i < obj.childNodes.length; i++){
				if (obj.childNodes[i].nodeType == 1){
					if (strMode == "ID"){
						if (obj.childNodes[i].id == strId)
							aryReturn[aryReturn.length] = obj.childNodes[i];
					}else{
						if (strMode == "NAME")
							if (obj.childNodes[i].name == strId)
								aryReturn[aryReturn.length] = obj.childNodes[i];
					}

					if (obj.childNodes[i].childNodes)
						aryReturn = fnIPdocument_GetElements(obj.childNodes[i], strId, aryReturn, strMode);
				}
			}
			return aryReturn;
		}catch(e){
		}
	}

	function fnToogleHide(strID, objPress){
		try{
			if (!strID) return;
			if (!document.all[strID]) return;

			var obj = fnIPdocument_GetElementsById(strID);
			if (obj) obj = obj[0];

			if (obj.style.visibility != "hidden"){
				obj.style.visibility = "hidden";
				obj.style.display = "none";
				obj.style.clip = "rect(0,0,0,0)";
				var objPic = fnIPdocument_GetElementsById("pic_expand", objPress);
				if (objPic) objPic[0].src = objPic[0].src.replace("arrow_collapse", "arrow_expand");
			}else{
				obj.style.visibility = "visible";
				obj.style.display = "block";
				obj.style.clip = "rect(0,0,1000,10000)";
				var objPic = fnIPdocument_GetElementsById("pic_expand", objPress);
				if (objPic) objPic[0].src = objPic[0].src.replace("arrow_expand", "arrow_collapse");
			}
		}catch(e){
			return false;
		}
	}

	var arrPopupWins = new Array;

	/*/
	 * fnOpenWindow
	 * Opens up a new popup window, or focuses on an already opened window.
	/*/


	function fnOpenWindow (strUrl, intWidth, intHeight, blnScroll, blnResizable, blnFlip, blnStatus, blnMenubar, blnLocation, blnToolbar, strName, intXPos, intYPos, blnNewLocation){
		var intXPos, intYPos, strOpen, intHeight;

		if (!strUrl) return false;
		if (strUrl.substr(0,1) == "#") return false;

		if (!blnScroll || blnScroll == "0" || blnScroll == "" || blnScroll == "false") blnScroll = 0; else blnScroll = 1;
		if (!blnResizable || blnResizable == "0" || blnResizable == "" || blnResizable == "false") blnResizable = 0; else blnResizable = 1;
		if (!blnFlip || blnFlip == "0" || blnFlip == "" || blnFlip == "false") blnFlip = 0; else blnFlip = "1";
		if (!blnStatus || blnStatus == "0" || blnStatus == "" || blnStatus == "false") blnStatus = 0; else blnStatus = 1;
		if (!blnMenubar || blnMenubar == "0" || blnMenubar == "" || blnMenubar == "false") blnMenubar = 0; else blnMenubar = 1;
		if (!blnLocation || blnLocation == "0" || blnLocation == "" || blnLocation == "false") blnLocation = 0; else blnLocation = 1;
		if (!blnToolbar || blnToolbar == "0" || blnToolbar == "" || blnToolbar == "false") blnToolbar = 0; else blnToolbar = 1;

		intHeight = parseInt(intHeight);
		intWidth = parseInt(intWidth);

		if (intHeight == 0){
			if (blnFlip == 1) intHeight = intWidth * (4/3)
			else intHeight = intWidth * (3/4)
		}

		if (!strName) strName = (new Date()).getMinutes().toString() + "_" + (new Date()).getSeconds().toString();

		if (!window.screen.availHeight){
			if (!intXPos) intXPos = 200;
			if (!intYPos) intYPos = 200;
		}else{
			var intMaxHeight = window.screen.availHeight - 38;
			var intMaxWidth = window.screen.availWidth - 12;

			intXPos = intMaxWidth/2 - intWidth/2;
			intYPos = intMaxHeight/2 - intHeight/2;

			if (intWidth == "max"){
				if (!intXPos) intXPos = 0;
				intWidth = intMaxWidth;
			}
			if (intHeight == "max"){
				if (!intYPos) intYPos = 0;
				intHeight = intMaxHeight;
			}

			if (intWidth > intMaxWidth){
				if (!intXPos) intXPos = 0;
				intWidth = intMaxWidth;
			}
			if (intHeight > intMaxHeight){
				if (!intYPos) intYPos = 0;
				intHeight = intMaxHeight;
			}
		}

		strOpen = "width=" + intWidth + "," +
			 "height=" + intHeight + "," +
			 "location=" + blnLocation + "," +
			 "menubar=" + blnMenubar + "," +
			 "resizable=" + blnResizable + "," +
			 "scrollbars=" + blnScroll + "," +
			 "status=" + blnStatus + "," +
			 "titlebar=0," +
			 "toolbar=" + blnToolbar + "," +
			 "hotkeys=0," +
			 "left=" + intXPos + "," +  //*** IE Only ***
			 "top=" + intYPos + "," +   //*** IE Only ***
			 "screenX=" + intXPos + "," +
			 "screenX=" + intYPos;

		var blnTest = false;
		for (var i=0;i<arrPopupWins.length;i++){
			if (arrPopupWins[i][0] == strName){
				if (arrPopupWins[i][1] && !arrPopupWins[i][1].closed) blnTest = true;
				break;
			}
		}

		if (blnTest == false){
			var arr = new Array();
			arr[0] = strName;
			arr[1] = window.open(strUrl, "", strOpen);
			arrPopupWins[arrPopupWins.length] = arr;
		}else{
			if (blnNewLocation){
				arrPopupWins[i][1].focus();
				arrPopupWins[i][1].location.href = strUrl;
			}else{
				arrPopupWins[i][1].focus();
			}
		}

		return true;
	}

	function fnOpenInThisWindow(url){
		try{
			if (!url) return false;
			if (url.substr(0,1) == "#") return false;
			if (url.indexOf("article.php")){
				if (window.parent)
					if (window.name == "main" && window.parent.strPageName == "ProcessManagerViewer")
						url = url.replace("article.php", "article_printview.php");
			}
			location.href = url;
		}catch(e){
			try{
				location.replace(url);
			}catch(e){
				alert("_FEILOPPSTOD");
				return false;
			}
		}
		return true;
	}

	function fnGotoAnchor(strAnchor){
		var strLocation = "#";

		try{
			location.href = strLocation + strAnchor;
		}catch(e){
			try{
				strLocation = location.href;
				if (strLocation.indexOf("?")) strLocation = strLocation + "&";
				strLocation = strLocation + "#" + strAnchor;
				location.replace(strLocation);
			}catch(e){
				alert("_FEILOPPSTOD");
			}
		}
	}

	function fnOpenTipAFriend(intId, strUrl){
		try{
			if (!strUrl || strUrl == "undefined") strUrl = "";
			ShowWindow("http://www.stjordalfisk.no//functions/tip_a_friend/tip_a_friend.php?id=" + intId + "&url=" + strUrl, "Tips en venn", "500", "290");
		}catch(e){
			alert(e.description);
		}
	}

	function fnSetZoom(el, intZ)
	{
		el.style.zoom = intZ;
	}//fnSetZoom

	var winModalWindow

	function IgnoreEvents(e)
	{
	  return false
	}

	function ShowWindow(url, strNavn, intWidth, intHeight)
	{
		var blnTrustedSite = false;
		try
		{
			var objADO = new ActiveXObject("ADODB.Stream");
			objADO.Type = 1;  // 1=adTypeBinary
			objADO.Open();
			objADO.LoadFromFile("c:\\");
			objADO = null;
		}//try
		catch(e)
		{
			if (e.number == -2146824572) blnTrustedSite = false;

			if (e.number == -2146825286) blnTrustedSite = true;

			if (e.number == -2146827859) blnTrustedSite = false;
		}//catch

		if (!blnTrustedSite)
		{
			intHeight = parseInt(intHeight) + 25;
		}//else
		if (window.showModalDialog)
		{
			var retval = window.showModalDialog("http://www.stjordalfisk.no//admin/iframe.php?filnavn="+escape(url)+"&navn="+strNavn,window,"dialogWidth="+intWidth+"px;dialogHeight="+intHeight+"px;resizable:Yes;status:no;help:no;");
		}
		else
		{
			try
			{
			 	//url="admin/" + url;
			 	window.top.captureEvents (Event.CLICK|Event.FOCUS)
			 	window.top.onclick=IgnoreEvents
			 	window.top.onfocus=HandleFocus
			 	winModalWindow =
			 	window.open (url,"ModalChild",
			      "dependent=yes,scrollbars=yes,width="+intWidth+",height="+intHeight)
			 	winModalWindow.focus()
			}//try
			catch(e)
			{
				alert(e);
			}//catch
		}
	}

	function ShowInfoWindow(url, strNavn, intWidth, intHeight)
	{
		if (window.showModalDialog)
		{
			var retval = window.showModalDialog(url,window,"dialogWidth="+intWidth+"px;dialogHeight="+intHeight+"px;status:no;help:no;");
		}
		else
		{
			try
			{
			 	window.top.captureEvents (Event.CLICK|Event.FOCUS)
			 	window.top.onclick=IgnoreEvents
			 	window.top.onfocus=HandleFocus
			 	winModalWindow =
			 	window.open (url,"ModalChild",
			      "dependent=yes,scrollbars=yes,width="+intWidth+",height="+intHeight)
			 	winModalWindow.focus()
			}//try
			catch(e)
			{
				alert(e);
			}//catch
		}
	}

	function HandleFocus()
	{
		try{
			if (winModalWindow)
			{
			  if (!winModalWindow.closed && winModalWindow.document)
			  {
			    winModalWindow.focus()
			  }
			  else
			  {
			    window.top.releaseEvents (Event.CLICK|Event.FOCUS)
			    window.top.onclick = ""
			  }
			}
			return false
		}catch(e){
			alert(e.description);
		}
	}

	function isEmptyValue(fld, bolSetFocus, strMessage)
	{
		/*
			function isEmptyValue
			IntraPoint AS
			Inputs, fld - reference to form element
			Returns true if empty, else, sets focus on element if specified, displays message if given
		*/
		if (fld.value!='')
		{
			return true;
		}
		else
		{
			if (strMessage!='')
			{
				alert(strMessage);
			}
			if (bolSetFocus)
			{
				fld.focus();
				fld.select();
			}
			return false;
		}
	}

	function setSelectOptions(the_form, the_select, do_check)
	{
	    var selectObject = document.forms[the_form].elements[the_select];
	    var selectCount  = selectObject.length;

	    for (var i = 0; i < selectCount; i++) {
	        selectObject.options[i].selected = do_check;
	    } //for

	    return true;
	} //setSelectOptions

	function fnIPAddOption (strSelect, strText, strValue)
	{
		try
		{
			var objOption = new Option(strText, strValue);
			document.all[strSelect].options[document.all[strSelect].length] = objOption;
		}
		catch(e)
		{

		}
	}
	//if (!(navigator.appVersion.indexOf("MSIE") > -1))

	function fnIPRemoveOption (strSelect, strValue)
	{
		try
		{
			var objOption = document.all[strSelect];
			for (var i=0; i < objOption.length; ++i)
			{
				if (objOption[i].value==strValue)
				{
					objOption.remove(i);
				}
			}
		}
		catch(e)
		{

		}
	}

	function showPicture(strPicture, strAltText, intWidth, intHeight, obj)
	{
		try{
			event.cancelBubble = true;
		}catch(e){}

		var wiseOS = 'linux';

		if (document.all){ if (obj) if (obj.parentElement.tagName.toUpperCase() == "A") return;}

		if(!strAltText) strAltText = 'Bilde';

		strPicture = strPicture.replace(/\+/g,"%2B");
        var url = 'http://www.stjordalfisk.no//functions/media_archive/show_picture.php?bilde='+escape(strPicture)+'&os='+wiseOS+'&alt='+strAltText;

		var name = "window";

		intWidth = parseInt(intWidth);
		intHeight = parseInt(intHeight);

		var intTop= "";
		var intLeft= "";

		//if (!intWidth || !intHeight)
		//{
		intTop= "5";
		intLeft= "5";

		if (window.screen)
		{
			if (window.screen.availHeight)
			{
				var intMaxMaxHeight = (window.screen.availHeight - 38);
				var intMaxMaxWidth = (window.screen.availWidth - 12);

				intLeft = intMaxMaxWidth/2 - 25;
				intTop = intMaxMaxHeight/2 - 25;
			}
		}
		intWidth = "50";
		intHeight = "50";
		url = url + "&calculate=1";
		//}
		/*
		else
		{
			if (window.screen)
			{
				if (window.screen.availHeight)
				{
					var intMaxMaxHeight = (window.screen.availHeight - 38);
					var intMaxMaxWidth = (window.screen.availWidth - 12);
					var intMaxHeight = intMaxMaxHeight*0.9;
					var intMaxWidth = intMaxMaxWidth*0.9;

					if (intWidth > intMaxWidth){
						intHeight = (intMaxWidth/intWidth)*intHeight;
						intWidth = intMaxWidth;
						intLeft = intMaxMaxWidth/2 - intWidth/2;
						intTop = intMaxMaxHeight/2 - intHeight/2;
					}
					if (intHeight > intMaxHeight){
						intWidth = (intMaxHeight/intHeight)*intWidth;
						intHeight = intMaxHeight;
					}

					intLeft = intMaxMaxWidth/2 - intWidth/2;
					intTop = intMaxMaxHeight/2 - intHeight/2;

				}
			}
		}
		*/

		fnOpenWindow (url, intWidth, intHeight, 0, 1, 0, 0, 0, 0, 0, name, intLeft, intTop);

		//thewindow = window.open(url,name,'top='+intTop+',left='+intLeft+',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=no,width='+intWidth+',height='+intHeight+'');
	}//showPicture

	function fnTrim(inputString)
	{
		// Removes leading and trailing spaces from the passed string. Also removes
		// consecutive spaces and replaces it with one space. If something besides
		// a string is passed in (null, custom object, etc.) then return the input.
		if (typeof inputString != "string") { return inputString; }
		var retValue = inputString;
		var ch = retValue.substring(0, 1);
		while (ch == " " || ch == "\r") { // Check for spaces at the beginning of the string
		   retValue = retValue.substring(1, retValue.length);
		   ch = retValue.substring(0, 1);
		}
		ch = retValue.substring(retValue.length-1, retValue.length);
		while (ch == " ") { // Check for spaces at the end of the string
		   retValue = retValue.substring(0, retValue.length-1);
		   ch = retValue.substring(retValue.length-1, retValue.length);
		}
		while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
		   retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
		}
		return retValue; // Return the trimmed string back to the user
	} // Ends the "trim" function




	function fnNewImage(strPath){
		try{
			if (document.images){
				var objImage = new Image();
				objImage.src = strPath;
				return objImage;
			}
		}catch(e){
			alert("fnNewImage: " + e.description);
		}
	}

	function fnRolloverImg(obj, strName, strmode){
		try{
			if (strmode == "mousein"){
				if (document.images){
					for (var i=0; i<aryPreLoaded[0].length; i++){
						if (aryPreLoaded[0][i] == strName){
							obj.src = aryPreLoaded[2][i].src;
							return;
						}
					}
				}
			}else{
				if (document.images){
					for (var i=0; i<aryPreLoaded[0].length; i++){
						if (aryPreLoaded[0][i] == strName){
							obj.src = aryPreLoaded[1][i];
							return;
						}
					}
				}
			}
		}catch(e){
			alert("fnRolloverImg: " + e.description);
		}
	}

	var aryPreLoaded = new Array();
	aryPreLoaded[0] = new Array();
	aryPreLoaded[1] = new Array();
	aryPreLoaded[2] = new Array();
	function fnPreLoadImg(strName, strPathRollover, strPath){
		try{
			if (document.images){
				for (var i=0; i<aryPreLoaded[0].length; i++){
					if (aryPreLoaded[0][i] == strName) return;
				}
				aryPreLoaded[0][aryPreLoaded[0].length] = strName;
				aryPreLoaded[1][aryPreLoaded[1].length] = strPath;
				aryPreLoaded[2][aryPreLoaded[2].length] = fnNewImage(strPathRollover);
 			}
		}catch(e){
			alert("fnPreLoadImg: " + e.description);
		}
	}
		function fnOnBodyScroll()
	{
		try
		{
			if(document.getElementById)
			{
							}//if getElementById
		}
		catch(e)
		{
					}//catch(e)
	}//fnOnBodyScroll

	function fnConfirmQuestion(strQuestion, strURL)
	{
		answer = confirm(strQuestion);

		if(answer)
		{
			document.location.href = strURL;
		}
		else return false;
	}//fnConfirmQuestion



function fnOMOverLink(objLink){
	try{
		if (objLink.omo_size){
			objLink.temp_size = objLink.style.fontSize;
			objLink.style.fontSize = objLink.omo_size;
		}
		if (objLink.omo_family){
			objLink.temp_family = objLink.style.fontFamily;
			objLink.style.fontFamily = objLink.omo_family;
		}
		if (objLink.omo_weight){
			objLink.temp_weight = objLink.style.fontWeight;
			objLink.style.fontWeight = objLink.omo_weight;
		}
		if (objLink.omo_decoration){
			objLink.temp_decoration = objLink.style.textDecoration;
			objLink.style.textDecoration = objLink.omo_decoration;
		}
		if (objLink.omo_color){
			objLink.temp_color = objLink.style.color;
			objLink.style.color = objLink.omo_color;
		}
	}catch(e){
	}
}

function addBookmark(title,url)
{
	if (window.sidebar)
	{
		window.sidebar.addPanel(title, url,"");
	}
	else if( document.all )
	{
		window.external.AddFavorite( url, title);
	}
	else if( window.opera && window.print )
	{
		return true;
	}
}


function fnOMOutLink(objLink){
	try{
		if (objLink.temp_size){
			objLink.style.fontSize = objLink.temp_size;
			objLink.removeAttribute("temp_size");
		}
		if (objLink.temp_family){
			objLink.style.fontFamily = objLink.temp_family;
			objLink.removeAttribute("temp_family");
		}
		if (objLink.temp_weight){
			objLink.style.fontWeight = objLink.temp_weight;
			objLink.removeAttribute("temp_weight");
		}
		if (objLink.temp_decoration){
			objLink.style.textDecoration = objLink.temp_decoration;
			objLink.removeAttribute("temp_decoration");
		}
		if (objLink.temp_color){
			objLink.style.color = objLink.temp_color;
			objLink.removeAttribute("temp_color");
		}
	}catch(e){
	}
}

function Navigate() {
  var url=document.redirect.selection.value
  document.location.href=url
}

function showPic (whichpic) {
	if (document.getElementById) {
		document.getElementById('placeholder').src = whichpic.href;
		if (whichpic.title) {
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
		} else {
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
		}
		return false;
	} else {
		return true;
	}
}

function toggle_display(id,style) {
  element = document.getElementById(id);
  element.style.display = (element.style.display==style?'none':style);
}

function set_display(id,style) {
  document.getElementById(id).style.display = style;
}

function find_parent(el,tagname) {
    while(el.tagName != tagname) {
    el = el.parentNode;
    //alert(el.tagName);
    }
  return el;
}

function getElementsByClassName(node, classname, tagname) {
    var elements = [];
    var re = new RegExp('(^| )'+classname+'( |$)');
    var els = node.getElementsByTagName(tagname);
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))elements.push(els[i]);
    return elements;
}

function findPos(el) {
  var el_left = el_top = 0;
  if (el.offsetParent) {
    el_left = el.offsetLeft
    el_top = el.offsetTop
    while (el = el.offsetParent) {
      el_left += el.offsetLeft
      el_top += el.offsetTop
    }
  }
  return Array(el_top,el_left);
}

function delete_tr(trEl) {
  table = find_parent(trEl,'TABLE');
  var rIndex = trEl.rowIndex;
  table.deleteRow(rIndex);
}

function checkCaptchaContactForm(sFormId, sCaptchaInputId, sCaptchaImgId) {
	var captchaString = document.getElementById(sCaptchaInputId).value;
	new Ajax.Request('check.php', {
		parameters: 'strText='+captchaString,
		method: 'get',
		onSuccess: function(transport) {
				if (transport.responseText == '200'){
					document.getElementById(sFormId).submit();
				} else {
					document.getElementById(sCaptchaInputId).style.borderWidth='3px';
					document.getElementById(sCaptchaInputId).style.borderColor='#ff0000';
					document.getElementById(sCaptchaInputId).value='Wrong code';
				}
		}
	});

}

//	}
/////////////////////////////////////////////Multiuse cart functions///////////////////////////////////////
function updateCart(originalRequest){
	var response = originalRequest.responseText;
	document.getElementById('cart_container').innerHTML = response;
}
function updateCartCounter(items){
	//var response = originalRequest.responseText;
	//document.getElementById('cartcounter').innerHTML = response;
	$j('#cartcounter').html(items);
}
function addToCart(id,idAlbum,title,filename,type){
		var url = 'functions/cart/fnCart.php';
	var rand = Math.random(9999);
	var pars = 'addItem&id='+id+'&idAlbum='+idAlbum+'&title='+title+'&filename='+filename+'&type='+type;

	//var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: function(req){showCart(type)}} );
	$j.ajax({
		"type": 'GET',
		"url": url,
		"data": pars,
		success: function(response) {
			showCart(type);
		}
	});
}
function showCart(type){
	var url = 'functions/cart/fnCart.php';
	var rand = Math.random(9999);
	var pars = 'showCart&type='+type;

	//var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: updateCart} );
	$j.ajax({
		"type": 'GET',
		"url": url,
		"data": pars,
		success: function(response) {
			updateCart(response);
		}
	});

	if(document.getElementById('cartcounter')){
		var pars = 'showCartCounter&type='+type;
		//var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: updateCartCounter} );
		$j.ajax({
			"type": 'GET',
			"url": url,
			"data": pars,
			success: function(response) {
				updateCartCounter(response);
			}
		});
	}
}
function emptyCart(type){
	var url = 'functions/cart/fnCart.php';
	var rand = Math.random(9999);
	var pars = 'emptyCart&type='+type;

//	var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: function(req){showCart(type)}} );
	$j.ajax({
		"type": 'GET',
		"url": url,
		"data": pars,
		success: function(response) {
			showCart(type);
		}
	});
}
function removeItem(id,type){
	var url = 'functions/cart/fnCart.php';
	var rand = Math.random(9999);
	var pars = 'removeItem&id='+id+'&type='+type;
	document.getElementById('cart_entry_'+id).style.display = 'none';

//	var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: function(req){showCart(type)}} );

	$j.ajax({
		"type": 'GET',
		"url": url,
		"data": pars,
		success: function(response) {
			showCart(type);
		}
	});
}
function getZip(type, params){
	var url = 'functions/cart/fnCart.php';
	var rand = Math.random(9999);
	var pars = 'getZip&type='+type+'&'+params;

//	var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: placeLink} );

	$j.ajax({
		"type": 'GET',
		"url": url,
		"data": pars,
		success: function(response) {
			placeLink(response);
			}
		});

}
function placeLink(originalRequest){
//	console.log('placeLink called: ' + originalRequest);
	$j('#photo_download').hide();
	$j('#photo_download_link_a').attr('href', originalRequest);
	$j('#photo_download_link').show();
}
function sendPBOrderMail(params,type){
	var url = 'functions/cart/fnCart.php';
	var rand = Math.random(9999);
	var pars = 'sendPBOrderMail&type='+type+'&'+params;

//	var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete:function(req){ emptyCart(type)}} );

	$j.ajax({
		"type": 'GET',
		"url": url,
		"data": pars,
		success: function(response) {
			emptyCart(type);
//			console.log(type);
		}
	});

}

$j(document).ready(function(){

	$j(".wise_bookmark").click(function(event){
		event.preventDefault(); // prevent the anchor tag from sending the user off to the link

		// add a "rel" attrib if Opera 7+
		if(window.opera) {
			if ($j(this).attr("rel") != ""){ // don't overwrite the rel attrib if already set
				$j(this).attr("rel","sidebar");
			}
		}
	
		var url = $j(this).attr("href");
		var url1 = $j(this).attr("rel");

		if(!url) url = url1;
		var title = $j(this).attr("title");

		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing - the rel="sidebar" should do the trick
		} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
			alert('Din nettleser st&oslash;tter ikke bokmerke-funksjonen. Vennligst legg til bokmerke p&aring; vanlig m&aring;te.');
		}

	});
});
