$(function() {
	if($.cookie("location")!=window.location && (window.location+"").indexOf("prospekt") == -1) {
		Eie.reset_BrowserPos();
	}
	if((window.location+"").indexOf("prospekt") == -1)
		$.cookie("location",window.location);
	
	if((window.location+"").indexOf("prospekt") > 0) {
		Brog.init({
			  moogover : [
			   "#icons img"
			  ],
			  preload  : [
			   "gfx/v2/icon_visningsfilm_o.gif",
				 "gfx/v2/icon_360_o.gif",
				 "gfx/v2/icon_prospekt_o.gif",
				 "gfx/v2/icon_nettside_o.gif",
				 "gfx/v2/icon_plantegning_o.gif"
				]
			 });
	}
	
});
var Brog = {
	init : function(options) {
		if(options.moogover) this.setMoogOver(options.moogover);
		if(options.preload) this.preloadImages(options.preload);
	},
	setMoogOver : function(imgs) {
		$.each(imgs, function(i, img) {
			$(img).hover(function() {
				$(this).attr("src", $(this).attr("src").replace(".","_o."));
			}, function() {
				$(this).attr("src", $(this).attr("src").replace("_o.","."));
			});
		});
	}, 
	preloadImages : function(imgs) {
		$.each(imgs, function(i, img) {
			var pimg = new Image();
      pimg.src = img;
		});
	}
};
var Eie = {
	objMoogOver : function() {
		$(".dimx a").css("color","white").css("text-decoration","none");
		$(".dimx").css("opacity","0.5")
			.hover(function() {
			$(this).css("opacity","1.0");
		}, function() {
			$(this).css("opacity","0.5");
		});
	},
	onLoading : function() {
		//leave this one empty. will be overwritten by sack
	},
	onCompletion : function() {
		//leave this one empty. will be overwritten by sack
	},
	previous : function(btype) {
		this.setBrowserPos(-1,btype);
		this.disableCmd("axNext", false);
	},
	next : function(btype) {
		this.setBrowserPos(+1,btype);
	},
	printResult : function() {
		
	},
	setBrowserPos : function(posChange, btype) {
		var newPos = parseInt($.cookie("#axBrowserPos"));
		newPos += parseInt(posChange);
		$.cookie("#axBrowserPos",newPos);
		this.set("#axBrowserPos", newPos);
		
		if(newPos==0) 
			this.disableCmd("axPrevious", true);
		else
			if(newPos==1) {
				this.disableCmd("axPrevious", false);
		}
		if(this.isAdvanced() && btype==0) {
			getExt_advanced(btype);
		}
		else {
			getExt(btype);
		}
	},
	doBlur : function(el) {
		el.blur();
	},
	isAdvanced : function() {
		return (getCookieValue("searchpad")=="advanced" ? true : false);
	},
	disableCmd : function(cmdId, isDisabled) {
		if(isDisabled) {
			document.getElementById(cmdId).style.color="#b4aeaa";
		}
		else {
			document.getElementById(cmdId).style.color="";
		}
		document.getElementById(cmdId).disabled=isDisabled;
	},
	reset_BrowserPos : function() {
		$.cookie("#axBrowserPos", 0);
		this.set("#axBrowserPos", 0);
	},
	show_Progbar : function(disp) {
		$("#progbar").css("display",disp);
		setTimeout('document.images["progbar"].src = "gfx/eie_load2.gif"', 5);
	},
	search : function(btype) {
		setCookieValue("prisfra",getValueFromText("prisfra"));
		setCookieValue("pristil",getValueFromText("pristil"));
		setCookieValue("boafra",getValueFromText("boafra"));
		setCookieValue("boatil",getValueFromText("boatil"));
		setCookieValue("fritekst",getValueFromText("fritekst"));
		getExt_advanced(btype);
	},
	selectOmraade : function(obj,btype) {
		setCookieValue("omraade",getValueFromSelect(obj.id));
		this.reset_BrowserPos();
		getExt_advanced(btype);
	},
	init_DefaultSearchOptions : function() {
		this.ax("ajax/searchpad.asp", "stype=simple&btype=0", function() { }, function(msg) {
			eval(msg);
			Eie.load_DefaultSearchOptions();
			getExt(0);
		});
	},
	load_DefaultSearchOptions : function() {
		this.setCheckboxValue("cb1");
		this.setCheckboxValue("cb2");
		this.setCheckboxValue("cb3");
		this.setCheckboxValue("cb4");
		this.setCheckboxValue("cb5");
		this.setCheckboxValue("cb6");
	},
	init_AdvancedSearchOptions : function() {
		this.ax("ajax/searchpad.asp", "stype=advanced&btype=0", function() { }, function(msg) {
			eval(msg);
			Eie.load_AdvancedSearchOptions();
			getExt_advanced(0);
		});
	},
	ax : function(srcurl, dat, before, callback) {
		
		$.ajax({
			type: "POST",
		  url: srcurl,
		  data : dat,
		  cache : false,
		  beforeSend : function() {
		  	if(before) before();
		  },
		  success: function(msg){
		  	if(callback) callback(msg);
		  }
		});
	},
	load_AdvancedSearchOptions : function() {
		this.setCheckboxValue("cba1");
		this.setCheckboxValue("cba2");
		this.setCheckboxValue("cba3");
		this.setCheckboxValue("cba4");
		this.setCheckboxValue("cba5");
		this.setCheckboxValue("cba6");
		this.setTextValue("prisfra");
		this.setTextValue("pristil");
		this.setTextValue("boafra");
		this.setTextValue("boatil");
		this.setTextValue("fritekst");
		this.setSelectValue("omraade");
	},
	init_LeieOptions : function() {
		this.ax("ajax/searchpad.asp", "btype=1", function() { }, function(msg) {
			eval(msg);
			Eie.load_LeieOptions();
			getExt(1);
		});
	},
	load_LeieOptions : function() {
		this.setCheckboxValue("cbl1");
		this.setCheckboxValue("cbl2");
		this.setCheckboxValue("cbl3");
	},
	setCheckboxValue : function(key) {
		document.getElementById(key).checked=(getCookieValue(key)=="false" ? false : true);
	},
	setSelectValue : function(key) {
		var s=document.getElementById(key).options;
		var c=getCookieValue(key);
		for(var i=0;i<s.length;i++) {
			if(s[i].value==c) {
				document.getElementById(key).selectedIndex=i;
				break;
			}
		}
	},
	setTextValue : function(key) {
		this.set("#" + key, getCookieValue(key));
	},
	init_ImperialPropertyTurbine : function(btype) {
		this.loadSearchPad(btype);
	},
	loadSearchPad : function(btype) {
		if(btype==0) {
			if(getCookieValue("searchpad")=="simple") {
				this.init_DefaultSearchOptions();
			}
			else
				if(this.isAdvanced()) {
					this.init_AdvancedSearchOptions();
			}
			else {
				setCookieValue("searchpad","simple");
				this.init_DefaultSearchOptions();
			}
		}
		else
			if(btype==1) {
				this.init_LeieOptions();
			}
		else {
			this.init_DefaultSearchPad(btype);
		}
	},
	init_DefaultSearchPad : function(btype) {
		this.ax("ajax/searchpad.asp", "btype=" + btype, function() { }, function(msg) {
			eval(msg);
			getExt(btype);
		});
	},
	changeSearchPadMode : function(stype) {
		$.cookie("#axBrowserPos",0);
		setCookieValue("searchpad",stype);
		if(stype=="advanced") 
			this.init_AdvancedSearchOptions();
		else
			if(stype=="simple")
			 	this.init_DefaultSearchOptions();
	},
	hover : function(e,className) {
		var hover=document.getElementsByClassName(e.className);
		for(var i=0; i<hover.length; i++) {
			hover[i].className=className;
		}
	},
	check : function(cbox) {
		var box = document.getElementById(cbox);
		box.checked = (box.checked ? false : true);
	},
	checkfamily : function(cbox,hiddenvalue,isCheckbox,btype) {
		if(!isCheckbox)
			this.check(cbox);
		setCookieValue(cbox, document.getElementById(cbox).checked);
		this.reset_BrowserPos();
		getExt(btype);
	},
	checkfamilyAdvanced : function(cbox,isCheckbox,btype) {
		if(!isCheckbox)
			this.check(cbox);
		setCookieValue(cbox, document.getElementById(cbox).checked);
		this.reset_BrowserPos();
		getExt_advanced(btype);
	},
	checkradio : function(radio_element_id,btype,isRadio) {
		if(!isRadio) {
			document.getElementById(radio_element_id).checked=true;
		}
		setCookieValue("radio", radio_element_id);
		this.reset_BrowserPos();
		getExt(btype);
	},
	fritekst : function(fritekst) {
		if(fritekst.value.length==0) {
			setCookieValue("fritekst","");
			getExt_advanced(0);
		}
	},
	schema_onFocus : function(el,v) {
		el.value=(el.value==v ? "" : el.value);
	},
	schema_onBlur : function(el,v) {
		el.value=(el.value=="" ? v : el.value);
	},
	submitEmailForm : function(email,autofill_with_dummies_on_completion) {
		 var err=""
		 if($("#_fornavn").val()=="fornavn.." || $("#_fornavn").val()=="") {
		 	err="- Fornavn\n";
		 }
		 if($("#_etternavn").val()=="etternavn.." || $("#_etternavn").val()=="") {
		 	err+="- Etternavn\n";
		 }
		 if($("#_telefon").val()=="telefon.." || $("#_telefon").val()=="") {
		 	err+="- Telefon\n";
		 }
		 if(!this.check_Email($("#_email").val())) {
		 	err+="- E-post\n";
		 }
		 if($("#_beskjed").val()=="beskjed.." || $("#_beskjed").val()=="") {
		 	err+="- Beskjed\n";
		 }
		 if(err=="") {
		 	
			 if(confirm("Er du sikker på at all informasjon er korrekt?")) {
				 this.disable_Submit(true);
				 ImperialAjax_MailForm.sendMail(
				  autofill_with_dummies_on_completion,
				 	email,
				 	Eie.get("#_fornavn"), 
				 	Eie.get("#_etternavn"),
				 	Eie.get("#_telefon"),
				 	Eie.get("#_email"),
				 	Eie.get("#_beskjed"),
				 	"kontakt");
				 this.disable_Submit(false);
				}
		}
		else {
			err="Beskjeden kan ikke sendes. Følgende informasjon mangler:\n\n"+err;
			alert(err);
		}
		return false;
	},
	submitEmailFormCalc : function(email,autofill_with_dummies_on_completion) {
		 var err="";
		 if($("#_fornavn").val()=="fornavn.." || $("#_fornavn").val()=="") {
		 	err+="- Fornavn\n";
		 }
		 if($("#_etternavn").val()=="etternavn.." || $("#_etternavn").val()=="") {
		 	err+="- Etternavn\n";
		 }
		 if($("#_adresse").val()=="adresse.." || $("#_adresse").val()=="") {
		 	err+="- Adresse\n";
		 }
		 if($("#_postnr").val()=="postnummer.." || $("#_postnr").val()=="") {
		 	err+="- Postnummer\n";
		 }
		 if($("#_poststed").val()=="poststed.." || $("#_poststed").val()=="") {
		 	err+="- Poststed\n";
		 }
		 if($("#_telefon").val()=="telefon.." || $("#_telefon").val()=="") {
		 	err+="- Telefon\n";
		 }
		 if(!this.check_Email($("#_epost").val())) {
		 	err+="- E-post\n";
		 }
		 if(err=="") {      
			 if(confirm("Er du sikker på at all informasjon er korrekt?")) {
				 //this.disable_Submit(true);
				 /*ImperialAjax_MailForm.sendMail2(
				  autofill_with_dummies_on_completion,
				 	email,
				 	Eie.get("#_fornavn"), 
				 	Eie.get("#_etternavn"),
				 	Eie.get("#_telefon"),
				 	Eie.get("#_epost"),
				 	Eie.get("#_adresse"),
				 	Eie.get("#_postnrsted"),
				 	"kalkulator");
				 this.disable_Submit(false);
				}*/
				$("#_submitcmd").attr("disabled",true);
				
				$.post("ajax/postLaanetipsBankpartner.asp", {
					megler:$("#_megler").val(),
					fornavn:$("#_fornavn").val(),
					etternavn:$("#_etternavn").val(),
					adresse:$("#_adresse").val(),
					postnummer:$("#_postnr").val(),
					poststed:$("#_poststed").val(),
					telefon:$("#_telefon").val(),
					epost:$("#_epost").val()
				}, function(html) {
					$("#_submitcmd").attr("disabled",false);
					$("#tblform_bankpartner").find("input[type='text']").val("");
					$("#tblform_bankpartner").find("select option:first").attr("selected", true);
					$("#_retmsg").html("Takk for din henvendelse!").fadeIn("fast");
					setTimeout(function() {
						$("#_retmsg").fadeOut("fast");
					}, 4000);
				});
			}
		}
		else {
			err="Beskjeden kan ikke sendes. Følgende informasjon mangler:\n\n"+err;
			alert(err);
		}
		return false;
	},
	set : function(id, val) {
		$(id).val(val);
	},
	get : function(id) {
		return escape($(id).val());
	},
	slideDown : function(id) {
		$("#" + id).fadeIn("slow");
	},
	submitValuationForm : function(email,autofill_with_dummies_on_completion) {
		 var err=""
		 if($("#_fornavn").val()=="fornavn.." || $("#_fornavn").val()=="") {
		 	err="- Fornavn\n";
		 }
		 if($("#_etternavn").val()=="etternavn.." || $("#_etternavn").val()=="") {
		 	err+="- Etternavn\n";
		 }
		 if($("#_telefon").val()=="telefon.." || $("#_telefon").val()=="") {
		 	err+="- Telefon\n";
		 }
		 if(!this.check_Email($("#_email").val())) {
		 	err+="- E-post\n";
		 }
		 if($("#_beskjed").val()=="beskjed.." || $("#_beskjed").val()=="") {
		 	err+="- Beskjed\n";
		 }
		 if(err=="") {
		 	
			 if(confirm("Er du sikker på at all informasjon er korrekt?")) {
				 this.disable_Submit(true);
				 ImperialAjax_MailForm.sendMail(
				  autofill_with_dummies_on_completion,
				 	Eie.get("#_kontoremail"),
				 	Eie.get("#_fornavn"), 
				 	Eie.get("#_etternavn"),
				 	Eie.get("#_telefon"),
				 	Eie.get("#_email"),
				 	Eie.get("#_beskjed"),
				 	"verdivurderings");
				 this.disable_Submit(false);
				}
		}
		else {
			err="Beskjeden kan ikke sendes. Følgende informasjon mangler:\n\n"+err;
			alert(err);
		}
		return false;
	},
	check_Email : function(email) {
	   if(email) {
        return email.match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
		 }
		return false;
	},
	disable_Submit : function(bool) {
		document.getElementById("_submitcmd").disabled=bool;
	}
}

var ImperialAjax_MailForm = {
	sendMail : function(autofill_with_dummies_on_completion, to_email, fornavn, etternavn, telefon, email, beskjed, skjematype) {
		new ImperialAjax_MailForm_Send(autofill_with_dummies_on_completion, to_email, fornavn, etternavn, telefon, email, beskjed, '', '', skjematype);
	},
	sendMail2 : function(autofill_with_dummies_on_completion, to_email, fornavn, etternavn, telefon, email, adress, zipcode, skjematype) {
		new ImperialAjax_MailForm_Send(autofill_with_dummies_on_completion, to_email, fornavn, etternavn, telefon, email, '', adress, zipcode, skjematype);
	}
} 

 /** Using AJAX to send an e-mail. Implementing code from SACK v1.6.1 **/
function ImperialAjax_MailForm_Send(autofill_with_dummies_on_completion, to_email, fornavn, etternavn, telefon, email, beskjed, adress, zipcode, skjematype) {
	  
		try {
				var ajaxObj = new sack();
				ajaxObj.requestFile = 'ajax/sendmail.asp?autofill=' + autofill_with_dummies_on_completion + '&email=' + to_email + '&ffornavn=' + fornavn + '&fetternavn=' + etternavn+ '&ftelefon=' + telefon+ '&femail=' + email+ '&fbeskjed=' + beskjed + '&fadress=' + adress + '&fzipcode=' + zipcode +"&skjematype=" + skjematype;
				ajaxObj.onCompletion = function(){ 
					showClientData(ajaxObj); 
				};
				ajaxObj.runAJAX();	
		}
		catch(e) { alert(e.description); }
		
		function showClientData(ajaxObj) {
			try {
				var formObj = document.forms["_form"];	
				eval(ajaxObj.response);
			}
			catch(e) { }			
		}
}

document.getElementsByClassName = function(className){
	
	var outArray = new Array();    
	var item;     
	try {        
		var xpathResult = document.evaluate('//*[@class = "' + className + '"]', document, null, 0, null);             
		while (item = xpathResult.iterateNext())            
		outArray[outArray.length] = item;
	}    
	catch(err) {        
		// ie fix        
		var currentIndex = 0;        
		var allElements = document.getElementsByTagName('*');        
		for(var i=0; i < allElements.length; i++)        {   
			if(allElements[i].className.match(className))            {   
				outArray[currentIndex] = allElements[i];               
				currentIndex++;            
			}        
		}    
	}
	return outArray;
}

function rollbg(chosen, objectID) {
if(chosen == "roll") {
document.getElementById(objectID).className="roll";
}
else {
document.getElementById(objectID).className="over";
}
}



/* FRZ'S JAVASCRIPT FUNCTIONS BELOW - jqueryized by mr fuzz */

// the t variable is a timer which launches the progressbar after 2 seconds..
var t;

function setNewId(objname, nr) {
	 $("#" + objname).attr("id","dark" + nr);
}

function setOldId(objname, nr) {
 	$("#" + objname).attr("id","dim" + nr);
}

function getRadioIDByName(n) {
	var hz=document.getElementsByName(n);
	for(var i=0; i<hz.length; i++) 
		if(hz[i].checked) 
			return hz[i].id;
}

function getValueFromCheckbox(cbox) {
	try {
		return (document.getElementById(cbox).checked ? 1:0);
	}
	catch(ex) {
		alert("err checkbox: " + cbox);
	}
}

function getValueFromSelect(sbox) {
	return document.getElementById(sbox).options[document.getElementById(sbox).selectedIndex].value;
}

function getValueFromText(key) {
	return $("#" + key).val();
}

function getExt(btype)
{
	var theurl="";
//30=visninger
if(btype==30) {
	var stored_radio=getCookieValue("radio");
	if(stored_radio=="")
		stored_radio="dagens";
	document.getElementById(stored_radio).checked=true;
	theurl="b=" + btype + "&o=" + stored_radio;
}
//1=leie
else
	if(btype==1) {
	 theurl="pg1="+getValueFromCheckbox("cbl1") +
	 "&pg2="+getValueFromCheckbox("cbl2") +
	 "&pg3="+getValueFromCheckbox("cbl3") +
	 "&lei=1"+ 
	 "&ene=1"+
	 "&tom=1"+
	 "&b="+btype;
}
//0=selges
else
	if(btype==0) {
	 theurl="pg1="+getValueFromCheckbox("cb4") +
	 "&pg2="+getValueFromCheckbox("cb5") +
	 "&pg3="+getValueFromCheckbox("cb6") +
	 "&lei="+getValueFromCheckbox("cb1") +
	 "&ene="+getValueFromCheckbox("cb2") +
	 "&tom="+getValueFromCheckbox("cb3") +
	 "&b="+btype;
}
else {
	theurl="pg1=1" +
	 "&pg2=1" +
	 "&pg3=1" +
	 "&lei=1" +
	 "&ene=1" +
	 "&tom=1" +
	 "&b="+btype;
}

	Eie.ax("ajax/properties.asp", theurl + "&pos=" + $.cookie("#axBrowserPos"), function() {
		Eie.disableCmd("axPrevious",true);
		Eie.disableCmd("axNext",true);
		setTimeout("Eie.show_Progbar(\"block\")",10);
	}, function(msg) {
		eval(msg);
		Eie.objMoogOver();
		setTimeout("Eie.show_Progbar(\"none\")",10);
	});
}

// avansert søk
function getExt_advanced(btype) {
	Eie.ax("ajax/properties.asp", {
			 lei : getValueFromCheckbox("cba1"),
		 	 tom : getValueFromCheckbox("cba2"), 
		 	 ene : getValueFromCheckbox("cba3"),
			 toma : getValueFromCheckbox("cba4"),
			 rekk : getValueFromCheckbox("cba5"),
			 andre : getValueFromCheckbox("cba6"),
			 omraade : escape(getValueFromSelect("omraade")),
			 prisfra : getValueFromText("prisfra"),
			 pristil : getValueFromText("pristil"),
			 boafra : getValueFromText("boafra"),
			 boatil : getValueFromText("boatil"),
			 fritekst : escape(getValueFromText("fritekst")),
			 b : btype,
			 stype : "advanced", 
			 pos : $.cookie("#axBrowserPos") }, function() {
		 Eie.disableCmd("axPrevious",true);
		 Eie.disableCmd("axNext",true);
		setTimeout("Eie.show_Progbar(\"block\")",10);
	}, function(msg) {
		eval(msg);
		Eie.objMoogOver();
		setTimeout("Eie.show_Progbar(\"none\")",10);
	});
}

function setHiddenValue(objname) {
 //timedMsg();
 
 if(Eie.get("#"+objname) == "1")
  Eie.set("#"+objname,"0");
 else
  Eie.set("#"+objname,"1");
}
function getHiddenValue(objname) {
 return Eie.get("#" + objname);
}


function setNewffId(objname, nr) {
 $("#" + objname).attr("id", "dark" + nr);
 $("#osk" + nr).css("color", "white");
 $("#dimtt" + nr).css("color", "white");
 $("#dimbt" + nr).css("color", "white");
}

function restoreColors(nr) {
 	 $("#osk" + nr).css("color", "#B4B2B1");
 	 $("#dimtt" + nr).css("color", "#B4B2B1");
 	 $("#dimbt" + nr).css("color", "#B4B2B1");
}

function setOldffId(objname, nr) {
 $("#" + objname).attr("id", "dim" + nr);
}

function getFirstPlantegning() {
	pic_types=getPicTypes();
	
	for(var i=0;i<pic_types.length;i++) {
		if(pic_types[i]==1) {
			return i;
			break;
		}
	}
	return -1;
}

function init_plantegning(theurl) {
	var first=getFirstPlantegning();
	changeimg(theurl, first);
	this.set("#tmpstr",first);
}

function auto_pos(picid) {
	pic_types=getPicTypes();
	var h=document.getElementById("majorPic").height;
	
	/* Plantegninger får fri høyde */
 if(pic_types[picid]==1) { //0=bilde, 1=plantegning
 	 document.getElementById("majorPic").style.top="0px";
 	 document.getElementById("majorpic_container").style.height="";
 }

 /* Vanlige bilder får en fast høyde på 383px */ 
 else {
  document.getElementById("majorpic_container").style.height="383px";
 	
 	/* Midtstiller bildet dersom det er høyere enn 383px */
 	if(h>=383) {
 		document.getElementById("majorPic").style.top="-"+((h-383) / 2)+"px";
 		//document.getElementById("majorPic").style.top="-50px";
 	}
 	else 
 		if(h<383) {
 			document.getElementById("majorPic").style.top=((383-h) / 2)+"px";	
 		}
 	else {
 		
 		document.getElementById("majorPic").style.top="0px";
 	}
 }
}

function changeimg(url,picid) {
 /* Setter bilde */
 if(url!="") {
 	document.getElementById("majorPic").src=url;
 	setTimeout("auto_pos("+picid+");",25);
 }
 
}

function changeimg_reeltime(url) {
 document.getElementById("reeltime").style.backgroundImage = "url(" + url + ")";
}

function init_major() {
	pics=getPics();
	pic_types=getPicTypes();
	
	for(var i=0;i<pic_types.length;i++) {
		if(pic_types[i]=="0") {
			changeimg(pics[i],i);
			break;
		}
	}
} 

function sethidden(nr) {
 Eie.set("#tmpstr", nr);
}

function rollnext() {
 pics = getPics();
 var picid = parseInt(Eie.get("#tmpstr"));
 
 if(picid >= pics.length-1) {
  Eie.set("#tmpstr", 0);
  picid = 0;
 }
 else
  document.getElementById('tmpstr').value = ++picid;
 changeimg(pics[picid], picid);
}

function close_plantegning() {
	try {
	//	dd.elements.te.hide();
	}	
	catch(e) {
		
	}
}

function rollprev() {
 pics = getPics();
 var picid = parseInt(document.getElementById('tmpstr').value);
 
 if(picid <= 1) {
  document.getElementById('tmpstr').value = pics.length;
  picid = 0;
 }
 else
  document.getElementById('tmpstr').value = --picid;

 changeimg(pics[picid],picid);
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'resizeable=1,height=200,width=200,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1');");
}

