		// javascript subst_count();
		function substr_count( haystack, needle, offset, length ) {
		
			var pos = 0, cnt = 0;
		
			if(isNaN(offset)) offset = 0;
			if(isNaN(length)) length = 0;
			offset--;
		
			while( (offset = haystack.indexOf(needle, offset+1)) != -1 ){
				if(length > 0 && (offset+needle.length) > length){
					return false;
				} else{
					cnt++;
				}
			}
		
			return cnt;
		}
		
		// javascript trim()
		function trim(str, chars) {
			return ltrim(rtrim(str, chars), chars);
		}
		
		function ltrim(str, chars) {
			chars = chars || "\\s";
			return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
		}
		
		function rtrim(str, chars) {
			chars = chars || "\\s";
			return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
		}

		
		jQuery(document).ready(function() {
				
				// NicEdit
				var nmbrTextarea = jQuery("#nicedit").size();
				if(nmbrTextarea != 0) {
					bkLib.onDomLoaded(function() {
						new nicEditor({iconsPath : 'code/js/nicedit/nicEditorIcons.gif', buttonList : ['bold', 'italic', 'underline', 'ul', 'ol', 'subscript','superscript', 'link', 'unlink']}).panelInstance('nicedit');
						
					});
			}
			
			/*jQuery("#validHTML").w3cValidator({
				parserLocation: "code/js/w3cValidator.php",
				URL_isValid: '<a class="standardLink" href="http://validator.w3.org/check?uri=referer">valides XHTML</a>',
				URL_isInvalid: ''
			});*/
				
			// Forward to programsPage by clicking a program in the list...^^
			jQuery("div[id^=id_]").click(function() {
				var progID		= jQuery(this).attr("id");
				var progHref	= jQuery("#p"+progID).attr("href");
				location.href	= progHref;
			});
			
			// Upload a Program --> Only show subcategories corresponding to the currently selected category
			jQuery("option[id^=catID]").hide();
			jQuery("option:selected]").show();
			jQuery("#uploadProgCategory").change(function() {
			var selectCatID = jQuery("#uploadProgCategory").attr("value");
				jQuery("option[id^=catID]").hide();
				jQuery("option[id=catID_"+selectCatID+"]").show();
			});
			
			
			// Screenshot "browser"
				// Show / hide what is needed
					jQuery(".programScreenshot").hide();
					
				// Get the data that will be needed
					var currentScreenPosition	 = 1;
					var nmbrOfScreenshots		 = jQuery(".programScreenshot").size();
				
				// Add the HTML, that is needed
					jQuery(".universalDownloadArchive_screenshot").before('<div id="screenshotShowCurrentPosition" class="minifont"></div>');
					jQuery(".programScreenshot:last").after('<div class="screenshotNavigation minifont"></div>');
					
				
				// Number the screenshots			
			// User specific variables
			var wizardStartByStepNmbr			= 1;						// Define by which step the wizard should start
			var hideAllStepApartCurrent			= 1;						// Define if you want to hide steps, that are not currently selected (0 = no | 1 = yes)
			var showCurrentStepNmbr				= 1; 						// Define if the current step number should be shown (0 = no | 1 = yes)
			var showCurrentStepTitle			= 0;						// Define wheter you want to show the step title or not (0 = no | 1 = yes)
				var attrToGetStepTitle				= "title";					// Define in which attribute you store the step title
				var showCurrentStepText_Title		= "-"; 						// [Text] used to make this: Step 1 of 3 [Text] Steptitle
			var elementToTransformToWizard		= ".programScreenshot";		// Define the class into which you packed your single steps (use jQuery Syntax)
			var elementToAddNaviAfter			= ".screenNaviHere";		// Define element after which you want to add the navigation
				var showCurrentStepText_step		= "Bild"; 				// Text used for "Step"
				var showCurrentStepText_of			= "von"; 					// Text used for "of"
				var showCurrentStepText_forward		= "Vorw&auml;rts"; 				// Text used for "Forward"
				var showCurrentStepText_back		= "Zur&uuml;ck"; 			// Text used for "Back"
			
			// Script specific variables
			var currentStepPosition				= wizardStartByStepNmbr;						// Which step is current shown
			var differentStepsNmbr 				= jQuery(elementToTransformToWizard).size();	// How many steps does the wizard consists in?
				
				
				// CODE --- DO NOT CHANGE //
				
				// Hide all steps
				jQuery(elementToTransformToWizard).hide();
				
				// Function the endue each step with an unique class
				function setStepUniqueClass() {
					var differentStepsNmbrLoop = differentStepsNmbr;
					var uniqueClass = 1; // Counter
					jQuery(elementToTransformToWizard).addClass("temporaryStepClass");
					while(differentStepsNmbrLoop > 0) {
						differentStepsNmbrLoop--;
						jQuery(".temporaryStepClass:first").addClass("step_nmbr_"+uniqueClass);
						jQuery(".step_nmbr_"+uniqueClass).removeClass("temporaryStepClass");
							//alert("step_nmbr_"+uniqueClass);
							uniqueClass++;
					};
				};
				
				// Function to show the current step position
				var firstTimeToExecuteFunction_showCurrentStepPosition = 0;
				
				function showCurrentStepPosition() {
					if(showCurrentStepNmbr == 1) {
						if (firstTimeToExecuteFunction_showCurrentStepPosition == 0) {
							jQuery(elementToTransformToWizard+":first").before("<div class=\"showCurrentStepNmbrDIV\"></div>");
							firstTimeToExecuteFunction_showCurrentStepPosition++;
							//alert("Was the first time");
						};
						if(showCurrentStepTitle == 1) {
							// Get step title
							currentStepTitle  = " "+showCurrentStepText_Title+" ";
							currentStepTitle += jQuery(".step_nmbr_"+currentStepPosition).attr(""+attrToGetStepTitle+"");
						} else {
							currentStepTitle = "";
						}
						jQuery(".showCurrentStepNmbrDIV").html(""+showCurrentStepText_step+" "+currentStepPosition+" "+showCurrentStepText_of+" "+differentStepsNmbr+""+currentStepTitle+"");
					};
				};
				
				// Function to add a forward button
				var firstTimeToExecuteFunction_addForwardLink = 0;
				
				function addForwardLink() {
					if (firstTimeToExecuteFunction_addForwardLink == 0) {
						jQuery(elementToAddNaviAfter+":last").after("<div class=\"showNavigationLinksForwardDIV\"></div>");
						firstTimeToExecuteFunction_addForwardLink++;
					};
					
					if(currentStepPosition < differentStepsNmbr) {
						currentStepPositionForward = currentStepPosition;
						currentStepPositionForward++;
						jQuery(".showNavigationLinksForwardDIV").html("<span name=\""+currentStepPositionForward+"\" class=\"stepByStepWizard_forwad stepByStepWizard_goto\">"+showCurrentStepText_forward+"<!-- ("+showCurrentStepText_step+" "+currentStepPositionForward+")--></span>");
					} else {
						jQuery(".showNavigationLinksForwardDIV").html("");
					};
					jQuery(".stepByStepWizard_goto").click(function() {
							gotoStepNmbr = jQuery(this).attr("name");
							changeStep(gotoStepNmbr);
					});
				};
				
				// Function to add a back button
				var firstTimeToExecuteFunction_addBackLink = 0;
				
				function addBackLink() {
					if (firstTimeToExecuteFunction_addBackLink == 0) {
						jQuery(elementToAddNaviAfter+":last").after("<div class=\"showNavigationLinksBackDIV\"></div>");
						firstTimeToExecuteFunction_addBackLink++;
					};
										
					if(currentStepPosition <= differentStepsNmbr) {
						if(currentStepPosition > 1) {
							currentStepPositionBack = currentStepPosition;
							currentStepPositionBack--;
							jQuery(".showNavigationLinksBackDIV").html("<span name=\""+currentStepPositionBack+"\" class=\"stepByStepWizard_back stepByStepWizard_goto\">"+showCurrentStepText_back+"<!-- ("+showCurrentStepText_step+" "+currentStepPositionBack+")--></span>");
						} else {
							jQuery(".showNavigationLinksBackDIV").html("");
						};
					} else {
						jQuery(".showNavigationLinksBackDIV").html("");
					};
					jQuery(".stepByStepWizard_goto").click(function() {
							gotoStepNmbr = jQuery(this).attr("name");
							changeStep(gotoStepNmbr);
					});
				};
				
				// Function to change to another step
				function changeStep(changeToStepNmbr) {
					// Hide stes that are not used anymore (if user wants to...)
					if(hideAllStepApartCurrent == 1) {
						jQuery(elementToTransformToWizard).hide();
					};
					
					currentStepPosition = changeToStepNmbr;
					// Show new step
					jQuery(".step_nmbr_"+changeToStepNmbr).show();
					
					// Renew navigation
					showCurrentStepPosition();

					if(hideAllStepApartCurrent == 1) {
						addBackLink();
					};
					addForwardLink();
				};
				
				
				setStepUniqueClass();
				showCurrentStepPosition();
				
				// Create Navigation
					addBackLink();
					addForwardLink();

					// Change to another step (do forward / back)
					jQuery(".stepByStepWizard_goto").click(function() {
							gotoStepNmbr = jQuery(this).attr("name");
							changeStep(gotoStepNmbr);
					});
			// Show the start-Step
			jQuery(".step_nmbr_"+wizardStartByStepNmbr).show();
		// End Step by Step Wizard
		
		

		
		// Divices To Select
			jQuery("select[name=divicesToSelect]").change(function() {
				var URI_toGO	 = jQuery(this).attr("value");
				window.location.href = URI_toGO;
			});
		
		});
		
		
