//################
//* 2009-11-27
//################

//******************************************************************************************************
//* String functions
//******************************************************************************************************

//-----------------------------------------------------------------------------		
//  trim
//-----------------------------------------------------------------------------		
function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

//-----------------------------------------------------------------------------		
//  ltrim
//-----------------------------------------------------------------------------		

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

//-----------------------------------------------------------------------------		
//  rtrim
//-----------------------------------------------------------------------------		
function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

//-----------------------------------------------------------------------------		
//  Trim
//-----------------------------------------------------------------------------		
function Trim(trimText)
{
    return trim(trimText, " \t\r\n");
}

//-----------------------------------------------------------------------------		
//  its_whitespace
//-----------------------------------------------------------------------------		
function its_whitespace(string_value) 
{

    // These are the whitespace characters
    var whitespace = " \n\r\t";

    // Run through each character in the string
    for (var counter = 0; counter < string_value.length; counter++) 
	{
        
        // Get the current character
        current_char = string_value.charAt(counter);
        
        // If it's not in the whitespace characters string,
        // return false because we found a non-whitespace character
        if (whitespace.indexOf(current_char) == -1) 
		{
            return false;
        }
    }
    
    // Otherwise, the string has nothing but
    // whitespace characters, so return true
    return true;
}


//-----------------------------------------------------------------------------		
//  AddCharToEndIfNotPresent(testChar)
//-----------------------------------------------------------------------------		
function AddCharToEndIfNotPresent(testChar)
{
	if (this.length > 0)
	{
		checkChar = this.substring(this.length - 1);
		if (checkChar == testChar) return this; else return this + testChar;
	}
	return "";
}
String.prototype.appendIfCharNotPresent = AddCharToEndIfNotPresent;


//-----------------------------------------------------------------------------		
//  GetUserIdEnclosedInBrackets
//-----------------------------------------------------------------------------		
function GetUserIdEnclosedInBrackets(user)
{
	charPos = this.indexOf("[");
	if (charPos > -1)
	{
		userId = this.mid(charPos+1, this.length); 
		charPos = userId.indexOf("]");
		userId = userId.left(charPos); 
		return userId;		
	}
	else
	{
		return -1;
	}
}
String.prototype.bracketId = GetUserIdEnclosedInBrackets;

//-----------------------------------------------------------------------------		
//  GetTextUpToBrackets
//-----------------------------------------------------------------------------		
function GetTextUpToBrackets(user)
{
	var userName;
	charPos = this.indexOf("[");
	if (charPos > -1)
	{
		userName = this.left(charPos); 
		return userName;		
	}
	else
	{
		return "";
	}
}
String.prototype.bracketName = GetTextUpToBrackets;


//-----------------------------------------------------------------------------		
//  ExtractRight
//-----------------------------------------------------------------------------		
function ExtractRight(total_chars)
{
	return this.substring(this.length - total_chars);
}
String.prototype.right = ExtractRight;

//-----------------------------------------------------------------------------		
//  ExtractLeft
//-----------------------------------------------------------------------------		
function ExtractLeft(total_chars)
{
	return this.substring(0, total_chars);
}
String.prototype.left = ExtractLeft;

//-----------------------------------------------------------------------------		
//  ExtractMid
//-----------------------------------------------------------------------------		
function ExtractMid(startChar, stopChar)
{
	return this.substring(startChar, stopChar);
}
String.prototype.mid = ExtractMid;

//-----------------------------------------------------------------------------		
//  Format_Dollars
//-----------------------------------------------------------------------------		
function Format_Dollars(amount)
{
	decimal_places=2;

    // Convert the number to a string
    amount *= 100; amount = Math.round(amount); amount /= 100;
    var value_string = amount.toString();
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".");
    var stringLength = value_string.length;

    // Is there a decimal point?
    if (decimal_location == -1) 
	{        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0;
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : "";
    }
    else 
	{    
        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1;
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length;
    
    if (pad_total > 0) 
	{        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) value_string += "0";
    }

    return value_string;
}


//-----------------------------------------------------------------------------		
//  Getter / Setter Functions
//-----------------------------------------------------------------------------		
function GetValue(nodeName)
{
	sNode = document.getElementById(nodeName);
	return sNode.value;
}

function SetValue(nodeName, nodeValue)
{
	sNode = document.getElementById(nodeName);
	sNode.value = nodeValue;
}

function GetInnerHtmlValue(nodeName)
{
	sNode = document.getElementById(nodeName);
	return sNode.innerHTML;
}

function SetInnerHtmlValue(nodeName, nodeValue)
{
	sNode = document.getElementById(nodeName);
	sNode.innerHTML = nodeValue;
}



//-----------------------------------------------------------------------------		
//  Form Control Functions
//-----------------------------------------------------------------------------		
function GetCheckBoxValue(obj)
{
	var	getstr;
	if (obj.checked) 
	{	getstr = obj.value;	} 
	else 
	{	getstr = "";	}
	return getstr;
}

function ClearDropDownList(current_list)
{
	while (current_list.length > 0)
    {
    	current_list.options[0] = null;
    }
}

function FillDropDownListBox(DNF, result)
{
	ClearDropDownList(DNF);		tmpArray =result.split("\r\n");		y = 0;
	for ( x = 0; x < tmpArray.length; x++)
	{
		tmpData = Trim(tmpArray[x]);
		if (tmpData != "")
		{
			tmpId = tmpData.bracketId();
			tmpName = tmpData.bracketName();
			DNF.options[y] = new Option(tmpName,tmpId);
			y++;
		}
	}
}

function FillInFormFields(result)
{
	delimiter = "~~.~~\r\n";	delimiter2 = "^~DBH~^";
	tmpArray =result.split(delimiter);

	for (i=0; i < tmpArray.length; i++) 
	{
		nameVal = tmpArray[i].split(delimiter2);
		elementId = nameVal[0];		elementId = Trim(elementId);	elementId = Trim(elementId);	elementId = Trim(elementId);
		DFF = document.getElementById(elementId)	
/*
		alert	(
					"elementId= " + elementId + "\r\n" +
					"DFF= " + DFF + "\r\n"
				);
*/


		if (DFF == null)
		{
			nodeTagName = 	"NA";			nodeTagType = 	"NA";
		}
		else
		{
			nodeTagName = 	DFF.tagName;			nodeTagType = 	DFF.type;
			nodeName = 		nameVal[0];				nodeValue = 	nameVal[1];
		}

		switch (nodeTagName)
		{
			case "INPUT":

				switch (nodeTagType)
				{
					case "text":
						DFF.value = nodeValue;
					break;
					
					case "password":
						DFF.value = "";
					break;
					
					case "hidden":
						DFF.value = nodeValue;
					break;
					
					case "button":
						DFF.value = nodeValue;
					break;
					
					case "submit":
						DFF.value = nodeValue;
					break;
					
					case "checkbox":
						if (nodeValue == 1) 
						{	DFF.checked = true  } 
						else 
						{	DFF.checked = false	}
					break;
					
					case "radio":
							if (obj.childNodes[i].checked) 
							{
								getstr += obnodeName + "=" + nodeValue + "&";
							}
					break;						
				}
			break;
			
			case "SELECT":
				// Get the combobox node.
				ddNode = document.getElementById(elementId);

				// Clear field text
				ddNode.text = "";

				// Loop through all of the combobox elements.
				for (ndx=0; ndx < ddNode.options.length; ndx++) 
				{
					ddNode.options[ndx].selected = false;
					if (nodeValue == ddNode.options[ndx].value)
					{
						ddNode.selectedIndex = ndx;
						tmpVal = ddNode.options[ndx].text;
						ddNode.text = tmpVal;
					}
				}
			break;
			
			case "TEXTAREA":
					DFF.value = nodeValue;
			break;
			
		}												
	}	
}
	






//-----------------------------------------------------------------------------		
//  BrowserDetect
//-----------------------------------------------------------------------------		

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

//**********************************************************************************************************************
//  SimpleAjax - Ajax Functions
//**********************************************************************************************************************

var SimpleAjax = 
{
	//-------------------------------------------------------------------------
	// SendRequest
	//-------------------------------------------------------------------------
	SendRequest: function (url, parameters, responder)
	{
//		alert(url + "\r\n" + parameters + "\r\n[" + responder + "]");	

		http_request = false;
		if (window.XMLHttpRequest) 
		{ 
			// Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) 
			{
				// set type accordingly to anticipated content type
				http_request.overrideMimeType('text/html');
			}
		} 
		else if (window.ActiveXObject) 
		{ // IE
			try {	http_request = new ActiveXObject("Msxml2.XMLHTTP");	} 
			catch (e) 
			{
				try {	http_request = new ActiveXObject("Microsoft.XMLHTTP");	} 
				catch (e) {	}
			}
		}
		if (!http_request) 		{	alert('Cannot create XMLHTTP instance');	return false;	}

		// By using an Anonymous callback function for the request handler, we can specify our own handler
		http_request.onreadystatechange = function () 
											{
												if (http_request.readyState == 4) 
												{
													if (http_request.status == 200) 
													{
														result = http_request.responseText;
														
															if ( (responder == "") || (responder == "undefined") ) 
															{
																SimpleAjax.ResponseDecoder(result);
															}
															else
															{
																eval(responder + "(result);");
															}
													} 
													else 
													{
														alert("ERROR!!!\r\n" + http_request.responseText);
													}
												}
											}
				
		http_request.open('POST', url, true);
		http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		http_request.send(parameters);	
	
	},

	//-------------------------------------------------------------------------
	// PostFormId
	//-------------------------------------------------------------------------
	PostFormId: function (name, command, pageUrl, responder) 
	{
		var obj= document.getElementById(name);
		
		this.PostFormElement(obj, command, pageUrl, responder);	 
	},
	
//	Javascript ---------------------------------
//	encodeURIComponent(",/?:@&=+$#");
//	decodeURIComponent(test1);

	//-------------------------------------------------------------------------
	// PostFormElement
	//-------------------------------------------------------------------------
	PostFormElement: function (obj, command, pageUrl, responder) 
	{
		var getstr = "";
		getstr += command + "&";

		for (i=0; i < obj.childNodes.length; i++) 
		{
			nodeTagName = 	obj.childNodes[i].tagName;
			nodeTagType = 	obj.childNodes[i].type;
			nodeName = 		obj.childNodes[i].name;
			nodeValue = 	obj.childNodes[i].value;
//			alert(nodeTagName + "\r\n" + nodeTagType + "\r\n" + nodeName + "\r\n" + nodeValue);
			switch (nodeTagName)
			{
				case "INPUT":

					switch (nodeTagType)
					{
						case "text":
							getstr += nodeName + "=" + encodeURIComponent(nodeValue) + "&";	
						break;
						
						case "password":
							getstr += nodeName + "=" + encodeURIComponent(nodeValue) + "&";	
						break;
						
						case "hidden":
							getstr += nodeName + "=" + encodeURIComponent(nodeValue) + "&";	
						break;
						
						case "button":
							getstr += nodeName + "=" + encodeURIComponent(nodeValue) + "&";	
						break;
						
						case "submit":
							getstr += nodeName + "=" + encodeURIComponent(nodeValue) + "&";	
						break;
						
						case "checkbox":
							if (obj.childNodes[i].checked) 
							{	getstr += nodeName + "=" + encodeURIComponent(nodeValue) + "&";	} 
							else 
							{	getstr += nodeName + "=&";	}
						break;
						
						case "radio":
							if (obj.childNodes[i].checked) 
							{
								getstr += obnodeName + "=" + encodeURIComponent(nodeValue) + "&";
							}
						break;
						
					}

				break;
				
				case "SELECT":
					var sel = obj.childNodes[i];	
					indx = sel.selectedIndex;
					if (indx < 0)
					{ getstr += sel.name + "=&";}
					else
					{ getstr += sel.name + "=" + encodeURIComponent(sel.options[sel.selectedIndex].value) + "&";}
				break;
				
				case "TEXTAREA":
					getstr += obj.childNodes[i].name + "=" + encodeURIComponent(nodeValue) + "&";	
				break;
				
			}
						
		}
		this.SendRequest(pageUrl, getstr, responder);
	},
	
	//-------------------------------------------------------------------------
	// ResponseDecoder
	//-------------------------------------------------------------------------
	ResponseDecoder: function (req_data) 
	{
//		alert (req_data);		
		colonPos = req_data.indexOf(":");
		if (colonPos > -1)
		{
			command = req_data.left(colonPos); command = command.toUpperCase(); command = Trim(command);
			data = req_data.mid(colonPos+1, req_data.length);
		
			if (command == "MESSAGE" )
			{
				alert (data);
			}
			if (command == "COMMAND" )
			{
				colonPos = data.indexOf(":");
				command = data.left(colonPos); command = command.toUpperCase();
				cmddata = data.mid(colonPos+1, data.length);
				ReplyCommandDecoder(command, cmddata);
			}
		}

	}
};
















//**********************************************************************************************************************
//  getScrollXYWH()
//**********************************************************************************************************************
function getScrollXYWH() 
{
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) 
	{
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} 
	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
	{
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} 
	else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
	{
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}


	// Calculate the page width and height 
	if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) 
	{
		var pageWidth = document.body.scrollWidth;
		var pageHeight = document.body.scrollHeight;
	} 
	else
	if( document.body.offsetWidth ) 
	{
		var pageWidth = document.body.offsetWidth;
		var pageHeight = document.body.offsetHeight;
	} 
	else 
	{
		var pageWidth='100%';
		var pageHeight='100%';
	}   

	return [ scrOfX, scrOfY, pageWidth, pageHeight];
}

//**********************************************************************************************************************
//  Browser Window Scroll and Size functions
//**********************************************************************************************************************

function GetScrollTop()
{
	var scrollTop =  GetScrollInfo(new Array("window.pageYOffset"), new Array("document.documentElement", "scrollTop"), new Array("document.body", "scrollTop"), 0);
	return scrollTop;
}

function GetScrollLeft()
{
	var scrollLeft = GetScrollInfo(new Array("window.pageXOffset"), new Array("document.documentElement", "scrollLeft"), new Array("document.body", "scrollLeft"), 0);
	return scrollLeft;
}

GetScrollInfo=function()
{
    var temp = 0, a, arg, newVal;
    for (a = 0; a < arguments.length - 1; a++)
    {
        arg = arguments[a];
        newVal = ((arg[1]) ? arg[0] + "." + arg[1] : arg[0]);
        eval("if ((" + arg[0] + ") && (" + newVal + ")" + ((temp) ? " && (" + newVal + " < " + temp + ")" : "") + ") { var temp = " + newVal + "; }");
    }
    return ((temp) ? temp : arguments[arguments.length - 1]);
}


//**********************************************************************************************************************
//  Gray out screen 
//**********************************************************************************************************************
function grayOut(vis, options) 
{
	// Pass true to gray out screen, false to ungray
	// options are optional.  This is a JSON object with the following (optional) properties
	// opacity:0-100         // Lower number = less grayout higher = more of a blackout 
	// zindex: #             // HTML elements with a higher zindex appear on top of the gray out
	// bgcolor: (#xxxxxx)    // Standard RGB Hex color code
	//
	// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
	//
	// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
	// in any order.  Pass only the properties you need to set.
	var options = options || {}; 
	var zindex = options.zindex || 1500;
	var opacity = options.opacity || 70;
	var opaque = (opacity / 100);
	var bgcolor = options.bgcolor || '#000000';
	var dark=document.getElementById('darkenScreenObject');

	if (!dark) 
	{
		// The dark layer doesn't exist, it's never been created.  So we'll
		// create it here and apply some basic styles.
		// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
		var tbody = document.getElementsByTagName("body")[0];
		var tnode = document.createElement('div');           // Create the layer.
		tnode.style.position='absolute';                 // Position absolutely
		tnode.style.top='0px';                           // In the top
		tnode.style.left='0px';                          // Left corner of the page
		tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
		tnode.style.display='none';                      // Start out Hidden
		tnode.id='darkenScreenObject';                   // Name it so we can find it later
		tbody.appendChild(tnode);                            // Add it to the web page
		dark=document.getElementById('darkenScreenObject');  // Get the object.
	}
	
	if (vis) 
	{
		// Calculate the page width and height 
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) 
		{
			var pageWidth = document.body.scrollWidth+'px';
			var pageHeight = document.body.scrollHeight+'px';
		} 
		else
		if( document.body.offsetWidth ) 
		{
			var pageWidth = document.body.offsetWidth+'px';
			var pageHeight = document.body.offsetHeight+'px';
		} 
		else 
		{
			var pageWidth='100%';
			var pageHeight='100%';
		}   
		//set the shader to cover the entire page and make it visible.
		dark.style.opacity=opaque;                      
		dark.style.MozOpacity=opaque;                   
		dark.style.filter='alpha(opacity='+opacity+')'; 
		dark.style.zIndex=zindex;        
		dark.style.backgroundColor=bgcolor;  
		dark.style.width= pageWidth;
		dark.style.height= pageHeight;
		dark.style.display='block';                          
	} 
	else 
	{
		dark.style.display='none';
	}
}





//**********************************************************************************************************************
//  Picture Display Functions
//**********************************************************************************************************************
arr_picture = new Array();

//---------------------------------------------------------------------------------------------
function AssignSinglePicInfo(pic)
{
	arr_picture[0] = "/auctions/pictures/batch/" + pic;
	ShowPicByIndex(0);
}

//---------------------------------------------------------------------------------------------
function PrevPic()
{
	if (currentPic > 0)
	{
		ShowPicByIndex(currentPic - 1)
		ShowHideButtons();
	}
}

//---------------------------------------------------------------------------------------------
function NextPic()
{
	if (currentPic < arr_picture.length -1)
	{
		ShowPicByIndex(currentPic + 1)
		ShowHideButtons();
	}
}

//---------------------------------------------------------------------------------------------
function ShowPicByIndex(picIndex)
{
	// Hide the main row
	var px=document.getElementById("mainRow");		px.style.visibility="hidden";

	scrollLeft = GetScrollLeft();
	scrollTop =  GetScrollTop();

	var px=document.getElementById("picName");		px.src=arr_picture[picIndex];

	var x=document.getElementById("picx");			x.style.visibility="visible";

	if (scrollTop < 225 ) scrollTop = 225;
	x.style.top=scrollTop + 5;
//	x.style.left=scrollLeft+5;
//	x.style.top=225;
	x.style.left=205;


	// Set the current picture index to the displayed picture
	currentPic = picIndex;

	// Load an image and set the onLoad and onError callbacks
	var myImage = new Image();
	myImage.name = arr_picture[picIndex];
	myImage.onload = getWidthAndHeight;
	myImage.onerror = loadFailure;
	myImage.src = arr_picture[picIndex];

	// Gray out the screen
	grayOut(true);
	
}

function getWidthAndHeight() 
{
	width = this.width;
	height = this.height;
	
	// Set the box sizes	
	var x=document.getElementById("picx");			x.style.width=width + 6;		x.style.height=height + 40;
	
	// Place the Buttons
	var x=document.getElementById("picPrev");		x.style.left=  6;			x.style.top=height + 6;
	var x=document.getElementById("picNext");		x.style.left= 63;			x.style.top=height + 6;
	var x=document.getElementById("picHide");		x.style.left= width-15;		x.style.top= 1;
	
	// Show the prev and next buttons
	ShowHideButtons()

	
	
//	alert ('The image size is '+width+'*'+height);
//    alert("'" + this.name + "' is " + this.width + " by " + this.height + " pixels in size.");
    return true;
}

function loadFailure() 
{
    alert("'" + this.name + "' failed to load.");
    return true;
}

//---------------------------------------------------------------------------------------------
function HideIt()
{
	scrollLeft = GetScrollLeft();
	scrollTop =  GetScrollTop();

	var x=document.getElementById("picx");			x.style.visibility="hidden";
	var px=document.getElementById("picPrev");		px.style.visibility="hidden";
	var px=document.getElementById("picNext");		px.style.visibility="hidden";
	var px=document.getElementById("mainRow");		px.style.visibility="visible";
	
	grayOut(false);
	
}

//---------------------------------------------------------------------------------------------
function ShowHideButtons()
{
	if (currentPic > 0)
	{
		var px=document.getElementById("picPrev");		px.style.visibility="visible";
	}
	else
	{
		var px=document.getElementById("picPrev");		px.style.visibility="hidden";
	}

	if (currentPic < arr_picture.length -1)
	{
		var px=document.getElementById("picNext");		px.style.visibility="visible";
	}
	else
	{
		var px=document.getElementById("picNext");		px.style.visibility="hidden";
	}

}




//---------------------------------------------------------------------------------------------
function set_cookie(cookie_name, cookie_value, cookie_expire, cookie_path, cookie_domain, cookie_secure) 
{

    // Begin the cookie parameter string
    var cookie_string = cookie_name + "=" + cookie_value
    
    // Add the expiration date, if it was specified
    if (cookie_expire) {
        var expire_date = new Date()
        var ms_from_now = cookie_expire * 24 * 60 * 60 * 1000
        expire_date.setTime(expire_date.getTime() + ms_from_now)
        var expire_string = expire_date.toGMTString()
        cookie_string += "; expires=" + expire_string
    }
    
    // Add the path, if it was specified
    if (cookie_path) {
        cookie_string += "; path=" + cookie_path
    }

    // Add the domain, if it was specified
    if (cookie_domain) {
        cookie_string += "; domain=" + cookie_domain
    }
    
    // Add the secure Boolean, if it's true
    if (cookie_secure) {
        cookie_string += "; true"
    }
//    alert(cookie_string);
    // Set the cookie
    document.cookie = cookie_string

}

//---------------------------------------------------------------------------------------------
function get_cookie(name_to_get) 
{

    var cookie_pair
    var cookie_name
    var cookie_value
    
    // Split all the cookies into an array
    var cookie_array = document.cookie.split("; ")
    
    // Run through the cookies
    for (counter = 0; counter < cookie_array.length; counter++) {
    
        // Split the cookie into a name/value pair
        cookie_pair = cookie_array[counter].split("=")
        cookie_name = cookie_pair[0]
        cookie_value = cookie_pair[1]
        
        // Compare the name with the name we want
        if (cookie_name == name_to_get) {
        
            // If this is the one, return the value
            return unescape(cookie_value)
        }
    }
    
    // If the cookie doesn't exist, return null
    return null
}


/**
*  AJAX IFRAME FILE UPLOAD METHOD (FileUp)
**/

FileUp = {
	//------------------------------------------------------------
	frame : function(c) 
	{

		var n = 'f' + Math.floor(Math.random() * 99999);
		var d = document.createElement('DIV');
		d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="FileUp.loaded(\''+n+'\')"></iframe>';
		document.body.appendChild(d);

		var i = document.getElementById(n);
		
		if (c && typeof(c.onComplete) == 'function') 
		{
			i.onComplete = c.onComplete;
		}

		return n;
	},

	//------------------------------------------------------------
	form : function(f, name) 
	{
//		alert("Form: " + "f:" + f + " \r\nName: " + name);
		f.setAttribute('target', name);
	},

	//------------------------------------------------------------
	submit : function(f, c) 
	{
//		alert ("Submit: " + f + "  " + c);
		FileUp.form(f, FileUp.frame(c));
		if (c && typeof(c.onStart) == 'function') 
		{
			return c.onStart();
		} 
		else 
		{
			return true;
		}
	},

	//------------------------------------------------------------
	loaded : function(id) 
	{
//		alert ("Loaded: " + id);
		
		var i = document.getElementById(id);
//		alert("Element: " + i + " ID: " + id);
		if (i.contentDocument) 
		{
			var d = i.contentDocument;
		} 
		else if (i.contentWindow) 
		{
			var d = i.contentWindow.document;
		} 
		else 
		{
			var d = window.frames[id].document;
		}
		
		if (d.location.href == "about:blank") 
		{
			return;
		}

		if (typeof(i.onComplete) == 'function') 
		{
			i.onComplete(d.body.innerHTML);
		}
	}

}


//**********************************************************************************************************************
//  ShowWaitingOnServer 
//**********************************************************************************************************************
function ShowWaitingOnServer(vis) 
{
	// Pass true to gray out screen, false to ungray
	var options = options || {}; 
	var zindex = options.zindex || 1500;
	var zindex1 = zindex + 1;
	var opacity = options.opacity || 70;
	var opaque = (opacity / 100);
	var bgcolor = options.bgcolor || '#000000';
	var dark=document.getElementById('waitScreenObject');
	var darkMsg=document.getElementById('waitScreenMsg');

	if (!dark) 
	{
		// The dark layer doesn't exist. So we'll create it here and apply some basic styles.
		// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
		var tbody = document.getElementsByTagName("body")[0];

		// Create the div to shade the page
		var tnode = document.createElement('div');			// Create the layer.
		tnode.style.position='absolute';					// Position absolutely
		tnode.style.top='0px';								// In the top
		tnode.style.left='0px';								// Left corner of the page
		tnode.style.overflow='hidden';						// Try to avoid making scroll bars            
		tnode.style.display='none';							// Start out Hidden
		tnode.id='waitScreenObject';						// Name it so we can find it later

		// Append the new shader div to the body
		tbody.appendChild(tnode);							// Add it to the web page

		// Get the shader divs node
		dark=document.getElementById('waitScreenObject'); 	// Get the object.

		// Create the div to show we are waiting on the server
		var snode = document.createElement('div');			// Create the layer.
		snode.style.position='absolute';					// Position absolutely
		snode.style.left='100px';							// Left corner of the page
		snode.style.top='100px';							// In the top
		snode.style.width='400px';							// Left corner of the page
		snode.style.height='200px';							// Left corner of the page
		snode.style.overflow='hidden';						// Try to avoid making scroll bars            
//		snode.style.display='none';							// Start out Hidden
		snode.style.zIndex=zindex1;        
		
		snode.style.fontSize='20px';        		snode.style.fontWeight='bolder';        snode.style.color='#800000';        
		snode.style.textAlign='center';        
		snode.style.backgroundColor='#FFFFFF';  
		
		snode.style.border='3px';       
		snode.id='waitScreenMsg';							// Name it so we can find it later

		// Append the new shader div to the body
		tbody.appendChild(snode);							// Add it to the web page

		snode.innerHTML = "<br>Your Information has been sent to the server.<br><br>Please wait for the server to reply.";

		// Get the shader msg divs node
		darkMsg=document.getElementById('waitScreenMsg');

	}
	
	if (vis) 
	{
		// Calculate the page width and height 
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) 
		{
			var pageWidth = document.body.scrollWidth+'px';
			var pageHeight = document.body.scrollHeight+'px';
		} 
		else
		if( document.body.offsetWidth ) 
		{
			var pageWidth = document.body.offsetWidth+'px';
			var pageHeight = document.body.offsetHeight+'px';
		} 
		else 
		{
			var pageWidth='100%';
			var pageHeight='100%';
		}   
		//set the shader to cover the entire page and make it visible.
		dark.style.opacity=opaque;                      
		dark.style.MozOpacity=opaque;                   
		dark.style.filter='alpha(opacity='+opacity+')'; 
		dark.style.zIndex=zindex;        
		dark.style.backgroundColor=bgcolor;  
		dark.style.width= pageWidth;
		dark.style.height= pageHeight;
		dark.style.display='block';                          
		darkMsg.style.display='block';
	} 
	else 
	{
		dark.style.display='none';
		darkMsg.style.display='none';
	}
}




