<!--

/*
 * A note of history: (as of 2007-10-17)
 			the first 2 functions, openNewWindow(URLtoOpen, windowName, windowFeatures) and doredirect() 
 * 			are present (and identical) in the /totalmanager/ui/com/affiliate/js/misc.js file!
 * 
 */
 
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
   	newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}

function doredirect(){
	if (document.flogin.countryselect.options[document.flogin.countryselect.selectedIndex].value != "none") {
		location = document.flogin.countryselect.options[document.flogin.countryselect.selectedIndex].value
	}
}


	function openEasyBigger(theURL) {
    	var width = 610;
    	var height = 450;
    	if (screen) {
    		width = screen.width * 0.77;
    		height = screen.height * 0.77;
    	}
    	
    	var temp = window.open( theURL, ""
    							, "scrollbars=yes,width=" + width + ",height=" + height + ",titlebar=no"
    							);
    	temp.focus();
    }


	/* simplist function for disabling the other search criteria input element, depending on the currently checked radio button */
	function disableTheOtherSearchCriteriaInputElem( elemToBeDisabled, elemToBeEnabled ) {
		elemToBeDisabled.disabled = true; 
		elemToBeEnabled.disabled = false; 
	}
	
	
// ======================================================================================================================
// ************************************************** Some master-detail lists assignment utility functions  ************
// NB: These will be shortly replaced by the more user-friendly and modern drag 'n drop functions 
// (using the Rico AJAX framework) 	[2007-10-26, emil.prager@nobelglobe.com]
// ======================================================================================================================
// Remark: this in fact is the content of the /NobelServices/src/common/war-part/js/common/multiSelectSrcDst.js  
// JavaScript file [2007-10-30, emil.prager@nobelglobe.com]

    // --- Move Item ---
    
    function moveByName(srcName, dstName) {
        var src = document.getElementById(srcName);
        var dst = document.getElementById(dstName);
        moveItem(src, dst);
    }
    
    function moveItem(src, dst) {
        var selIndex = src.selectedIndex;
        while (selIndex != null) {
            var option = src.options[selIndex];
            if (option.value != null) {
                var dstLength = dst.length;
                dst.options[dstLength] = new Option(option.text, option.value);
                src.options[selIndex] = null;
            }
            selIndex = src.selectedIndex;
        }
    }
    
    // --- Move All Items ---
    
    function moveAllByName(srcName, dstName) {
        var src = document.getElementById(srcName);
        var dst = document.getElementById(dstName);
        moveAll(src, dst);
    }
    
    function moveAll(src, dst) {
        var length = src.length;
        for (i = 0; i < length; i++) {
            var option = src.options[i];
            var dstLength = dst.length;
            dst.options[dstLength] = new Option(option.text, option.value);
        }
        clearAllItems(src);
    }

    // --- Copy Item ---
    
    function copySingleToMultiByName(srcName, dstName) {
        var src = document.getElementById(srcName);
        var dst = document.getElementById(dstName);
        copyItemSingleToMulti(src, dst);
    }

    function copySingleToMultiByName(srcName, dstName, textPrefix, valuePrefix) {
        var src = document.getElementById(srcName);
        var dst = document.getElementById(dstName);
        copyItemSingleToMulti(src, dst, textPrefix, valuePrefix);
    }
    
    function copyItemSingleToMulti(src, dst) {
        var selIndex = src.selectedIndex;
        var option = src.options[selIndex];
        if (option.value != null) {
            var dstLength = dst.length;
            dst.options[dstLength] = new Option(option.text, option.value);
        }
    }

    function copyItemSingleToMulti(src, dst, textPrefix, valuePrefix) {
        var selIndex = src.selectedIndex;
        var option = src.options[selIndex];
        if (option.value != null) {
            var dstLength = dst.length;
            dst.options[dstLength] = new Option(textPrefix + option.text, valuePrefix + option.value);
        }
    }
    
    // --- Clear Items ---
    
    function clearAllItemsByName(srcName) {
        var src = document.getElementById(srcName);
        clearAllItems(src);
    }

    function clearAllItems(src) {
        for (i = 0; i < src.length; i++) {
            src.options[i] = null;
        }
        src.length = 0;
    }
    
    // --- Submit Items ---
    
    function selectAll(srcName) {
        var src = document.getElementById(srcName);
        var length = src.length;
        for (i = 0; i < length; i++) {
            src.options[i].selected = true;
        }
    }
    
// ********** END of the "Some master-detail lists assignment utility functions" section *******************
	
	
// ******************* Array and select lists utility functions *******************

	/* small utility function to check whether an array contains an element 
	 * (inserted here because I didn't find a js built-in function to do that (or a function from a framework we already use) 
	 */
	function arrayContains( /* Array */ array, /* var */ elem ) {
		for ( var i = 0; i < array.length; i++ )
			if ( array[ i ] != undefined 
				&& elem == array[ i ]
			)
				return true;
			else 
				continue;
		
		return false;
	}

	function sortLexicographicallyByName( a, b ) {
    	var x = a.toLowerCase();
    	var y = b.toLowerCase();
    	return ( (x < y) ? -1 
    				 : ( (x > y) ? 1 : 0 ) 
    		);
	}
	
	function sortList( myListId ) {
		var lb = document.getElementById( myListId );
		arrTexts = new Array();
		arrValues = new Array();
		arrOldTexts = new Array();
	
		for ( i = 0; i < lb.length; i++ ) {
			arrTexts[i] = lb.options[i].text;
			arrValues[i] = lb.options[i].value;
			
			arrOldTexts[i] = lb.options[i].text;
		}
		
		arrTexts.sort( /* sortLexicographicallyByName */ );
		
		for ( i = 0; i < lb.length; i++ ) {
			lb.options[i].text = arrTexts[i];
			for ( j = 0; j < lb.length; j++ ) {
				if ( arrTexts[i] == arrOldTexts[j] ) {
					lb.options[i].value = arrValues[j];
					j = lb.length;
				}
			}
		}
	}
	
	function computeCommaSeparatedStringFromList( myListId ) {
		var lb = document.getElementById( myListId );
		var commaSeparatedIdValues = "";
		// arrValues = new Array();
	
		// TODO: use the javascript buil-in function join() for this!
		var i = -1;
		for ( i = 0; i < lb.length - 1; i++ ) {
			commaSeparatedIdValues += lb.options[i].value + ",";
		}
		if ( i == lb.length - 1 )
			commaSeparatedIdValues += lb.options[i].value;
		
		
		return commaSeparatedIdValues;
	}
	
	
	/* function for filling (populating ) a select list
	 * (the boolean arg appendMode says if the list should be emptied first (if false))
	 */
	function populateSelectList( targetElem, withText, appendMode ) {
		var targetList = document.getElementById( targetElem ); 	// $( targetElem );
		
		if ( ! appendMode )
			targetList.innerHTML = ""; 		// reinitialization;
		
		// we'll use the method accepted by IE (also by Mozilla etc.), with constructing instances of the kind:
		// 		opt = new Option( 'text', 'value' );
		
		var optionValues = withText.getElementsByTagName( "option" );
		var opt; 
		var optValue;
		var optText;
		for ( var i = 0; i < optionValues.length; i++ ) {
			optValue = optionValues[ i ].attributes[ 0 ].nodeValue;
			optText  = optionValues[ i ].firstChild.nodeValue;
			opt = new Option( optText, optValue );
			// alert ( "<opt value=" + optValue + ">" + optText + "</opt>" );
			targetList.options[ targetList.options.length ] = opt;
		}
	}
	
	
// ======================================================================================================================
// ************************************************** Some String utility functions  ************************************
// ======================================================================================================================
// (Remark: the Trim related functions were taken from the /ep/ui/com/enjoyprepaid/totalmanager/interfaces/customer/displayProfile.jsp page)

	// ==================================================================
	// LTrim(string) : Returns a copy of a string without leading spaces.
	// ==================================================================
	function LTrim(str)
	{
		if (str == null) {
			return str;
		}
		var whitespace = new String(" \t\n\r");
		
		var s = new String(str);
		
		if (whitespace.indexOf(s.charAt(0)) != -1) {
			// We have a string with leading blank(s)...
			var j=0, i = s.length;
			
			// Iterate from the far left of string until we
			// don't have any more whitespace...
			while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
				j++;
				
			// Get the substring from the first non-whitespace
			// character to the end of the string...
			s = s.substring(j, i);
		}
		return s;
	}

	// ==================================================================
	// RTrim(string) : Returns a copy of a string without trailing spaces.
	// ==================================================================
	function RTrim(str)
	{
		if (str == null) {
			return str;
		}
	
		// We don't want to trip JUST spaces, but also tabs,
		// line feeds, etc.  Add anything else you want to
		// "trim" here in Whitespace
		var whitespace = new String(" \t\n\r");
		
		var s = new String(str);
		
		if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
			// We have a string with trailing blank(s)...
			var i = s.length - 1;       // Get length of string
			
			// Iterate from the far right of string until we
			// don't have any more whitespace...
			while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
				i--;
				
			// Get the substring from the front of the string to
			// where the last non-whitespace character is...
			s = s.substring(0, i+1);
		}
		
		return s;
	}

	// =============================================================
	// Trim(string) : Returns a copy of a string without leading or trailing spaces
	// =============================================================
	function Trim(str)
	{
		if (str == null) {
			return str;
		}
		return RTrim(LTrim(str));
	}
	
	/**
	 * Preffixes the received number with the zero string if that number consists from a single digit.
	 * That is, 0 to 9 become "00" to "09", while numbers above (or equal to) 10 remain the same.
	 * It is useful for more uniform display in dates, hours etc.
	 * NB: negative numbers are returned as received! (this function is intended to be used only with positive numbers!)
	 */
	function lpadNumberWithZeroIfSingleDigit( number ) {
		if ( number == undefined || number < 0 )
			return number;
		
		var zeroPreffix = "0";
		var emptyString = "";
		if ( number.toString().length == 1 && "0" <= number.toString() && number.toString() <= "9" )
			return zeroPreffix + number;
		else 
			return emptyString + number;
	}
	
	/**
	 * Changes the value of the date part element whose ID is received by preffixing the value with the zero string if that number consists from a single digit.
	 * That is, 0 to 9 become "00" to "09", while numbers above (or equal to) 10 remain the same.
	 * It is useful for more uniform display in dates, hours etc.
	 */
	function lpadDatePartElemWithZeroIfSingleDigit( elementID ) {
		if ( document.getElementById( elementID ) == null )
			return;
		// else set the element value with the padded numeric string
		document.getElementById( elementID ).value = lpadNumberWithZeroIfSingleDigit( document.getElementById( elementID ).value );
	}
	
	/** 
	 * Escapes the HTML sensitive characters from the given string.
	 * Note: 	The built-in javascript function escape makes a great part of the job, 
	 * 		 	but it does not escape the '+' and '/' characters !
	 * 			The built-in escape function is certified to work well 
	 * 			on series of characters in the ISO Latin-1 character set,  
	 * 			which the currently character set used by our pages, ISO 8859-1  
	 * 			(see http://wp.netscape.com/eng/mozilla/3.0/handbook/javascript/ref_d-e.htm#48073 
	 * 			for the official description of an early implementation).
	 * 			Anyway, the more recent javascript implementations deal well 
	 * 			with the more recommendable UTF-8 encoding! (TODO: check this further!)
	 * 			
	 */
	function escapeHtmlSensitiveChars( stringToBeEscaped ) {
		// if null, return what was received
		if ( stringToBeEscaped == null ) {
			return stringToBeEscaped;
		}
		// if the given string does not contain the '+' and '/' characters, 
		// simply rely on the escape built-in javascript function 
		if ( stringToBeEscaped.indexOf( '+' ) == -1 
			& stringToBeEscaped.indexOf( '/' ) == -1 
			) // TODO replace with checking against a given array of unescaped characters
			return escape( stringToBeEscaped );
		
		// The behavior of the java.net.URLEncoder.encode(String, String) method is (on both "UTF-8" and "ISO-8859-1" encodings): 
		// 		'+' --> "%2B"
		// 		'/' --> "%2F"
		var escapedString = escape( stringToBeEscaped );
		escapedString = escapedString.replace( '+', "%2B" );
		escapedString = escapedString.replace( '/', "%2F" );
		
		return escapedString;
	}

// ======================================================================================================================
// *********************** End of the "Some String utility functions" section *******************************************
// ======================================================================================================================


 /***********************************************
 * Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
 * This notice MUST stay intact for legal use
 * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
 ***********************************************/
 
 /* Modified to support Opera and excluded FireFox(no solution for this browser)*/
 function bookmarksite(title,url){
	if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
 }

// -->