Advertisement

10.11.2008 at 09:04PM PDT, ID: 23807322
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.7

javascript safari problem(printing js code on page)

Asked by Stian_B in Safari Web Browser, JavaScript

Tags: ,

Hi,

i have currently made a webpage to organize shifts for workers at a store. i thought everything worked fine, until i discovered that sometimes when the page reload(only in safari), safari starts printing out the javascript code at random position in the code, and then shows the intended result below the code. I've also been notified that this is a problem on another website i've made as well, which has a totally different code. I'm out of ideas on this one, since i cant find any errors in my code, and the place where the printing of code changes every time, also the print starts in very odd places, like in this example in the middle of an array variable.

Here is an example of when safari prints code on the page:

tions[i] = new Option("20:30", "20:30"); i++; } if("21:00" == "12:00"){ sel4.options[i] = new Option("21:00", "21:00", true, true); i++; }else{ sel4.options[i] = new Option("21:00", "21:00"); i++; } if("21:30" == "12:00"){ sel4.options[i] = new Option("21:30", "21:30", true, true); i++; }else{ sel4.options[i] = new Option("21:30", "21:30"); i++; } if("22:00" == "12:00"){ sel4.options[i] = new Option("22:00", "22:00", true, true); i++; }else{ sel4.options[i] = new Option("22:00", "22:00"); i++; } if("22:30" == "12:00"){ sel4.options[i] = new Option("22:30", "22:30", true, true); i++; }else{ sel4.options[i] = new Option("22:30", "22:30"); i++; } if("23:00" == "12:00"){ sel4.options[i] = new Option("23:00", "23:00", true, true); i++; }else{ sel4.options[i] = new Option("23:00", "23:00"); i++; } if("23:30" == "12:00"){ sel4.options[i] = new Option("23:30", "23:30", true, true); i++; }else{ sel4.options[i] = new Option("23:30", "23:30"); i++; } sel4.onchange=function(){ var id = this.id; var lengde = id.length; if(lengde == 5) id = id.substr(2,3); if(lengde == 4) id = id.substr(2,2); if(lengde == 3) id = id.substr(2,1); lagDiv(id); } ut.appendChild(sel4); var tidslinje = rad.insertCell(4); var div = document.createElement("div"); div.style.height = "20px"; div.style.width = "auto"; div.style.position = "relative"; div.id = "rad" + html("raderLaget") if(fargetRad == 0){ div.style.backgroundColor = "#F5FAFA"; //sel2.style.color = "#B4AA9D"; } tidslinje.appendChild(div); var lunch = rad.insertCell(5); var divLunch = document.createElement("div"); divLunch.style.height = "20px"; divLunch.style.width = "62px"; divLunch.id = "lunchDiv" + html("raderLaget"); if(fargetRad == 0){ divLunch.style.backgroundColor = "#F5FAFA"; //sel2.style.color = "#B4AA9D"; } divLunch.onmouseover = function(){ var id = this.id; musOverBakgrunn(id) } divLunch.onmouseout = function(){ var id = this.id; musUt(id) } divLunch.onclick = function(){ var id = this.id; id = id.split("lunchDiv"); toggleCheckbox("lunchbox"+id[1]); } lunch.style.textAlign = "right"; var sel5 = document.createElement('input'); sel5.type = "checkbox"; sel5.id = "lunchbox" + html("raderLaget"); sel5.name = "lunchbox" + html("raderLaget"); sel5.onclick = function(){ var id = this.id; id = id.split("lunchbox"); toggleCheckbox("lunchbox"+id[1]); } divLunch.appendChild(sel5); lunch.appendChild(divLunch); var syk = rad.insertCell(6); var divSyk = document.createElement("div"); divSyk.style.height = "20px"; divSyk.style.width = "90px"; divSyk.id = "sykDiv" + html("raderLaget"); if(fargetRad == 0){ divSyk.style.backgroundColor = "#F5FAFA"; //sel2.style.color = "#B4AA9D"; } divSyk.onmouseover = function(){ var id = this.id; musOverBakgrunn(id) } divSyk.onmouseout = function(){ var id = this.id; musUt(id) } divSyk.onclick = function(){ var id = this.id; id = id.split("sykDiv"); toggleCheckbox("sykbox"+id[1]); } syk.style.textAlign = "right"; var sel6 = document.createElement('input'); sel6.type = "checkbox"; sel6.id = "sykbox" + html("raderLaget"); sel6.name = "sykbox" + html("raderLaget"); sel6.onclick = function(){ var id = this.id; id = id.split("sykbox"); toggleCheckbox("sykbox"+id[1]); } divSyk.appendChild(sel6); syk.appendChild(divSyk); var celle = rad.insertCell(7); celle.style.background = "#FFFFFF"; celle.style.border = "none"; var slett = document.createElement("img"); slett.src = "gfx/slett.png"; slett.style.background = "#FFFFFF"; slett.style.width = "11px"; slett.style.height = "11px"; slett.style.border = "none"; slett.style.padding = "5px"; slett.id = "slett" + html("antRader"); slett.onclick = function(){ var id = this.id; id = id.split("slett"); slettRad(id[1]); } celle.appendChild(slett); } function slettRad(i){ document.getElementById('vaktlistetabell').deleteRow(i); var antall = html("antRader"); antall++; for(j=i;j<=antall;j++){ if(document.getElementById("slett"+j) != null){ var div = document.getElementById("slett"+j); id = "slett"+(j-1); div.id = id; } } minusId(); } function lastSide(){ var dato = document.getElementById("aktuellDato").value; var url = location.href; url = url.split("?"); location.href= url[0]+"?dato="+dato; } function forrigeDag(){ var dag = "04-09-2008" var url = location.href; url = url.split("?"); location.href= url[0]+"?dato="+dag; } function nesteDag(){ var dag = "06-09-2008" var url = location.href; url = url.split("?"); location.href= url[0]+"?dato="+dag; } function oppdaterId(){ oppdaterHiddenfelt(); var antall = html("antRader"); if(antall == "0"){ antall = 1; }else antall++; settHTML("antRader", antall); } function oppdaterTotalId(){ var totaltAnt = html("raderLaget"); if(totaltAnt == "0"){ totaltAnt = 1; }else totaltAnt++; settHTML("raderLaget", totaltAnt); } function minusId(){ var antall = html("antRader"); antall--; settHTML("antRader", antall); return antall; } function value(id){ return document.getElementById(id).value; } function html(id){ return document.getElementById(id).innerHTML; } function settVerdi(id, verdi){ document.getElementById(id).value = verdi; } function settHTML(id, verdi){ document.getElementById(id).innerHTML = verdi; } function oppdaterHiddenfelt(){ var antall = value("hiddenAntRader"); if(antall == "0" || antall == ""){ antall = 1; } else antall++; settVerdi("hiddenAntRader", antall); return antall; } function sok(){ var sokeord = value("sokefelt"); var currentTime = new Date(); getFromServer("sokVaktliste.php?ord="+sokeord+"&time="+currentTime.getTime(), visResultat); } function visResultat(XHR){ document.getElementById('light').style.display='block'; document.getElementById('fade').style.display='block'; var url = location.href; url = url.split("?"); var div = document.getElementById('light'); var html = ""; if(XHR.responseText != "-1"){ //location.href= url[0]+"?dato="+dag; var datoArray = XHR.responseText.split(":"); if(datoArray.length >1){ for(i = 0;i


 I don't know if it's the code that is the problem or the browser, but here is the entire code (i know it's a little long..):

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578:
579:
580:
581:
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627:
628:
629:
630:
631:
632:
633:
634:
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645:
646:
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689:
690:
691:
692:
693:
694:
695:
696:
697:
698:
699:
700:
701:
702:
703:
704:
705:
706:
707:
708:
709:
710:
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746:
747:
748:
749:
750:
751:
752:
753:
754:
755:
756:
757:
758:
759:
760:
761:
762:
763:
764:
765:
766:
767:
768:
769:
770:
771:
772:
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798:
799:
800:
801:
802:
803:
804:
805:
806:
807:
808:
809:
810:
811:
812:
813:
814:
815:
816:
817:
818:
819:
820:
821:
822:
823:
824:
825:
826:
827:
828:
829:
830:
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848:
849:
850:
851:
852:
853:
854:
855:
856:
857:
858:
859:
860:
861:
862:
863:
864:
865:
866:
867:
868:
869:
870:
871:
872:
873:
874:
875:
876:
877:
878:
879:
880:
881:
882:
883:
884:
885:
886:
887:
888:
889:
890:
891:
892:
893:
894:
895:
896:
897:
898:
899:
900:
901:
902:
903:
904:
905:
906:
907:
908:
909:
910:
911:
912:
913:
914:
915:
916:
917:
918:
919:
920:
921:
922:
923:
924:
925:
926:
927:
928:
929:
930:
931:
932:
933:
934:
935:
936:
937:
938:
939:
940:
941:
942:
943:
944:
945:
946:
947:
948:
949:
950:
951:
952:
953:
954:
955:
956:
957:
958:
959:
960:
961:
962:
963:
964:
965:
966:
967:
968:
969:
970:
971:
972:
973:
974:
975:
976:
977:
978:
979:
980:
981:
982:
983:
984:
985:
986:
987:
988:
989:
990:
991:
992:
993:
994:
995:
996:
997:
998:
999:
1000:
1001:
1002:
1003:
1004:
1005:
<?php
require_once ("tidTabell.php");
require_once ("classes/db.php");
require_once ("classes/bruker_php.php");
require_once ("classes/bruker.php");
require_once ("classes/vaktliste_bud_oms.php");
require_once("classes/vaktliste.php");
require_once("inc/browserdetection.php");
 
$_SESSION['community_statusVaktliste'] = 'vaktliste';
$_SESSION['lagret'] = "nei";
$fraUrl = "http://www.trmed.no/kunder/burgerking2/vaktliste.php";
$fortid;
if(isset($_GET['lagreVakt'])){
	$nyRad = true;
	$index = 0;
	$dato = $_POST['aktuellDato'];
	$vakt = new Vaktliste();
	$vakt->slettVakterForDag($dato);
	$_SESSION['id'] = 0;
	while($index < $_POST['hiddenAntRader']){
		if(isset($_POST['navn'.$index])){
			$ansattnr = $_POST['ansattnr'.$index];
			$navnet = $_POST['navn'.$index];
			$inn = $_POST['inn'.$index];
			$ut = $_POST['ut'.$index];
			if(isset($_POST['lunchbox'.$index]))$lunch = "ja";
			if(isset($_POST['sykbox'.$index]))$sykefravaer = "ja";
			if(!(isset($_POST['lunchbox'.$index])))$lunch = "";
			if(!(isset($_POST['sykbox'.$index])))$sykefravaer = "";
			$allowedTags='<a><p><strong><em><u><h1><h2><h3><h4><h5><h6><img>';
 			$allowedTags.='<li><ol><ul><span><div><br><ins><del><object><embed><param>';
			$spesielt = htmlspecialchars(strip_tags(stripslashes($_POST['spesielt']),$allowedTags), ENT_QUOTES);
			$notater = htmlspecialchars(strip_tags(stripslashes($_POST['notater']),$allowedTags), ENT_QUOTES);
			if($_SESSION['id'] == 0){
				$budOms = new VaktlisteBudOms($_POST['budsjett'], $_POST['omsetning']);
				$_SESSION['id'] = $budOms->leggTilBudOms();
			} 
			$vakt = new Vaktliste($dato, $ansattnr, $navnet, $inn, $ut, $lunch, $sykefravaer, $spesielt, $notater, $_SESSION['id']);
			$vakt->leggTilVakt();
		}else $nyRad = false;
		$index++;
	}
	$url = explode("?",$HTTP_REFERER); 
	$url = explode("http//", $url[0]);
	if($SF){
		 $url = $fraUrl;
		 header( 'location:'.$url.'?dato='.$_POST['aktuellDato']);
	}else{
		header( 'location:'.$url[0].'?dato='.$_POST['aktuellDato']);
	}
 
 
}
 
$navn = array();
$navn = finnAlleNavnMedIdKey();
$nummer = finnAnsattnr($navn);
$fraBase = true;
 
function finnAlleNavnMedIdKey(){
	$bruker = new Bruker_php();
	return $bruker->finnAlleNavnMedIdKey();
}
 
function finnAnsattnr($navn){
	$bruker = new BrukerClass();
	return $bruker->finnAnsattnr($navn);
}
 
$navnVakt = array();
$nummerVakt = array();
$innVakt = array();
$utVakt = array();
$lunchVakt = array();
$sykVakt = array();
$spesielt = "";
$notater= "";
$Budsjett= "";
$Omsetning= "";
$budOmsId = -1;
 
 
 
if(isset($_GET['dato'])){
	$datoArray = explode("-", $_GET['dato']);
	if(mktime(23,59,59,$datoArray[1],$datoArray[0],$datoArray[2])<time()) $fortid = true;
	require_once("classes/vaktliste.php");
	$vakt = new Vaktliste();
	$vaktArray = $vakt->hentVakterForDag($_GET['dato']);
	if(sizeof($vaktArray)==0){
		$_SESSION['rader'] = 0;
		$fraBase = false;
	}else{
		$_SESSION['rader'] = sizeof($vaktArray)-1;
		$fraBase = true;
	}
	for($i=0;$i<sizeof($vaktArray);$i++){
		foreach($vaktArray[$i] as $key => $value){
			if($key == "navn") $navnVakt[] = $value;
			if($key == "ansattnr") $nummerVakt[] = $value;
			if($key == "inn") $innVakt[] = $value;
			if($key == "ut") $utVakt[] = $value;
			if($key == "lunsj") $lunchVakt[] = $value;
			if($key == "sykefravaer") $sykVakt[] = $value;
			if($key == "vaktliste_bud_oms_id") $budOmsId = $value;
			if($key == "spesielt") $spesielt = $value;
			if($key == "notater") $notater = $value;
			if($budOmsId>=0){
				$budOms = new VaktlisteBudOms();
				$arr = $budOms->hentVakterForId($budOmsId);
				$budsjett = $arr['budsjett'];
				$omsetning = $arr['omsetning'];
			}
		}
		if(sizeof($vaktArray) == 1 && $innVakt[0] == "00:00" && $utVakt[0] == "00:00") $fraBase = false;
		
	}
}
 
if(!(isset($_GET['dato'])) && !(isset($_GET['lagreVakt']))){
	require_once("classes/vaktliste.php");
	$vakt = new Vaktliste();
	$vaktArray = $vakt->hentVakterForDag(date("d-m-Y"));
	(sizeof($vaktArray)==0)?$_SESSION['rader'] = 0:$_SESSION['rader'] = sizeof($vaktArray)-1;
	for($i=0;$i<sizeof($vaktArray);$i++){
		foreach($vaktArray[$i] as $key => $value){
			if($key == "navn") $navnVakt[] = $value;
			if($key == "ansattnr") $nummerVakt[] = $value;
			if($key == "inn") $innVakt[] = $value;
			if($key == "ut") $utVakt[] = $value;
			if($key == "lunsj") $lunchVakt[] = $value;
			if($key == "sykefravaer") $sykVakt[] = $value;
			if($key == "vaktliste_bud_oms_id") $budOmsId = $value;
			if($key == "spesielt") $spesielt = $value;
			if($key == "notater") $notater = $value;
			if($budOmsId>=0){
				$budOms = new VaktlisteBudOms();
				$arr = $budOms->hentVakterForId($budOmsId);
				$budsjett = $arr['budsjett'];
				$omsetning = $arr['omsetning'];
			}
		}
	}
}
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="js/prototype_ny.js"></script>
<script type="text/javascript" src="js/scriptaculous.js"></script>
<script type="text/javascript" src="js/datepicker.js"></script>
<script type="text/javascript" src="js/date_functions.js"></script>
<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="js/asynkron.js"></script>
<script type="text/javascript" src="js/nyttig.js"></script>
<link href="css/linkboks.css" type="text/css" rel="stylesheet" />
<script language="javascript" type="text/javascript">
  tinyMCE.init({
    theme : "advanced",
    mode: "exact",
    elements : "spesielt, notater",
    theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
    theme_advanced_buttons1 : "bold,italic,underline,separator,"
    + "justifyleft,justifycenter,justifyright,|,fontsizeselect,"
    + "bullist,numlist,separator,link,unlink,image,media,separator,preview",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resize_horizontal : false,
	theme_advanced_resizing : true,
    height:"250px",
    width:"510px",
	force_br_newlines : true,
    forced_root_block : '',
	plugins : "preview,advimage,advlink,media",
	plugin_preview_width : "500",
	plugin_preview_height : "600",
	file_browser_callback : "fileBrowserCallBack"
  });
 
  function fileBrowserCallBack(field_name, url, type, win) {
			var connector = "../../../../js/tiny_mce/plugins/filemanager/file_manager.php";
 
			my_field = field_name;
			my_win = win;
 
			switch (type) {
				case "image":
					connector += "?type=img";
					break;
				case "media":
					connector += "?type=media";
					break;
				case "flash": //for older versions of tinymce
					connector += "?type=media";
					break;
				case "file":
					connector += "?type=files";
					break;
			}
 
			window.open(connector, "file_manager", "modal,width=450,height=600,scrollbars=1");
		}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/vaktliste.css" type="text/css" rel="stylesheet" />
 
<style>
	@import url("css/datepicker.css");
</style>
 
<script>
var bakgrunnsfarge ="#FAF8CC";
var gammelFarge;
function lagDiv(radId){
	var cell = document.getElementById("rad"+radId);
 
	if ( cell.hasChildNodes() )
	{
		while ( cell.childNodes.length >= 1 )
		{
			cell.removeChild( cell.firstChild );       
		} 
	}
	
	//lager tidtabell, slik at 05:00, som kommer først har verdien "0"
	var tid = new Array();
	for(var i = 0; i<24;i++){
		if(i<5) tid[i] = i+19;
		else tid[i] = i-5;
	}//for
 
	
	var timeavstand = 13; //px
	var halvtime = timeavstand/2; //px
	var farge = "#14dc14";
	var fraHalv = 0
	var tilHalv = 0; //true hvis det ikke er en hel timen, men XX:30
	
	var inn = document.getElementById("inn"+radId).value;
	var ut = document.getElementById("ut"+radId).value;
	
	var fra = inn.split(":",2);
	if(fra[0].substr(0,1) == "0") fra[0] = fra[0].substr(1,1);
	if(fra[1] == "30") fraHalv = halvtime;
	fra = fra[0];
	
	var til = ut.split(":",2);
	if(til[0].substr(0,1) == "0") til[0] = til[0].substr(1,1);
	if(til[1] == "30") tilHalv = halvtime;
	til = til[0];
	
	var toBarer = sjekkOmMaaLageToBarer(tid[fra], tid[til]);
	if(toBarer){
		var start = 8+(timeavstand*tid[fra])+fraHalv;
		var start2 = 0;
		var celle = document.getElementById("rad"+radId);
		/*var div = document.createElement("div");
		var div2 = document.createElement("div");
		div.style.position = "absolute";
		div2.style.position = "absolute";
		div.style.left =start+"px";
		div2.style.left="0px";
		div.style.margin = "0px";
		div.style.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv+"px";
		div.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv;
		div2.style.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv)+"px";
		div2.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv);
		div.style.height = "20px";
		div2.style.height = "20px";
		div.style.background = "#666666";
		div2.style.background = "#666666";
		celle.appendChild(div);
		celle.appendChild(div2);	*/
		var div = document.createElement("img");
		var div2 = document.createElement("img");
		div.style.position = "absolute";
		div2.style.position = "absolute";
		div.style.left =start+"px";
		div2.style.left="0px";
		div.style.margin = "0px";
		div.style.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv+"px";
		div.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv;
		div2.style.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv)+"px";
		div2.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv);
		div.style.height = "20px";
		div2.style.height = "20px";
		div.src = 'gfx/timediv.png';
		div2.src = 'gfx/timediv.png';
		celle.appendChild(div);
		celle.appendChild(div2);	
	}else{
		var start = 8+(timeavstand*tid[fra])+fraHalv;
		var celle = document.getElementById("rad"+radId);
		/*var div = document.createElement("div");
		div.style.position = "absolute";
		//div.style.marginLeft=start+"px";
		div.style.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv+"px";
		div.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv;
		div.style.height = "20px";
		div.style.marginLeft = start +"px";
		div.style.background = "#666666";
		celle.appendChild(div);*/
		var celle = document.getElementById("rad"+radId);
		var div = document.createElement("img");
		div.style.position = "absolute";
		div.style.border = "0px";
		div.style.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv+"px";
		div.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv;
		div.style.height = "20px";
		div.style.marginLeft = start +"px";
		div.src = 'gfx/timediv.png';
		celle.appendChild(div);
	}
		var id = "navn"+radId;
		sjekkDobbelVakt(document.getElementById("navn"+radId).value, id);
	
}//function
 
function sjekkOmMaaLageToBarer(fra, til){
	if(fra > til) return true;
	else return false;
}//function
 
function toggleCheckbox(id){
	var box = document.getElementById(id);
	if(box.checked == true) box.checked = false;
	else box.checked = true;
}
 
function musOverBakgrunn(id){
	var div = document.getElementById(id);
	gammelFarge = div.style.backgroundColor;
	div.style.backgroundColor = "#666666";
}
 
function musUt(id){
	var div = document.getElementById(id);
	div.style.backgroundColor = gammelFarge;
}
 
function visDiv(hvilkenDiv){
	var id = hvilkenDiv+"Div";
	toggleLayer(id);
}
 
function toggleLayer(whichLayer){
	var thisLayer = document.getElementById(whichLayer).style;
	if(thisLayer.display == "none" || thisLayer.display == ""){
		thisLayer.display = "block";
	}else{
		thisLayer.display = "none";
	}
}
 
 
function finnDagForDato(datoen){
	if(datoen != "nei"){
		show_clock();
		var dager = new Array()
		dager["Mon"] = "Mandag";
		dager["Tue"] = "Tirsdag";
		dager["Wed"] = "Onsdag";
		dager["Thu"] = "Torsdag";
		dager["Fri"] = "Fredag";
		dager["Sat"] = "Lørdag";
		dager["Sun"] = "Søndag";
		
		var dato = datoen;
		var datofelt = document.getElementById("aktuellDato");
		datofelt.value = datoen;
		if(dato != ""){
			var datoArr = dato.split("-", 3);
			var string = datoArr[2]+"-"+datoArr[1]+"-"+datoArr[0];
			var d = Date.parseDate(string, "Y-m-d");
			var dag = d + " ";
			var dag = dag.split(" ", 1);
			
			var ukedag = document.getElementById("ukedag");
			ukedag.innerHTML = dager[dag];
		}
	}else show_clock();
	//settHTML("antRader", "<?php if($_SESSION['rader'] != 0) echo $_SESSION['rader']; else echo "1";?>");
	if("<?php echo $_SESSION['lagret']; ?>"=="ja"){
		toggleLayer("lagreBeskjed");
	}
}
 
function leggTilRad(){
	  oppdaterId();
	  oppdaterTotalId();
	  var tabell = document.getElementById('vaktlistetabell');
	  var antRader = tabell.rows.length;
	  // if there's no header rad in the table, then iteration = lastrad + 1
	  var i = antRader;
	  var rad = tabell.insertRow(antRader);
	  // left cell
	  var fargetRad = html("antRader") % 2;
 
 
	  var navn = rad.insertCell(0);
	  navn.style.textAlign = "right";
	  var sel = document.createElement('select');
	  sel.name = 'navn' + html("raderLaget");
	  sel.id = 'navn' + html("raderLaget");
	  sel.style.width = "118px";
	  sel.style.textAlign = "left";
	  sel.onchange = function(){
	  	sjekkDobbelVakt(this.value, this.id);
		finnAnsattNrForNavn(this.id);
	  }
	  if(fargetRad == 0){
	  	 sel.style.backgroundColor = "#F5FAFA";
		 //sel2.style.color = "#B4AA9D";
	  }
	  i=0;
	  <?php foreach($navn as $key => $value){ ?>
	  	if(i == html("raderLaget")){
	  		sel.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
			i++;
		}else{
	  		sel.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
			i++;
		}
	  <?php } ?>
	  navn.appendChild(sel);
	  
	  var ansattNr = rad.insertCell(1);
	  ansattNr.style.textAlign = "right";
	  ansattNr.style.width = "80px";
	  var sel2 = document.createElement('select');
	  sel2.name = 'ansattnr' + html("raderLaget");
	  sel2.id = 'ansattnr' + html("raderLaget");
	  sel2.style.width = "80px";
	  sel2.style.textAlign = "center";
	  sel2.onchange = function(){
		finnNavnForAnsattnr(this.id);
	  }
	  if(fargetRad == 0){
	  	 sel2.style.backgroundColor = "#F5FAFA";
		 //sel2.style.color = "#B4AA9D";
	  }
	  i=0;
	  <?php foreach($nummer as $key => $value){ ?>
	  	if(i == html("raderLaget")){
	  		sel2.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
			i++;
		}else{
	  		sel2.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
			i++;
		}
	  <?php } ?>
	  ansattNr.appendChild(sel2);
	  
	  
	  var inn = rad.insertCell(2);
	  inn.style.textAlign = "right";
	  var sel3 = document.createElement('select');
	  sel3.name = 'inn' + html("raderLaget");
	  sel3.id = "inn" + html("raderLaget");
	  sel3.style.width = "60px";
	  if(fargetRad == 0){
	  	 sel3.style.backgroundColor = "#F5FAFA";
		 //sel3.style.color = "#B4AA9D";
	  }
	  i=0;
	  <?php foreach($tider as $key => $value){ ?>
	  			if("<?=$value?>" == "12:00"){
					sel3.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
					i++;
				}else{
					sel3.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
					i++;
				}
	  <?php } ?>
	  sel3.onchange=function(){
	  	var id = this.id;
		var lengde = id.length;
		if(lengde == 6) id = id.substr(3,3);
		if(lengde == 5) id = id.substr(3,2);
		if(lengde == 4) id = id.substr(3,1);
	  	lagDiv(id);
	  }
	  inn.appendChild(sel3);
	  
	  var ut = rad.insertCell(3);
	  ut.style.textAlign = "right";
	  var sel4 = document.createElement('select');
	  sel4.style.textAlign = "center";
	  sel4.name = 'ut' + html("raderLaget");
	  sel4.id = 'ut' + html("raderLaget");
	  sel4.style.width = "60px";
	  if(fargetRad == 0){
	  	 sel4.style.backgroundColor = "#F5FAFA";
		 //sel4.style.color = "#B4AA9D";
	  }
	  i=0;
	  <?php foreach($tider as $key => $value){ ?>
	  			if("<?=$value?>" == "12:00"){
					sel4.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
					i++;
				}else{
					sel4.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
					i++;
				}
	  <?php } ?>
	  sel4.onchange=function(){
	  	var id = this.id;
		var lengde = id.length;
		if(lengde == 5) id = id.substr(2,3);
		if(lengde == 4) id = id.substr(2,2);
		if(lengde == 3) id = id.substr(2,1);
	  	lagDiv(id);
	  }
	  ut.appendChild(sel4);
	  
	  var tidslinje = rad.insertCell(4);
	  var div = document.createElement("div");
	  div.style.height = "20px";
	  div.style.width = "auto";
	  div.style.position = "relative";
	  div.id = "rad" + html("raderLaget")
	  if(fargetRad == 0){
	  	 div.style.backgroundColor = "#F5FAFA";
		 //sel2.style.color = "#B4AA9D";
	  }
	  tidslinje.appendChild(div);
	  
	  var lunch = rad.insertCell(5);
	  var divLunch = document.createElement("div");
	  divLunch.style.height = "20px";
	  divLunch.style.width = "62px";
	  divLunch.id = "lunchDiv" + html("raderLaget");
	  if(fargetRad == 0){
	  	 divLunch.style.backgroundColor = "#F5FAFA";
		 //sel2.style.color = "#B4AA9D";
	  }
	  divLunch.onmouseover = function(){
	  	var id = this.id;
	  	musOverBakgrunn(id)
	  }
	  divLunch.onmouseout = function(){
	  	var id = this.id;
		musUt(id)
	  }
	  divLunch.onclick = function(){
	  	var id = this.id;
		id = id.split("lunchDiv");
		toggleCheckbox("lunchbox"+id[1]);
	  }
	  lunch.style.textAlign = "right";
	  var sel5 = document.createElement('input');
	  sel5.type = "checkbox";
	  sel5.id = "lunchbox" + html("raderLaget");
	  sel5.name = "lunchbox" + html("raderLaget");
	  sel5.onclick = function(){
	  	var id = this.id;
		id = id.split("lunchbox");
		toggleCheckbox("lunchbox"+id[1]);
	  }
	  divLunch.appendChild(sel5);
	  lunch.appendChild(divLunch);
	  
	  var syk = rad.insertCell(6);
	  var divSyk = document.createElement("div");
	  divSyk.style.height = "20px";
	  divSyk.style.width = "90px";
	  divSyk.id = "sykDiv" + html("raderLaget");
	  if(fargetRad == 0){
	  	 divSyk.style.backgroundColor = "#F5FAFA";
		 //sel2.style.color = "#B4AA9D";
	  }
	  divSyk.onmouseover = function(){
	  	var id = this.id;
		musOverBakgrunn(id)
	  }
	  divSyk.onmouseout = function(){
	  	var id = this.id;
		musUt(id)
	  }
	  divSyk.onclick = function(){
	  	var id = this.id;
		id = id.split("sykDiv");
		toggleCheckbox("sykbox"+id[1]);
	  }
	  syk.style.textAlign = "right";
	  var sel6 = document.createElement('input');
	  sel6.type = "checkbox";
	  sel6.id = "sykbox" + html("raderLaget");
	  sel6.name = "sykbox" + html("raderLaget");
	  sel6.onclick = function(){
	  	var id = this.id;
		id = id.split("sykbox");
		toggleCheckbox("sykbox"+id[1]);
	  }
	  divSyk.appendChild(sel6);
	  syk.appendChild(divSyk);
	  
	  var celle = rad.insertCell(7);
	  celle.style.background = "#FFFFFF";
	  celle.style.border = "none";
	  var slett = document.createElement("img");
	  slett.src = "gfx/slett.png";
	  slett.style.background = "#FFFFFF";
	  slett.style.width = "11px";
	  slett.style.height = "11px";
	  slett.style.border = "none";
	  slett.style.padding = "5px";
	  slett.id = "slett" + html("antRader");
	  slett.onclick = function(){
	  	var id = this.id;
		id = id.split("slett");
		slettRad(id[1]);
	  } 
	  celle.appendChild(slett);
}
 
function slettRad(i){
	document.getElementById('vaktlistetabell').deleteRow(i);
	var antall = html("antRader");
	antall++;
	for(j=i;j<=antall;j++){
		if(document.getElementById("slett"+j) != null){
			var div = document.getElementById("slett"+j);
			id = "slett"+(j-1);
			div.id = id;
		}
	}
	minusId();
}
 
function lastSide(){
	var dato = document.getElementById("aktuellDato").value;
	var url = location.href;
	url = url.split("?");
	location.href= url[0]+"?dato="+dato;
}
 
function forrigeDag(){
var dag = "<?php 
$tab = explode("-", $_GET['dato']);
$inputDate = ($_GET['dato']=="")?time():mktime(0,0,0,$tab[1],$tab[0], $tab[2]);
echo date("d-m-Y", strtotime('-1 day', $inputDate)); ?>"
var url = location.href;
url = url.split("?");
location.href= url[0]+"?dato="+dag;
}
 
function nesteDag(){
var dag = "<?php 
$tab = explode("-", $_GET['dato']);
$inputDate = ($_GET['dato']=="")?time():mktime(0,0,0,$tab[1],$tab[0], $tab[2]);
echo date("d-m-Y", strtotime('+1 day', $inputDate)); ?>"
var url = location.href;
url = url.split("?");
location.href= url[0]+"?dato="+dag;
}
 
function oppdaterId(){
	oppdaterHiddenfelt();
	var antall = html("antRader");
	if(antall == "0"){
		 antall = 1;
	}else antall++;
	settHTML("antRader", antall);
}
 
function oppdaterTotalId(){
	var totaltAnt = html("raderLaget");
	if(totaltAnt == "0"){
		 totaltAnt = 1;
	}else totaltAnt++;
	settHTML("raderLaget", totaltAnt);
}
 
 
 
function minusId(){
	var antall = html("antRader");
	antall--;
	settHTML("antRader", antall);
	return antall;
}
 
function value(id){
	return document.getElementById(id).value;
}
 
function html(id){
	return document.getElementById(id).innerHTML;
}
 
function settVerdi(id, verdi){
	document.getElementById(id).value = verdi;
}
 
function settHTML(id, verdi){
	document.getElementById(id).innerHTML = verdi;
}
 
function oppdaterHiddenfelt(){
	var antall = value("hiddenAntRader");
	if(antall == "0" || antall == ""){
		 antall = 1;
	}
	else antall++;
	settVerdi("hiddenAntRader", antall);
	return antall;
}
 
function sok(){
	var sokeord = value("sokefelt");
	var currentTime = new Date();
	getFromServer("sokVaktliste.php?ord="+sokeord+"&time="+currentTime.getTime(), visResultat);
}
 
function visResultat(XHR){
 
	document.getElementById('light').style.display='block';
	document.getElementById('fade').style.display='block';
	var url = location.href;
	url = url.split("?");
	var div = document.getElementById('light');
	var html = "";
	if(XHR.responseText != "-1"){
		//location.href= url[0]+"?dato="+dag;
		var datoArray = XHR.responseText.split(":");
		if(datoArray.length >1){
			for(i = 0;i<datoArray.length; i++){
				html = html + "<p style='text-align: center;'><a href='"+url[0]+"?dato="+datoArray[i]+"' style='color: #6D929B;'>"+datoArray[i]+"</a></p>";
			}
		}
	}else{
		html = "<p style='text-align: center;'><a href='"+url[0]+"' style='color: #6D929B;'>Det finnes dessverre ingen treff</a></p>";
	}	
	div.innerHTML = html;
	
}
 
function visOverlapp(){
 
	document.getElementById('light2').style.display='block';
	document.getElementById('fade2').style.display='block';
	var div = document.getElementById('light2');
	var html = '<a href = "javascript:void(0)" style="position:absolute; border: none; top: 0; right: 0;" onclick = "document.getElementById(\'light2\').style.display=\'none\';document.getElementById(\'fade2\').style.display=\'none\'"><img src="gfx/slett.png" width="16" height="16" style="border: none;"/></a>';
	var html = html+ "<p style='font-size: 20px; font-weight: 700;' class='info'> Overlappende vakter</p>";
	div.innerHTML = html;
	
}
 
function sjekkOmEnter(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if(charCode == 13){
		sok();
	}
}
 
function sjekkDobbelVakt(navn, id){
	var antallRader = html("raderLaget");
	idTall = id.substr(4);
	for(i=0;i<=antallRader;i++){
				if(document.getElementById("navn"+i) != null){
					var navnX = document.getElementById("navn"+i);
					navnet = navnX.value
					if(navnet == navn && navnX.id != id){
						var overlapp = false;
						var inn = document.getElementById("inn"+i).value;
						var inn2 = document.getElementById("inn"+idTall).value;
						var ut = document.getElementById("ut"+i).value;
						var ut2 = document.getElementById("ut"+idTall).value;
						if(ut2<ut && ut2>inn) { overlapp = true; }
						if(inn2<ut && inn2>inn) { overlapp = true; }
						//if(inn2<inn && ut2>ut) { alert("3"); overlapp = true; }
						if(inn2==inn && ut2>inn2) { overlapp = true; }
						//if(inn<inn2 && ut>ut2) { alert("overlapp4"); overlapp = true; }
						/*if(ut2> && ut2>inn) overlapp = true;
						if(ut2<ut && ut2>inn) overlapp = true;
						if(ut2<ut && ut2>inn) overlapp = true;*/
						if(overlapp== true){ 
							visOverlapp();
						}
					}
				}
	}
}
 
function finnAnsattNrForNavn(id){
	var currentTime = new Date();
	var number = id.split("navn");
	var IndexValue = eval("document.vaktlisteForm.navn"+number[1]+".selectedIndex");
	var SelectedVal = eval("document.vaktlisteForm.navn"+number[1]+".options[IndexValue].value");
	getFromServer("vaktlisteAjax.php?navn="+SelectedVal+"&rad="+number[1]+"&time="+currentTime.getTime(), skiftAnsattnr);
}
 
function skiftAnsattnr(XHR){
	var tab = XHR.responseText.split("-");
	var IndexValue = tab[0];
	id = "ansattnr"+tab[1];
	var tabellLengde = <?php echo sizeof($nummer); ?>;
	for(i = 0;i<tabellLengde;i++){
		var e = eval("document.vaktlisteForm."+id+".options["+i+"].value");
		if(eval("document.vaktlisteForm."+id+".options["+i+"].value") == IndexValue){
			var y = eval("document.vaktlisteForm."+id);
			y.selectedIndex = i;
		}
	}
}
 
function finnNavnForAnsattnr(id){
	var currentTime = new Date();
	var number = id.split("ansattnr");
	var IndexValue = eval("document.vaktlisteForm.ansattnr"+number[1]+".selectedIndex");
	var SelectedVal = eval("document.vaktlisteForm.ansattnr"+number[1]+".options[IndexValue].value");
	getFromServer("vaktlisteAjax.php?nummer="+SelectedVal+"&rad="+number[1]+"&time="+currentTime.getTime(), skiftNavn);
}
 
function skiftNavn(XHR){
	var tab = XHR.responseText.split("-");
	var IndexValue = tab[0];
	id = "navn"+tab[1];
	var tabellLengde = <?php echo sizeof($navn); ?>;
	for(i = 0;i<tabellLengde;i++){
		var e = eval("document.vaktlisteForm."+id+".options["+i+"].value");
		if(eval("document.vaktlisteForm."+id+".options["+i+"].value") == IndexValue){
			var y = eval("document.vaktlisteForm."+id);
			y.selectedIndex = i;
		}
	}
}
</script>
</head>
 
<body onLoad="finnDagForDato('<?php if(isset($_GET['dato'])) echo $_GET['dato']; else echo date("d-m-Y"); ?>')" style="background-image:none;">
		<div id="light" class="white_content"><a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div>
		<div id="fade" class="black_overlay"></div>
        
		<div id="light2" class="white_content"><a href = "javascript:void(0)" onclick = "document.getElementById('light2').style.display='none';document.getElementById('fade2').style.display='none'">Close</a></div>
		<div id="fade2" class="black_overlay"></div>
        
<div id="antRader" style="visibility:hidden;">0</div>
<div id="fortidVarsel" style="position:absolute; font-size:16px; font-weight:bold; color:#990000;"><?php if($fortid) echo "Fortid!"; ?></div>
<div id="raderLaget" style="visibility:hidden;">0</div>
<div id="lagreBeskjed" style="position:absolute; left:350px; top:225px; width: 200px; height: 200px; border:solid 1px #6D929B; display:none; background-color:#CCCCCC; z-index: 1500;">
	<span style="font-size:24px; color: #6D929B; text-align:center;">Lagring vellykket!</span>
	<div id="lukkLagreBeskjed" onclick="toggleLayer('lagreBeskjed')" style="position:absolute; bottom:0px; width:198px; border-top: #999999 solid 1px; height:20px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer; border:solid 1px #999999;" ><img src="gfx/hake.png" /></div>
</div>
 
<div id="vaktliste">
 
<div id="sokefeltDiv"  style="position:absolute; left: 350px; top: 25px;">
<input id="sokefelt" name="sokefelt" type="text" value="Søk" width="150px" onkeydown="sjekkOmEnter(event)" />
        <a href = "javascript:void(0)" onclick = "sok()">
        	<img onclick="sok()" src="gfx/sok.png" width="18" height="18" style="position:relative; padding-left: 6px; margin-bottom: -3px; border:none;"/>
        </a>
</div>
 
<form name="vaktlisteForm" id="vaktlisteForm" action="?lagreVakt=1" method="post">
<input type="hidden" id="hiddenAntRader" name="hiddenAntRader" />
<div id="spesieltDiv" style="position:absolute; left:375px; top:70px; width:auto; height: auto; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<textarea name="spesielt" id="spesielt" rows="5" cols="10" style="border:hidden; height:126px; width: 246px; overflow:auto; padding:2px;" ><?php echo $spesielt; ?> </textarea>
<div id="lukkSpesieltDiv" onclick="toggleLayer('spesieltDiv')" style="position:absolute; bottom:0px; width:150px; border-top: #999999 solid 1px; height:20px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer; margin-left:179px; border:solid 1px #999999;" ><img src="gfx/hake.png" /></div>
</div>
<div id="notaterDiv" style="position:absolute; left:470px; top:70px; width:auto; height: auto; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<textarea name="notater" id="notater" rows="5" cols="10" style="border:hidden; height:126px; width: 246px; overflow:auto; padding:2px;" ><?php echo $notater; ?> </textarea>
<div id="lukkNotaterDiv" onclick="toggleLayer('notaterDiv')" style="position:absolute; bottom:0px; width:150px; border-top: #999999 solid 1px; height:20px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer; margin-left:179px; border:solid 1px #999999;" ><img src="gfx/hake.png" /></div>
</div>
<div id="budsjettDiv" style="position:absolute; left:565px; top:70px; width:250px; height: 100px; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<input type="text" name="budsjett" value="<?php echo $budsjett; ?>"  style="position:absolute;height:20px; width: 150px; overflow:auto; top:25px; left:50px; background: url('gfx/kr.png') no-repeat right;" ></input>
<div id="aarsbudsjett" style="position:absolute; right: 10px; top: 2px; cursor:pointer; color:#0066FF;" onclick="window.open('budsjett.php','newWin','width=400,height=500')">&aring;rsbudsjett</div>
<div id="lukkBudsjettDiv" onclick="toggleLayer('budsjettDiv')" style="position:absolute; bottom:0px; width:250px; border-top: #999999 solid 1px; height:22px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer;" ><img src="gfx/hake.png" /></div>
</div>
<div id="omsetningDiv" style="position:absolute; left:660px; top:70px; width:250px; height: 100px; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<input type="text" name="omsetning" value="<?php echo $omsetning; ?>" style="position:absolute;height:18px; width: 150px; overflow:auto; top:25px; left:50px; background: url('gfx/kr.png') no-repeat right;" > </input>
<div id="lukkOmsetningDiv" onclick="toggleLayer('omsetningDiv')" style="position:absolute; bottom:0px; width:250px; border-top: #999999 solid 1px; height:22px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer;" ><img src="gfx/hake.png" /></div>
</div>
 
<table id="overst" cellspacing="0" cellpadding="0" rules="none" frame="box" border="0">
    <tr>
        <td width='400px' align='left' style="color:#666666;"> Vaktliste</td>
        <td width="400px" style="text-align:right; color:#999999; padding: 0px; margin: 0px;"><span class="tidOgDato"></span><script language="javascript" src="js/liveclock.js"></script></td>
    </tr>
</table>
<div style="position:absolute; padding:0; margin:0; border: width: 400px; height: 20px;"> 
<div id="forrige" onclick="forrigeDag()" style="position:absolute; left:30px; width:20px; height: 20px; cursor:pointer; z-index:100;"><span style="color:#6D929B;"><<</span></div>
<div id="neste" onclick="nesteDag()" style="position:absolute; left:155px; width:20px; height: 20px; cursor:pointer; z-index:100;"><span style="color:#6D929B;">>></span></div>
</div>
<br />
<table id="notiserTabell" class="vaktliste" border="0" bordercolor="#FFFFFF" rules="none" frame="box" cellpadding="0" cellspacing="0">
    <tr>
        <td id="dato" height="30px" width="210px" class="notiser">Dato<?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?> <input onchange="lastSide()" type="text" name="aktuellDato" id="aktuellDato" style="background:url('gfx/calendar.png') no-repeat right;" /><?php }else {?> <input type="text" name="aktuellDato" id="aktuellDato" value=<?php echo date("d.m.Y");?> /><?php } ?></td>
        <td height="30px" width="210px" class="notiser">Ukedag: &nbsp;&nbsp;<span id="ukedag" style="color:#000000; font-size:16px; font-weight:500;"></span></td>
        <td id="spesielt" height="30px" width="94px" class="notiser2"><span onmousedown="visDiv('spesielt')" style="cursor:pointer;"> Events<img src="gfx/endre.png"/></span></td>
        <td id="notat" height="30px" width="94px" class="notiser2"><span onmousedown="visDiv('notater')" style="cursor:pointer;">Notater <img src="gfx/endre.png"/></span></td>
        <td id="budsjett" height="30px" width="92px" class="notiser2"><span onmousedown="visDiv('budsjett')" style="cursor:pointer;">Budsjett <img src="gfx/endre.png"/></span></td>
        <td id="omsetning" height="30px" width="92px" class="notiser2"><span onmousedown="visDiv('omsetning')" style="cursor:pointer;">Omsetning <img src="gfx/endre.png"/></span></td>
    </tr>
</table>
<table id="vaktlistetabell" width="820" name="vaktlistetabell" cellpadding="0" cellspacing="0" style="padding: 0px;">
    <tr>
    	<th scope="col" width="120px" class="nobg">Navn</th>
        <th scope="col" width="80px">ANS.NR</th>
        <th scope="col" width="60px" >Inn</th>
        <th scope="col" width="60px" >Ut</th>
        <th scope="col"><img src="gfx/tidslinje.png" /></th>
        <th scope="col" width="60px" >Lunch</th>
        <th scope="col" width="90px" >Sykefravær</th>
    </tr>
	<?php 
	$fargetLinje = true;
	$x = 0;
	$rader = sizeof($navnVakt);
	?>
 
    <?php
	if($rader == 0) $rader = 1;
	for($i=0;$i<$rader;$i++){ 
	
		?><script>oppdaterHiddenfelt(); oppdaterId(); if(0 != <?=$i;?>)oppdaterTotalId();</script><?php
		
		if($i==0) $fargetLinje = true;
		else{
			if($i % 2 == 1){
			 	$fargetLinje = false;
			}
			else $fargetLinje = true;
		}
		
	
	?>
    <tr <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA;" <?php } ?> >
    	<td width="120px" style="text-align:right;">
        	<select name="navn<?php echo $i; ?>" id="navn<?php echo $i; ?>" style="width: 118px; border: hidden; text-align:left;" onchange="javascript: sjekkDobbelVakt(this.value, this.id); finnAnsattNrForNavn(this.id)">
				<?php foreach($navn as $key => $value){ ?> 
							<option value="<?php echo $value; ?>" <?php if($value==$navnVakt[$i]) echo " selected"; ?>><?php echo $value; ?></option>            
				<?php } ?> 
            </select></td>
        <td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align:right;" <?php } ?> width="80x"  style="text-align:right;">
        	<select name="ansattnr<?php echo $i; ?>" id="ansattnr<?php echo $i; ?>" style="width: 80px; text-align:center;" onchange="finnNavnForAnsattnr(this.id)"><?php foreach($nummer as $key => $value){ ?> 
						<option value="<?php echo $value; ?>" <?php if($value==$nummerVakt[$i]) echo " selected";?>><?php echo $value; ?></option> <?php } ?> 
            </select>
        </td>
        <td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align: right;" <?php } ?> width="60px" style="text-align: right;">
        	<select name="inn<?php echo $i; ?>" id="inn<?php echo $i;?>" style="width: 60px;" onchange="lagDiv(<?php echo $i; ?>)">
				<?php for($j=0;$j<48;$j++){
						if($fraBase) $selected = ($tider[$j]==$innVakt[$i])?" selected":"";
						else $selected = ($tider[$j]=="12:00")?" selected":"";
						echo "<option value=".$tider[$j]."".$selected.">".$tider[$j]."</option>";
				}?>
            </select></td>
        <td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; width: 60px; text-align:right; padding-right: 0px;" <?php } ?> width="60px" style="padding-right: 0px;text-align:right;">
			<select name="ut<?php echo $i; ?>" id="ut<?php echo $i;?>" style="width: 60px; padding-right: 0px; text-align:center;" onchange="lagDiv(<?php echo $i; ?>)">
				<?php for($j=0;$j<48;$j++){
						if($fraBase) $selected = ($tider[$j]==$utVakt[$i])?" selected":"";
						else $selected = ($tider[$j]=="12:00")?" selected":"";
						echo "<option value=".$tider[$j]."".$selected.">".$tider[$j]."</option>";
				}?></select></td>
        <td><div id="rad<?php echo $i; ?>" style="position: relative; margin: 0px; padding: 0px; height: 20px;" /></td>
        
        <td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align:right;" <?php } ?> width="62px" style="text-align:right;"><div id="lunchDiv<?php echo $i; ?>" onmouseover="musOverBakgrunn('lunchDiv<?php echo $i; ?>')" onClick="toggleCheckbox('lunchbox<?php echo $i; ?>')" onmouseout="musUt('lunchDiv<?php echo $i; ?>')" height="20px" width="62px"><?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?><input id="lunchbox<?php echo $i; ?>" type="checkbox" onClick="toggleCheckbox('lunchbox<?php echo $i; ?>')" name="<?php echo "lunchbox".$i;?>" 
<?php if($lunchVakt[$i]=="ja") echo " checked"; ?>  /><?php } else echo "logginn";?></div></td>
        
        <td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align:right;" <?php } ?> width="90px" style="text-align:right;"><div id="sykDiv<?php echo $i; ?>" onmouseover="musOverBakgrunn('sykDiv<?php echo $i; ?>')" onClick="toggleCheckbox('sykbox<?php echo $i; ?>')" onmouseout="musUt('sykDiv<?php echo $i; ?>')" height="20px" width="90px"><?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?><input id="sykbox<?php echo $i; ?>" type="checkbox" onClick="toggleCheckbox('sykbox<?php echo $i; ?>')" name="<?php echo "sykbox".$i; ?>" <?php if($sykVakt[$i]=="ja") echo " checked"; ?> /> <?php }else echo "logg inn";?></div></td>
    <td onclick="slettRad(<?php echo $i+1; ?>)" id="slett<?php echo $i+1?>" style="background:#FFFFFF; border:none; padding:5px;"><img src="gfx/slett.png" width="11px" height="11px"/></td>
    </tr>
    <?php $x = ($x==1)?0:1;} ?>
 
</table>
<?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?>
		<div id="buttonsDiv" style="position:absolute; width: 795px; height: 50px;">
			<input type="submit" value="lagre" style="position:absolute; right:10px; top:10px; background:url('gfx/lagre.png') no-repeat right; width: 120px; height: 30px; text-align:left; border: 1px solid #C1DAD7; color: #6D929B; font-size: 13px; font-weight: bold; font-family: "microsoft Sans Serif";"/>
            <img src="gfx/add.png" onclick="leggTilRad()" style=" cursor:pointer;position:absolute; border:none; left: 10px; top:10px"/>
        </div>
</form>
<?php } ?>
 
<script>
	for(o=0;o<<?php echo (sizeof($navnVakt)); ?>; o++){
		lagDiv(o);
	}
</script>
<?php if(!(isset($_GET['dato'])) && !(isset($_GET['lagreVakt']))){?>
	<script>
		var datofelt = document.getElementById("aktuellDato");
		datofelt.value = "<?php echo date("d-m-Y"); ?>";
	</script>
<?php } ?>
</div>
<a href="#" onclick="window.print()" style="position:absolute; right: 10px; bottom:10px; color:#0033FF; border-bottom: 0px none; border-color:#FFFFFF;">Skriv ut <img src="gfx/action_print.gif" border="0"/></a>
<script type="text/javascript">
/*<[CDATA[*/
 var dpck2	= new DatePicker({
  relative	: 'aktuellDato',
  language	: 'no',
  keepFieldEmpty : true,
  disableFutureDate : false,
  dateFormat : [ ["dd", "mm", "yyyy"], "-" ]
  });
/*]]>*/
</script>
</body>
</html>
[+][-]10.11.2008 at 10:39PM PDT, ID: 22696454

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.11.2008 at 11:16PM PDT, ID: 22696505

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.11.2008 at 11:24PM PDT, ID: 22696519

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.12.2008 at 12:32AM PDT, ID: 22696632

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.12.2008 at 08:31AM PDT, ID: 22697748

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2008 at 09:27AM PDT, ID: 22697927

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2008 at 09:34AM PDT, ID: 22697962

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2008 at 10:06AM PDT, ID: 22698059

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2008 at 10:22AM PDT, ID: 22698120

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2008 at 12:11PM PDT, ID: 22698499

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Safari Web Browser, JavaScript
Tags: javascript, safari
Sign Up Now!
Solution Provided By: sh0e
Participating Experts: 2
Solution Grade: A
 
 
[+][-]10.12.2008 at 12:13PM PDT, ID: 22698504

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.12.2008 at 03:25PM PDT, ID: 22699136

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2008 at 03:41PM PDT, ID: 22699182

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 - Hierarchy / EE_QW_2_20070628