
function swapRanges(elementlow,elementhigh,form){var low=document.forms[form].elements[elementlow].value;var high=document.forms[form].elements[elementhigh].value;if(low.value>high.value&&low!=""&&high!=""){document.forms[form].elements[elementlow].value=high;document.forms[form].elements[elementhigh].value=low;}}
function searchAll(radioObject,form1){if(radioObject[1].checked){document.forms['hiddenform'].elements['keyword'].value=form1.elements['keyword'].value;document.forms['hiddenform'].elements['sort'].value=form1.elements['sort'].value;document.forms['hiddenform'].submit();return false;}
else{form1.submit();return true;}}
function swapCurrency(formname,tofield,fromfield,selectedNo){document.forms[formname].elements[tofield].value=document.forms[formname].elements[fromfield].options[selectedNo].text;}
function expandCollapse(){for(var i=0;i<expandCollapse.arguments.length;i++){var element=document.getElementById(expandCollapse.arguments[i]);element.style.display=(element.style.display=="none")?"block":"none";}}
function expandCollapse2(o){var n=o.nextSibling;while(n.nodeType!=1)n=n.nextSibling;n.style.display=(o.className=="expand")?"block":"none";o.className=(o.className=="expand")?"collapse":"expand";}
function expandCollapseInitiallyHidden(){for(var i=0;i<expandCollapseInitiallyHidden.arguments.length;i++){var element=document.getElementById(expandCollapseInitiallyHidden.arguments[i]);element.style.display=(element.style.display=="block")?"none":"block";}}
function hideIfEmpty(emptyTag,hideTag){if(hideTag===null){hideTag=emptyTag;}
var e=document.getElementById(emptyTag);if(isEmpty(e)){hide(hideTag);}}
function isEmpty(element){if(element!==null&&element.childNodes!==null&&element.childNodes.length<=1){if(!element.childNodes.length){return 1;}else if(element.childNodes.length==1&&element.childNodes[0].data!==null&&!element.childNodes[0].data.match("[^ \t\n]")){return 1;}}
return null;}
function _addEventListener(element,eventName,func){if(element.addEventListener){element.addEventListener(eventName,func,false);}else if(element.attachEvent){element.attachEvent('on'+eventName,func);}else{element['on'+eventName]=func;}}
function show(object,displayMode){if(document.getElementById&&document.getElementById(object)!==null){document.getElementById(object).style.visibility='visible';document.getElementById(object).style.display=displayMode?displayMode:'';}else if(document.layers&&document.layers[object]!==null){document.layers[object].visibility='visible';}else if(document.all){document.all[object].style.zIndex=100;document.all[object].style.visibility='visible';}}
function hide(object){if(document.getElementById&&document.getElementById(object)!==null){document.getElementById(object).style.visibility='hidden';document.getElementById(object).style.display='none';}else if(document.layers&&document.layers[object]!==null){document.layers[object].visibility='hidden';}else if(document.all){document.all[object].style.visibility='hidden';}}
if(document.getElementById){document.write('<style>.contractArticle {position:absolute;visibility:hidden;display:none}</style>');}
function disableButton(button,disabledButtonText,disabledStyle){if(!disabledButtonText){disabledButtonText='   Vent...   ';}
button.onclick=preventDefaultAction;button.value=disabledButtonText;if(disabledStyle){button.className=disabledStyle;}else if(button.style){button.style.color='#BBBBBB';}}
function preventDefaultAction(event){if(!event){event=window.event;}
if(event){if(event.preventDefault){event.preventDefault();}else{event.returnValue=false;}}
return false;}
function submitForm(formName){document[formName].submit();}
function setFormAction(formName,actionValue){document[formName].action=actionValue;}
function setUserAction(formName,actionField,actionValue){document[formName].elements[actionField].value=actionValue;}
function setNextStep(formName,value){document[formName].nextStep.value=value;}
function changeImage(name,text){document.images["main"].src=name;document.all.imagetext.innerText=text;}
function submitToNewWindow(form,action,width,height){function disableFileUpload(disable){for(elemName in form.elements){var elem=form.elements[elemName];if(elem!==null&&elem.type=='file'){elem.disabled=disable;}}}
if(!width){width=740;}
if(!height){height=540;}
if(!action){action=form.action;}
var oldTarget=form.target;var oldAction=form.action;var windowName="popupwindow";openWindow('',width,height,windowName);form.target=windowName;form.action=action;disableFileUpload(true);form.submit();disableFileUpload(false);form.target=oldTarget;form.action=oldAction;return false;}
function openWindow(url,width,height,name){if(!name){name="";}
var win;win=window.open(url,name,"toolbar=no,location=no,directories=no,status=no,menubar=0,resizable=0,copyhistory=no,width="+width+",height="+height+",scrollbars=1");if(((navigator.appName.indexOf("Netscape")!=-1)&&(parseInt(navigator.appVersion)>=3))||((navigator.userAgent.indexOf("MSIE")!=-1)&&(parseInt(navigator.appVersion)>=4))){win.focus();}}
function openMapWindow(url){mapwin=window.open(url,"Kart","toolbar=no,location=no,directories=no,status=no,menubar=0,resizable=1,copyhistory=no,width=805,height=860,screenX=0,screenY=0,scrollbars=yes");if(((navigator.appName.indexOf("Netscape")!=-1)&&(parseInt(navigator.appVersion)>=3))||((navigator.userAgent.indexOf("MSIE")!=-1)&&(parseInt(navigator.appVersion)>=4))){mapwin.focus();}}
function checkTextareaMaxLength(textarea,evt,maxLength){if(textarea.selected&&evt.shiftKey){return true;}
var allowKey=false;if(textarea.selected&&textarea.selectedLength>0){allowKey=true;}else{var keyCode=evt.which?evt.which:evt.keyCode;if(keyCode<48&&keyCode!=13&&keyCode!=32){allowKey=true;}else{allowKey=textarea.value.length<maxLength;}}
textarea.selected=false;if(!allowKey){evt.returnValue=false;if(evt.preventDefault){evt.preventDefault();}}
return allowKey;}
function addTextAreaCounter(textareaName,maxLength,alertMessage){var textarea=document.getElementById(textareaName);var textareaCounterName=textareaName+'Counter';function updateCounter(){var value=maxLength-textarea.value.length;var counter=textarea.form[textareaCounterName];counter.value=value;}
function onKeyPressHandler(evt){if(!evt){evt=window.event;}
return checkTextareaMaxLength(textarea,evt,maxLength);}
function onBlurHandler(){if(textarea.value.length>maxLength&&alertMessage){alert(alertMessage);if(textarea.focus){textarea.focus();}}}
if(!textarea.form[textareaCounterName]){document.writeln('<input disabled type="text" name="'+textareaCounterName+'" size="3" maxlength="3" value=""> tegn igjen');updateCounter();textarea.onkeypress=onKeyPressHandler;textarea.onkeyup=textarea.onkeydown=updateCounter;textarea.onblur=onBlurHandler;}else{alert('Error in addTextAreaCounter(): Form already contains a child node named "'+textareaCounterName+'".');}}
function allChecked(formname,fieldname){var nr,value;if(!document[formname].elements[fieldname].length){nr=1;}else{nr=document[formname].elements[fieldname].length;}
if(document[formname].elements["all_"+fieldname].checked){value=true;}else{value=false;}
for(var i=0;i<nr;i++){if(nr==1){document[formname].elements[fieldname].checked=value;}else{document[formname].elements[fieldname][i].checked=value;}}}
function setGroupChecked(formname,fieldname,newstate){var nr;if(!document[formname].elements[fieldname].length){nr=1;}else{nr=document[formname].elements[fieldname].length;}
for(var i=0;i<nr;i++){if(nr==1){document[formname].elements[fieldname].checked=newstate;}else{document[formname].elements[fieldname][i].checked=newstate;}}}
function splitComposite(form,compositefield,field1,field2){var compValue=document.forms[form].elements[compositefield].value;var tmpArr=compValue.split("|");document.forms[form].elements[field1].value=tmpArr[0];document.forms[form].elements[field2].value=tmpArr[1];}
function setSelected(form,field){if(document.forms[form].elements[field].options){var length=Number(document.forms[form].elements[field].options.length);for(var i=0;i<length;i++){document.forms[form][field][i].selected=true;}}}
function copyChild(form,parent,from,to,parentfield,insertparenttext){var parentLenght=Number(document.forms[form].elements[parent].options.length);var parentText="";var parentValue="";for(var p=0;p<parentLenght;p++){if(document.forms[form].elements[parent].options[p].selected){parentText=document.forms[form].elements[parent].options[p].text;parentValue=document.forms[form].elements[parent].options[p].value;}}
var length=Number(document.forms[form].elements[from].options.length);for(var i=0;i<length;i++){if(document.forms[form][from][i].selected){var valuefrom=document.forms[form][from][i].value;var textfrom=parentText+" "+document.forms[form][from][i].text;var all=false;if(valuefrom=='0'){all=true;}
var exists=false;var tolength=Number(document.forms[form].elements[to].options.length);for(var j=0;j<tolength;j++){var valueto=document.forms[form][to][j].value;var textto=document.forms[form][to][j].text;if(valueto==valuefrom&&valueto||(textto==textfrom)){exists=true;}}
if(!exists){if(!insertparenttext){parentText="";}
var l=document.forms[form].elements[to].options.length;if(all){document.forms[form][to][l]=new Option(parentText+" "+document.forms[form][from][i].text,parentValue);}else{document.forms[form][to][l]=new Option(parentText+" "+document.forms[form][from][i].text,document.forms[form][from][i].value);}
document.forms[form][to][l].selected=true;}}}}
function deleteChild(form,from,all,parentfield){var i,length=Number(document.forms[form].elements[from].options.length);if(!all){for(i=length-1;i>=0;i--){if(document.forms[form][from][i].selected){if(navigator.appName.indexOf("Netscape")!=-1){document.forms[form].elements[from].options[i]=null;}else if(navigator.userAgent.indexOf("Opera")!=-1){document.forms[form].elements[from].options.remove(i);}else if((navigator.userAgent.indexOf("MSIE")!=-1)&&(parseInt(navigator.appVersion)>=4)){document.forms[form].elements[from].options.remove(i);}else if((navigator.userAgent.indexOf("MSIE")!=-1)&&(parseInt(navigator.appVersion)<4)){document.forms[form].elements[from].options[i].selected=false;}else{document.forms[form].elements[from].options[i].selected=false;}}else{document.forms[form].elements[from].options[i].selected=true;}}}else{if(navigator.appName.indexOf("Netscape")!=-1){for(i=(length);i>=0;i--){document.forms[form].elements[from].options[i]=null;}}else if(navigator.userAgent.indexOf("Opera")!=-1){for(i=(length);i>=0;i--){document.forms[form].elements[from].options.remove(i);}}else if((navigator.userAgent.indexOf("MSIE")!=-1)&&(parseInt(navigator.appVersion)>=4)){for(i=(length);i>=0;i--){document.forms[form].elements[from].options.remove(i);}}else if((navigator.userAgent.indexOf("MSIE")!=-1)&&(parseInt(navigator.appVersion)<4)){for(i=(length-1);i>=0;i--){document.forms[form].elements[from].options[i].selected=false;}}else{for(i=(length-1);i>=0;i--){document.forms[form].elements[from].options[i].selected=false;}}}}
function setCheckedRegions(form,name,value){var valueArr=value.split(";");for(var i=0;i<document[form][name].length;i++){for(var ii=0;ii<valueArr.length;ii++){if(document[form][name][i].value==valueArr[ii]){document[form][name][i].checked=true;}}}}
function setCheckedSubRegions(form,name,name2,value,subRegion){var childs=childArr[value];var tmpArr=childs.split("|");var tmpArr2;var id;var checked=document[form][name][value].checked;if(!subRegion){var exit=false;for(var d=0;d<document[form][name2].length;d++){for(var c=0;c<tmpArr.length;c++){tmpArr2=tmpArr[c].split(";");id=tmpArr2[0];if(document[form][name2][d].value==id){document[form][name2][d].checked=checked;exit=true;}}}}else{checked=true;for(var s=0;s<tmpArr.length;s++){if(!document[form][name2][s].checked){checked=false;}}
if(checked){document[form][name][value].checked=true;}else{document[form][name][value].checked=false;}}}
function setCheckedSubRegionsVisible(form,name,value,regions){var subRegionsArr;var tempArr;var lastChanged;var found=false;var valueArr=value.split(";");var mainRegionsArr=regions.split("#");for(var i=0;i<mainRegionsArr.length;i++){tempArr=mainRegionsArr[i].split("|");subRegionsArr=tempArr[1].split(";");for(var ii=0;ii<subRegionsArr.length;ii++){for(var iii=0;iii<valueArr.length;iii++){if(subRegionsArr[ii].length>0&&valueArr[iii].length>0&&subRegionsArr[ii]==valueArr[iii]){if(lastChanged!=tempArr[0]){menu("submenu"+tempArr[0]);swapImage(tempArr[0]);lastChanged=tempArr[0];}}}}}}
function fillChilds(form,name1,name2,allchilds,allparents){emptySelectBox(form,name1,allchilds);var childid=0;var start=1;var name2Length=document[form][name2].length;if(allchilds){childid=1;}
if(!allparents){start=0;}
var selectedvalue=0;for(var i=start;i<name2Length;i++){if(document[form][name2][i].selected){selectedvalue=parentArr[i-start].split(";")[0];var tmpArr=childArr[i-start].split("|");for(var j=0;j<tmpArr.length;j++){var tmpArr2=tmpArr[j].split(";");document[form].elements[name1].options[childid]=new Option(tmpArr2[1],tmpArr2[0]);childid++;}}}
if(allchilds){document[form].elements[name1].options[0].value='0';}}
function fillChilds_FirstEntryCustomised(form,name1,name2,allparents,value,text){var childid=0;var start=1;var name2Length=document[form][name2].length;if(!allparents){start=0;}
var selectedvalue=0;for(var i=start;i<name2Length;i++){if(document[form][name2][i].selected){document[form].elements[name1].options.length=0;document[form].elements[name1].options[childid]=new Option(text,value);childid++;selectedvalue=parentArr[i-start].split(";")[0];var tmpArr=childArr[i-start].split("|");for(var j=0;j<tmpArr.length;j++){var tmpArr2=tmpArr[j].split(";");document[form].elements[name1].options[childid]=new Option(tmpArr2[1],tmpArr2[0]);childid++;}}}}
function showCvLink(){document.getElementById("link").style.visibility='visible';}
function hideCvLink(){document.getElementById("link").style.visibility='hidden';}
function fillChildsLocation(form,name1,name2,allchilds,allparents){emptySelectBox(form,name1,allchilds);var childid=0;var start=1;var name2Length=document[form][name2].length;if(allchilds){childid=1;}
if(!allparents){start=0;}
var selectedvalue=0;for(var i=start;i<name2Length;i++){if(document[form][name2][i].selected){selectedvalue=parentArrLocation[i-start].split(";")[0];var tmpArr=childArrLocation[i-start].split("|");for(var j=0;j<tmpArr.length;j++){var tmpArr2=tmpArr[j].split(";");document[form].elements[name1].options[childid]=new Option(tmpArr2[1],tmpArr2[0]);childid++;}}}
if(allchilds){document[form].elements[name1].options[0].value='0';}}
function rememberoptions_load(inputSelect){if(inputSelect&&inputSelect.form&&inputSelect.options){var hValues=inputSelect.form[inputSelect.name+'_values'];var hText=inputSelect.form[inputSelect.name+'_text'];var hSelected=inputSelect.form[inputSelect.name+'_selected'];if(hValues&&hText&&hSelected&&hValues.value&&hValues.value.length>0){var optionValues=hValues.value.split(';');var optionText=hText.value.split(';');var optionSelected=hSelected.value.split(';');emptySelectBox(inputSelect.form.name,inputSelect.name,true);for(var i=0;i<optionValues.length;++i){var option=new Option(optionText[i],optionValues[i]);inputSelect.options[i]=option;for(var j=0;j<optionSelected.length;++j){if(option.value==optionSelected[j]){option.selected=true;}}}}}}
function rememberoptions_save(inputSelect){if(inputSelect&&inputSelect.form&&inputSelect.options){var options=inputSelect.options;var optionValues=new Array(),optionText=new Array(),optionSelected=new Array();for(var i=0;i<options.length;++i){var option=options[i];optionValues.push(option.value);optionText.push(option.text);if(option.selected){optionSelected.push(option.value);}}
inputSelect.form[inputSelect.name+'_values'].value=optionValues.join(';');inputSelect.form[inputSelect.name+'_text'].value=optionText.join(';');inputSelect.form[inputSelect.name+'_selected'].value=optionSelected.join(';');}}
function rememberoptions_registerEventHandlers(formName,selectTagName){if(!formName||!formName.length){var tags=document.getElementsByName(selectTagName);if(tags.length>0&&tags[0]&&tags[0].form&&tags[0].form.name){formName=tags[0].form.name;}}
var form=document.forms[formName];if(form){var selectTag=form[selectTagName];if(selectTag){_addEventListener(form,'submit',function(){rememberoptions_save(selectTag);});_addEventListener(window,'load',function(){rememberoptions_load(selectTag);});}}}
function emptySelectBox(form,boxname,allchilds){var i,length=Number(document.forms[form].elements[boxname].options.length);if(navigator.appName.indexOf("Netscape")!=-1){for(i=(length);i>0;i--){document.forms[form].elements[boxname].options[i]=null;}}else if(navigator.userAgent.indexOf("Opera")!=-1){for(i=(length);i>0;i--){document.forms[form].elements[boxname].options.remove(i);}}else if((navigator.userAgent.indexOf("MSIE")!=-1)&&(parseInt(navigator.appVersion)>=4)){for(i=(length);i>0;i--){document.forms[form].elements[boxname].options.remove(i);}}else if((navigator.userAgent.indexOf("MSIE")!=-1)&&(parseInt(navigator.appVersion)<4)){for(i=(length-1);i>0;i--){document.forms[form].elements[boxname].options[i].selected=false;}}else{for(i=(length-1);i>0;i--){document.forms[form].elements[boxname].options[i].selected=false;}}
if(navigator.appName.indexOf("Netscape")==-1){if(allchilds){document.forms[form].elements[boxname].options[0]=new Option("Alle","0",true,true);}else{document.forms[form].elements[boxname].options[0]=new Option("","0",true,true);}
document.forms[form].elements[boxname].options[0].selected=true;}}
function removeNonDigits(inputObject){inputObject.value=inputObject.value.replace(/[\.,:]-$/,'');inputObject.value=inputObject.value.replace(/[\.,:][0-9][0-9]$/,'');inputObject.value=inputObject.value.replace(/[^0-9]/g,'');}
function removeNonDigitsSimple(inputObject){inputObject.value=inputObject.value.replace(/[\.,][0-9][0-9]$/,'');inputObject.value=inputObject.value.replace(/[\.,][0-9]$/,'');inputObject.value=inputObject.value.replace(/[., ]/g,'');}
function removePrecedingZeros(inputObject){inputObject.value=inputObject.value.replace(/^0+/,'');}
function removeExceptNumbersAndLetters(inputObject){inputObject.value=inputObject.value.replace(/[^a-zA-Z0-9]/g,'');}
function removeExceptNumbersAndPlus(inputObject){inputObject.value=inputObject.value.replace(/[-\.\\,: ]/g,'');inputObject.value=inputObject.value.replace(/[a-zA-Z]/g,'');}
function convertCommaToPeriod(inputObject){inputObject.value=inputObject.value.replace(/\,/,'.');}
function MM_findObj(n,d){var p,i,x;if(!d){d=document;}
if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all){x=d.all[n];}
for(i=0;!x&&i<d.forms.length;i++){x=d.forms[i][n];}
for(i=0;!x&&d.layers&&i<d.layers.length;i++){x=MM_findObj(n,d.layers[i].document);}
if(!x&&d.getElementById){x=d.getElementById(n);}
return x;}
function menu(objName){var theValue;var obj=MM_findObj(objName);var theProp="style.display";if(obj.style.display=="none"){theValue="block";}else{theValue="none";}
if(obj&&(theProp.indexOf("style.")==-1||obj.style)){if(theValue===true||theValue===false){eval("obj."+theProp+"="+theValue);}else{eval("obj."+theProp+"='"+theValue+"'");}}}
function swapImage(intImage){var filenamePosition=document.getElementById("image"+intImage).src.indexOf('collapse.gif');var originalSrc=document.getElementById("image"+intImage).src;if(filenamePosition>0){document.getElementById("image"+intImage).src=originalSrc.substring(0,filenamePosition)+'expand.gif';}else{filenamePosition=document.getElementById("image"+intImage).src.indexOf('expand.gif');document.getElementById("image"+intImage).src=originalSrc.substring(0,filenamePosition)+'collapse.gif';}
return(false);}
function toggleMap()
{el=document.getElementById('imgmap1');var display=el.style.display?'':'none';el.style.display=display;el=document.getElementById('imgmap2');display=el.style.display?'':'none';el.style.display=display;}
function concat_collections(){var result=new Array();for(var i=0;i<concat_collections.arguments.length;++i){var collection=concat_collections.arguments[i];for(var j=0;j<collection.length;++j){result.push(collection[j]);}}
return result;}
function toggle_enable_inputfields(parentTagId,enable,disabledBgColor){var parentTag=document.getElementById(parentTagId);if(parentTag){var inputFields=concat_collections(parentTag.getElementsByTagName('input'),parentTag.getElementsByTagName('textarea'));for(var i=0;i<inputFields.length;++i){inputFields[i].disabled=!enable;if(inputFields[i].runtimeStyle){if(!disabledBgColor){disabledBgColor='#DDDDDD';}
inputFields[i].runtimeStyle.backgroundColor=enable?'':disabledBgColor;}}}}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name){createCookie(name,"",-1);}
function copyText(){document.update.rss.focus();document.update.rss.select();var t=document.selection.createRange();t.execCommand("Copy");alert("Linken er kopiert");}
function toggleTooltipOn(imageUrl,iFrameName,iFrameHeight,iFrameWidth,iFrameBgColor,iFrameBodyStyles){var iFrame=document.getElementById(iFrameName);iFrame.style.top=iFrame.offsetTop;iFrame.style.left=iFrame.offsetLeft;iFrame.style.height=iFrameHeight;iFrame.style.width=iFrameWidth;var doc=iFrame.contentDocument;if(doc==undefined||doc==null)
doc=iFrame.contentWindow.document;doc.open();doc.write("<html><head></head><body style="+"\""+iFrameBodyStyles+"\" bgColor="+"\""+iFrameBgColor+"\">"+"<img src="+"\""+imageUrl+"\""+"></body></html>");doc.close();iFrame.style.visibility="visible";}
function toggleTooltipOff(iFrameName){var iFrame=document.getElementById(iFrameName);iFrame.style.visibility="hidden";}
Number.prototype.addPrefix=function(){return(this<10)?'0'+this:this;}
function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){oldonload();func();}}}
function getRealPosition(currentObject,coordinate){this.pos=(coordinate=='x')?currentObject.offsetLeft:currentObject.offsetTop;this.tmp=currentObject.offsetParent;while(this.tmp!=null){this.pos+=(coordinate=='x')?this.tmp.offsetLeft:this.tmp.offsetTop;this.tmp=this.tmp.offsetParent;}
return this.pos;}
function formatWithThousandSeparator(input){var num=input.value.replace(/\./g,'');if(!isNaN(num)){num=num.toString().split('').reverse().join('');num=num.replace(/(?=\d*\.?)(\d{3})/g,'$1.');num=num.split('').reverse().join('').replace(/^[\.]/,'');input.value=num;}else{input.value=input.value.replace(/[^\d\.]*/g,'');}}
function formatNumber(input){if(input){var num=input.value;if(!isNaN(num)){input.value=num;}else{input.value=input.value.replace(/[^\d\.]*/g,'');}}}
function adjustImageSize(myAnchor,myMaxWidth,myMaxHeight){var myAnchorElement=document.getElementById(myAnchor);if(myAnchorElement){var myImages=myAnchorElement.getElementsByTagName("img");if(myImages){for(var x=0;x<myImages.length;x++){if(myImages[x].width>myMaxWidth){myImages[x].width=myMaxWidth;}
if(myImages[x].height>myMaxHeight){myImages[x].height=myMaxHeight;}}}}}
function isSingle(jsonObject){var counter=0;var single=true;for(k in jsonObject){counter++;if(counter>1){single=false;break;}}
return single;}
function jQueryFillList(field,options,topOptionLabel,jqvar){if(!jqvar){jqvar=jQuery.noConflict();}
jqvar(field).removeOption(/./).removeOption(0);if(topOptionLabel&&!isSingle(options)){jqvar(field).addOption("",topOptionLabel);}
jqvar(field).addOption(options,false);}
function updateOrder(form,ajaxUrl){var $j=jQuery.noConflict();var parameters=$j(form).serialize();$j.ajax({url:ajaxUrl,type:'POST',dataType:'html',timeout:2000,data:parameters,error:function(){},success:function(html){$j("div#order").html(html);}});}
function validateCoordinate(formName,fieldName,type,errorMsg){var maxLat=90;var minLat=-90;var maxLong=180;var minLong=-180;var value=document.forms[formName].elements[fieldName].value;if(type=="long"){if(value>maxLong||value<minLong)
alert(errorMsg);}
else if(type=="lat"){if(value>maxLat||value<minLat)
alert(errorMsg);}}
function validateRadius(formName,fieldName,errorMsg){var MAX_VALUE=40000000;var value=parseInt(document.forms[formName].elements[fieldName].value);if(isNaN(value)||!isFinite(value)){alert(errorMsg);document.forms[formName].elements[fieldName].value=0;}
if(value<0){document.forms[formName].elements[fieldName].value=0;alert(errorMsg);}
if(value>MAX_VALUE){document.forms[formName].elements[fieldName].value=MAX_VALUE;alert(errorMsg);}}
IADLIB={version_title:"iAD javascript library",version_major:0,version_minor:1,addMeta:function(name,content){var meta;if(document.createElement&&(meta=document.createElement('meta'))){meta.name=name;meta.content=content;document.getElementsByTagName('head').item(0).appendChild(meta);}},showAllMetaTags:function(){var elems=document.getElementsByTagName('meta');if(elems){for(var i=0;i<elems.length;i++){alert(elems[i]['name']);}}else{alert("No meta elements found");}},toString:function(){return(IADLIB.version_title+" "+IADLIB.version_major+"."+IADLIB.version_minor);}};function Cookie(document,name,hours,path,domain,secure)
{this.$document=document;this.$name=name;if(hours)
this.$expiration=new Date((new Date()).getTime()+hours*3600000);else this.$expiration=null;if(path)this.$path=path;else this.$path=null;if(domain)this.$domain=domain;else this.$domain=null;if(secure)this.$secure=true;else this.$secure=false;}
Cookie.prototype.store=function(){var cookieval="";for(var prop in this){if((prop.charAt(0)=='$')||((typeof this[prop])=='function'))
continue;if(cookieval!="")cookieval+='&';cookieval+=prop+':'+escape(this[prop]);}
var cookie=this.$name+'='+cookieval;if(this.$expiration)
cookie+='; expires='+this.$expiration.toGMTString();if(this.$path)cookie+='; path='+this.$path;if(this.$domain)cookie+='; domain='+this.$domain;if(this.$secure)cookie+='; secure';this.$document.cookie=cookie;}
Cookie.prototype.load=function(){var allcookies=this.$document.cookie;if(allcookies=="")return false;var start=allcookies.indexOf(this.$name+'=');if(start==-1)return false;start+=this.$name.length+1;var end=allcookies.indexOf(';',start);if(end==-1)end=allcookies.length;var cookieval=allcookies.substring(start,end);var a=cookieval.split('&');for(var i=0;i<a.length;i++)
a[i]=a[i].split(':');for(var i=0;i<a.length;i++){this[a[i][0]]=unescape(a[i][1]);}
return true;}
Cookie.prototype.remove=function(){var cookie;cookie=this.$name+'=';if(this.$path)cookie+='; path='+this.$path;if(this.$domain)cookie+='; domain='+this.$domain;cookie+='; expires=Fri, 02-Jan-1970 00:00:00 GMT';this.$document.cookie=cookie;}
