/*************************************/
/*  Script for Eventmarket.com       */
/*  Per Söderkvist					 */
/*  (C) Copyright 2004, GimGif AB	 */
/*************************************/


// rotates the banners
function frameSendData(bannerLocations,refreshRate, baseUrl){
	window.frames["frameReturnData"].document.location = baseUrl + "Adm/StandardModule/Banner/Public/GetBannerInfo.aspx?bannerMod=MainBanners&lang=swe&" + bannerLocations;
	//funcCall = "frameSendData('"+ bannerLocations +"',"+ refreshRate +")";
	// setTimeout(funcCall,refreshRate);
}

// old code
//function openPresentationPageInter(id, baseUrl){
//	var url = baseUrl + "Eventmarket/Internet/PresentationPage.aspx?PageID=" + id;
//	var url = "PresentationPage.aspx?PageID=" + id;
//	var parameters = "width=538,height=600,location=0,menubar=0,status=0,toolbar=0,scrollbars=1,resizable=1";
//	openWin(url, 'PresentationPage', parameters);
//}

// opens a contact page window
function openPresentationPageInter(id){
	var url = "PresentationPage.aspx?PageID=" + id;
	var parameters = "";
	openWin(url, 'PresentationPage', parameters);
}

// opens a contact page window
function openPresentationPageExtra(id){
	var url = "../../Internet/PresentationPage.aspx?PageID=" + id;
	var parameters = "";
	openWin(url, 'PresentationPage', parameters);
}

// opens a helpwindow from backstage
function openHelpPopup(id){
	var url = "../../Internet/HelpPopup.aspx?HelpTextID=" + id;
	var parameters = "width=300,height=400,location=0,menubar=0,status=0,toolbar=0,scrollbars=1,resizable=1";
	openWin(url, 'Help', parameters);
}

// opens a helpwindow from the public site.
function openInterHelpPopup(id){
	var url = "HelpPopup.aspx?HelpTextID=" + id;
	var parameters = "width=300,height=400,location=0,menubar=0,status=0,toolbar=0,scrollbars=1,resizable=1";
	openWin(url, 'Help', parameters);
}

var arrow = "down"; // initial state of the arrow image for switchMenu()

// opens/closes the switch menus
function switchMenu(theObj,callerObj,swapArrows, baseUrl){
	if(swapArrows){
		var theImg = callerObj.getElementsByTagName("img");
		if(theImg!= null){
			if(arrow=="down"){ 
				theImg[1].src = baseUrl + "Eventmarket/Images/ArrowUp.gif"; 
				arrow = "up"; }
			else{ 
				theImg[1].src = baseUrl + "Eventmarket/Images/ArrowDown.gif"; 
				arrow = "down"; }
		}
	}
	switchDisplay(theObj);
}

// -----------------------------------------------------------------------
// Function:   Selects/deselects all checkboxes in a form
// Parameters: strListPrefix: The prefix for all objects in the current list.
//			   strContainderID: The id of the container element (if applicable)
// Returns:    Nothing
// Created by: Per Söderkvist
// Date:       16 mars 2004
// -----------------------------------------------------------------------
function checkAll(strListPrefix, strContainerID){
	// get the user's action (check/uncheck)
	var bolIsChecked = eval("document.forms[0]." + strListPrefix +"_selector_all.checked");
	
	// if there is a container element, use that element
	// to get to the checkboxes (for increased performance)
	if(strContainerID != "")
	{
		objContainer = getObj(strContainerID);
		colElements = objContainer.getElementsByTagName("input");
	}
	else{
		var colElements = document.forms[0].elements;
	}
	
	for(i=0; i<colElements.length; i++){
		if(colElements[i].id.indexOf(strListPrefix) != -1){
			colElements[i].checked = bolIsChecked;
		}
	}
}

// -----------------------------------------------------------------------
// Function:   Deselects the SelectAll checkbox when any checkbox in a row is modified.
// Parameters: strListPrefix: The prefix for all objects in the current list.
// Returns:    Nothing
// Created by: Jonas Höijer
// Date:       24 sept 2003
// -----------------------------------------------------------------------
function DeselectSelectAllCB(strListPrefix){
	var objListElement = getObj(strListPrefix + "_selector_all");
	objListElement.checked = false;
}

// --------------------------------------------------------------------------------
// Function:   Script for setting the max length in a textarea.
// Parameters: objTextArea (object) - The textarea
//			   intMaxChars (int) - The maximum number of characters to allow
// Returns:    Nothing
// Created by: Jonas Höijer
// Date:       04-03-19
// --------------------------------------------------------------------------------
function MaxNoOfChars(objTextArea, intMaxChars) {
	if(objTextArea.value.length > intMaxChars){ 
		// must be > maxChars, not == maxChars or else the substring statement on the next line will cause the function to run again if the user dismisses the alert by pressing the 'enter' key rather than clicking 'OK'.
		objTextArea.value= objTextArea.value.substring(0,intMaxChars); 
		// set field's value equal to first five characters. 
		objTextArea.blur();
		// Move cursor out of form element to keep it from placing itself at position zero, causing an overwrite of the first character
	}
} 