/* ALL JS STANDARD FUNCTION FOR THE HTS(I) Presenation Module */

/* the following code is needed by the location selector page */
var currentLocationToShow = undefined;
function showLocation(id){
	if(id != undefined && id != ""){
		if( currentLocationToShow != undefined && currentLocationToShow != "" ){
			$(currentLocationToShow).hide();
		}
		if($(id)){
			$(id).show();
			currentLocationToShow = id;
		}
	}
}

/*  form check stuff for form editor */

var checkFormularErrorMessage = 'please fill all mandatory form elements';
function checkFormular(elem) {
    var form = elem.form;
    var numOfElements;
    var currentElement;
    var count;

    numOfElements = form.length;
    for (count = 0; count < numOfElements; count++) {
        currentElement = form.elements[count];
        if (currentElement.getAttribute("mandatory") != null &&
            (currentElement.getAttribute("mandatory") == true ||
             currentElement.getAttribute("mandatory") == 'true')) {
            //div could be the mandatory label
            if (currentElement.tagName!='DIV') {
                if (currentElement.value == null || currentElement.value == "") {
                   alert(checkFormularErrorMessage);
                   return;
                }
            }
        }
    }

    form.submit();
}


function showVideo (videoTextualId, videowidth, videoheight, windowwidth, windowheight) {
	var videourl = "/htsi/get/params_W0/"+videoTextualId;
	var videoWin = window.open("about:blank", 'Video', 'width='+windowwidth+',height='+windowheight+',left=100,top=200' );
	videoWin.document.open('text/html');
	videoWin.document.write('<html><head><title>HTS</title>\n');
	videoWin.document.write('<style>a , a:link , a:visited , a:active { font-size:12px; text-decoration:underline; color:#407BB7; font-family:Verdana, Geneva, Arial, Helvetica, sans-serif; }\n');
	videoWin.document.write('a:hover { text-decoration:none; }</style>\n');
	videoWin.document.write('</head><body><center>\n');
	videoWin.document.write('<object classid="CLSID:05589FA1-C356-11CE-BF01-00AA0055595A" width="'+videowidth+'" height="'+videoheight+'">\n');
    videoWin.document.write('<param name="src" value="'+videourl+'"></param>\n');
    videoWin.document.write('<param name="filename" value="'+videourl+'"></param>\n');
    videoWin.document.write('<param name="type" value="video/mpeg"></param>\n');
    videoWin.document.write('<embed src="'+videourl+'" type="video/mpeg" width="'+videowidth+'" height="'+videoheight+'"></embed>\n');
    videoWin.document.write('</object>\n');
    videoWin.document.write('<br />&nbsp;<br /><a href="'+videourl+'">Download</a>\n');
	videoWin.document.write('</center></body></html>\n');
	videoWin.document.close();
	if(videoWin == undefined){
		alert("Bitte Pop up Blocker deaktivieren / please deactivate your pop up blocker");
	}
  	videoWin.focus();	
}