/**
 * jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-ad-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */

// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias

 var productId;
 var productName;
 //document.getElementById('user_email').focus();

 function validatefeedback(type)
 {
	if(type == 3)
	{
		if(isWhitespace(document.getElementById('sugg_text').value) || document.getElementById('sugg_text').value.substr(18,8) == 'feedback')
		{
			alert("Please enter your feedback.");
			document.getElementById('sugg_text').focus();
			return false;
		}
		if(document.getElementById('overall_rate').value == 0)
		{
			alert("Please select overall rating.");
			return false;
		}
		var feedback	 = document.getElementById('sugg_text').value;
		var email 		 = document.getElementById('user_email').value;
		var p_range_rate = document.getElementById('p_range_rate').value;
		var prices_rate  = document.getElementById('prices_rate').value;
		var search_rate  = document.getElementById('search_rate').value;	
		var use_rate 	 = document.getElementById('use_rate').value;		
		var overall_rate = document.getElementById('overall_rate').value;		
	}

	if(type != 2)
	{
		var email	=	trimAll(document.getElementById('user_email').value);
	
		if (isWhitespace(email) || email == 'Enter Email Address')
		{		
			alert("Please enter your email address.");
			document.getElementById('user_email').focus();
			return false;
		}		
		else if(!isEmail(email))
		{
		   alert("Please enter your email address in the correct format.");
		   document.getElementById('user_email').focus();
		   return false;
		}	
		else if(!isCharsInBag(email, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@._-"))
		{
			alert("Your email address contains invalid characters.");
			document.getElementById('user_email').focus();
			return false;
		}
	}
	
	try
	{ 
		// Opera 8.0+, Firefox, Safari
		xmlhttp = new XMLHttpRequest();
		//alert(xmlhttp);
	}
	catch(e)
	{
		// Internet Explorer Browsers 
		try
		{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				// Something went wrong 
				alert("Your browser broke!"); 
				return false; 
			}
		}
	}
	
	if(type == 2 || type == 1)
	{
		var url = tmp_rootpath+"jcarousel/lightbox/addstockuser_data.php?email="+email+'&productId='+productId+'&productName='+productName+'&type='+type;
		var param = "email="+email+'&productId='+productId+'&productName='+productName+'&type='+type;
	}
	else if(type == 3)
	{
		var url = "jcarousel/lightbox/addstockuser_data.php?email="+email+'&feedback='+feedback+'&p_range_rate='+p_range_rate+'&prices_rate='+prices_rate+'&search_rate='+search_rate+'&use_rate='+use_rate+'&overall_rate='+overall_rate+'&type='+type;
		var param = 'email='+email+'&feedback='+feedback+'&p_range_rate='+p_range_rate+'&prices_rate='+prices_rate+'&search_rate='+search_rate+'&use_rate='+use_rate+'&overall_rate='+overall_rate+'&type='+type;
	}
	xmlhttp.open('GET', url, true);                      
	
	/* The callback function */
	xmlhttp.onreadystatechange = function() 
	{
		if(type == 2 || type == 3)
		{
			document.getElementById('lightbox-container-image-fd').innerHTML = "<div class='padt125 padb125' align='center'><img src='"+tmp_rootpath+"images/Loader.gif'></div>";
		}
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			var objDetails = xmlhttp.responseText;
			//alert('result'+objDetails);
			if(objDetails != null)
			{   
				if(type == 2 || type == 3)
				{
					document.getElementById('lightbox-container-image-fd').innerHTML = objDetails;
				}
				else if(type == 1)
				{
					document.getElementById('dispemail').style.display='none';
					document.getElementById('hidthank').style.display='none';
					document.getElementById('dispthank').style.display='';				
					document.getElementById('getContent_light').innerHTML=objDetails;
				}
			}
		}
	}                  
	
	/* Send the POST request */
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.send(param);
 }
 
function showOverRating_prod(imgId,cnt){
	var im=cnt;
	
	for(im = cnt; im<=imgId; im++){
		document.getElementById("img"+im).src=tmp_rootpath+'images/yellow_star_17_16.gif';
		document.getElementById("img"+im).alt='Click to rate';
		document.getElementById("img"+im).title='Click to rate';
	}
}

function showOutRating_prod(img_start,img_end,ratingId){
	var im=img_start;
	//alert(ratingId);
	for(im = img_start; im<=img_end; im++){
		if(im <= ratingId)
			document.getElementById("img"+im).src=tmp_rootpath+'images/orange_star_17_16.gif';
		else
			document.getElementById("img"+im).src=tmp_rootpath+'images/grey_star_17_16.gif';
	}
}

function setRating(j,startnum)
{
	var RateFor = '';
	
	for(im = startnum; im<=j; im++){
		document.getElementById("img"+im).src=tmp_rootpath+'images/orange_star_17_16.gif';
		document.getElementById("img"+im).onmouseover = '';
		document.getElementById("img"+im).onclick	  = '';
		document.getElementById("img"+im).onmouseout  = '';
		document.getElementById("img"+im).style.cursor = '';
	}
	var limit = parseInt(startnum)+4;
	
	for(img = j+1; img<=limit; img++)
	{
		document.getElementById("img"+img).src=tmp_rootpath+'images/grey_star_17_16.gif';
		document.getElementById("img"+img).onmouseover = '';
		document.getElementById("img"+img).onclick	  = '';
		document.getElementById("img"+img).onmouseout  = '';
		document.getElementById("img"+img).style.cursor = '';
	}
	switch(startnum)
	{
		case 51:
				RateFor = 'p_range_rate';
				break;
		case 56:
				RateFor = 'prices_rate';
				break;
		case 61:
				RateFor = 'search_rate';
				break;
		case 66:
				RateFor = 'use_rate';
				break;
		case 71:
				RateFor = 'overall_rate';
				break;
	}
	var totalRate = parseInt((parseInt(j)-parseInt(startnum)))+1;
	
	document.getElementById(RateFor).value = totalRate;
}
(function($) {
	/**
	 * $ is an alias to jQuery object
	 *
	 */
	$.fn.lightBox = function(id,backpageurl,type,settings) {
		//alert(id+''+id1);
		
		// Settings to configure the jQuery lightBox plugin how you like
		settings = jQuery.extend({

			// Configuration related to overlay
			overlayBgColor: 		'#000',		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
			overlayOpacity:			0.6,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
			// Configuration related to navigation
			fixedNavigation:		false,		// (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
			// Configuration related to images
			imageLoading:			'jcarousel/lightbox/images/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			'jcarousel/lightbox/images/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
			imageBtnNext:			'jcarousel/lightbox/images/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
			imageBtnClose:			'jcarousel/lightbox/images/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:				'jcarousel/lightbox/images/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)

			// Configuration related to container image box
			containerBorderSize:	10,			// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-ad-box-ad, you will need to update this value
			containerResizeSpeed:	400,		// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
			// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
			txtImage:				'Image',	// (string) Specify text "Image"
			txtOf:					'on',		// (string) Specify text "of"
			// Configuration related to keyboard navigation
			keyToClose:				'c',		// (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
			keyToPrev:				'p',		// (string) (p = previous) Letter to show the previous image
			keyToNext:				'n',		// (string) (n = next) Letter to show the next image.
			// Donīt alter these variables in any way
			imageArray:				[],
			activeImage:			0
		},settings);
		// Caching the jQuery object with all elements matched
		var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
		if(type == 'stock' || type == 'Feedback')
		{
			var ovrlay = '#jquery-overlay'; 
			var jlight = '#jquery-lightbox';
			var lightsecNav = '.lightbox-secNav-btnClose';
			var lightEnt = '#Enter-button';
		}
		else
		{
			var ovrlay = '#jquery-overlay_ad'; 
			var jlight = '#jquery-lightbox-ad';
			var lightsecNav = '#lightbox-secNav-btnClose-ad';
			var lightEnt = '#Enter-button-ad';
		}

		/**
		 * Initializing the plugin calling the start function
		 *
		 * @return boolean false
		 */
		function _initialize() {

			if(type == 'stock')
			{
				productId	=	document.getElementById('stock_product_id'+id).value;
				productName	=	document.getElementById('stock_product_name'+id).value;	
			}
			_start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
			return false; // Avoid the browser following the link
		}
		/**
		 * Start the jQuery lightBox plugin
		 *
		 * @param object objClicked The object (link) whick the user have clicked
		 * @param object jQueryMatchedObj The jQuery object with all elements matched
		 */
		function _start(objClicked,jQueryMatchedObj) {
			// Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'hidden' });
			// Call the function to create the markup structure; style some elements; assign events in some elements.
			_set_interface();
			// Unset total images in imageArray
			settings.imageArray.length = 0;
			// Unset image active information
			settings.activeImage = 0;
			// We have an image set? Or just an image? Letīs see it.
			if ( jQueryMatchedObj.length == 1 ) {
				settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));
			} else {
				// Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references		
				for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
					settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));
				}
			}
			while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
				settings.activeImage++;
			}
			// Call the function that prepares image exibition
			_set_image_to_view();
		}
		function _set_interface() {
			// Apply the HTML markup into body tag

			if(type == 'adult')
			{
				$('body').append('<div id="jquery-overlay_ad"></div><div id="jquery-lightbox-ad"><div id="lightbox-container-image-ad-box-ad"><div id="lightbox-container-image-ad"><img id="lightbox-image-ad"><div style="" id="lightbox-nav-ad"><a href="#" id="lightbox-nav-ad-btnPrev"></a><a href="#" id="lightbox-nav-ad-btnNext"></a></div><div id="lightbox-loading-ad"><div class="search_adult_warn"><h1>Warning: Adult Content.</h1><div class="search_adult_warn_content"><p>This area is not intended to be viewed by minors.</p><p>The content of these pages include material that may be deemed offensive and also includes images of a sexual nature. You may only view these pages if you are 18 years of age or over.</p><p>By entering this area you are confirming that you are 18 years of age or over, you are accepting full responsibility for your actions and releasing chemistdirect.co.uk and its entire staff of any liability.</p></div><span><a href="#" id="lightbox-secNav-btnClose-ad"><img src="images/back_home_btn.gif"/></a> <a href="#" id="Enter-button-ad"><img src="images/enter_btn.gif"/></a></span></div></div></div></div><div id="lightbox-container-image-ad-data-box-ad"><div id="lightbox-container-image-ad-data"><div id="lightbox-image-ad-details"><span id="lightbox-image-ad-details-caption"></span><span id="lightbox-image-ad-details-currentNumber"></span></div></div></div></div>');	
			}
			else if(type == 'stock')
			{
				$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image">	<table width="100%" border="0"  cellpadding="0" cellspacing="0" ><tr><td colspan="2" class="htext" align="left"><input type="hidden" name="hidden_email" id="hidden_email"><table width="100%" border="0"><tr><td  align="left"></td><td width="25%" align="right"><a href="#" class="lightbox-secNav-btnClose" ><img src="jcarousel/lightbox/images/icon_close.gif"></a></td></tr><tr><td id="getContent_light" style="padding-top:10px; padding-bottom:5px; padding-left:5px; padding-right:5px; " colspan="2"><div class="floatl"><img src="jcarousel/lightbox/images/email.gif" align="absmiddle" class="padr10"></div><div ><b>This item is Out of Stock. Please enter your email address below and we\'ll alert you when it becomes available.</b></div></td></tr></table></td></tr><tr><td colspan="2"><div id="hidthank" style="display:"><table width="100%" id="dispemail"><tr><td class="text12 padr5" align="right" valign="middle"><img src="images/tspacer.gif" height="10px" width="5"></td><td align="left" class=""></td></tr><tr><td class="text12 padr5" align="right" valign="middle"><img src="images/tspacer.gif" height="10px" width="5"><b>Email:</b> </td><td align="left"  ><input class="textbox1" type="text" name="user_email" id="user_email" onBlur="javascript: defaultText(this);" onFocus="javascript: clearSearchField(this);" value="Enter Email Address"></td></tr><tr><td></td><td align="left" class="padt15" style="padding-bottom:10px;"><input type="image" src="jcarousel/lightbox/images/submit.gif" name="btn_prod" onClick="return validatefeedback(1);"></td></tr><tr><td colspan="2"></td></tr></table></div><table width="100%" style="display:none;" id="dispthank"><tr><td colspan="3" align="center">&nbsp;</td></tr></table></td></tr></table></table></div></div><div><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"></div></div></div></div>');	
			}
			else if(type == 'Feedback')
			{
				$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image-fd"></div></div><div><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"></div></div></div></div><map name="Maplight" id="Maplight"><area shape="rect" coords="-4,0,30,26" href="#" class="lightbox-secNav-btnClose" /></map>');
				validatefeedback(2);
			}
			// Get page sizes
			var arrPageSizes = ___getPageSize();
			// Style overlay and show it
			$(ovrlay).css({
				backgroundColor:	settings.overlayBgColor,
				opacity:			settings.overlayOpacity,
				width:				arrPageSizes[0],
				height:				arrPageSizes[1]
			}).fadeIn();
			// Get page scroll
			var arrPageScroll = ___getPageScroll();
			// Calculate top and left offset for the jquery-lightbox-ad div object and show it
			var arrScreen = alertSize();
			if(type == 'adult')
			{
				var topCss = (arrScreen[1]/2) - 220;
				var leftCss = arrPageScroll[0];
			}
			else if(type == 'stock')
			{
				var topCss = (arrPageScroll[1]+240);
				var leftCss = arrPageScroll[0]-80;
			}
			else if(type == 'Feedback')
			{
				var topCss = (arrScreen[1]/2) - 180;
				var leftCss = arrPageScroll[0] - 150;
			}

			$(jlight).css({
				top:	topCss,
				left:	leftCss

			}).show();
			// Assigning click events in elements to close overlay - remove below to not allow click
			// Assign the _finish function to lightbox-loading-ad-link and lightbox-secNav-btnClose-ad objects
			$(lightsecNav).click(function() {
				_finish();
				if(type == 'adult')
				{
					window.location=backpageurl;
				}
				return false;
			});
			$(lightEnt).click(function() {
				_finish();
				UpdateAge();
				
			});
			// If window was resized, calculate the new overlay dimensions
			$(window).resize(function() {
				// Get page sizes
				var arrPageSizes = ___getPageSize();
				// Style overlay and show it
				$(ovrlay).css({
					width:		arrPageSizes[0],
					height:		arrPageSizes[1]
				});
				// Get page scroll
				var arrPageScroll = ___getPageScroll();
				// Calculate top and left offset for the jquery-lightbox-ad div object and show it
				$(jlight).css({
					top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
					left:	arrPageScroll[0]
				});
			});
		}
		/**
		 * Prepares image exibition; doing a imageīs preloader to calculate itīs size
		 *
		 */
		function _set_image_to_view() { // show the loading
			// Show the loading
			$('#lightbox-loading-ad').show();
			if ( settings.fixedNavigation ) {
				$('#lightbox-image-ad,#lightbox-container-image-ad-data-box-ad,#lightbox-image-ad-details-currentNumber').hide();
			} else {
				// Hide some elements
				$('#lightbox-image-ad,#lightbox-nav-ad,#lightbox-nav-ad-btnPrev,#lightbox-nav-ad-btnNext,#lightbox-container-image-ad-data-box-ad,#lightbox-image-ad-details-currentNumber').hide();
			}
			// Image preload process
			var objImagePreloader = new Image();
			objImagePreloader.onload = function() {
				$('#lightbox-image-ad').attr('src',settings.imageArray[settings.activeImage][0]);
				// Perfomance an effect in the image container resizing it
				_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
				//	clear onLoad, IE behaves irratically with animated gifs otherwise
				objImagePreloader.onload=function(){};
			};
			objImagePreloader.src = settings.imageArray[settings.activeImage][0];
		};
		/**
		 * Remove jQuery lightBox plugin HTML markup
		 *
		 */
		function _finish() {
			$(jlight).remove();
			$(ovrlay).fadeOut(function() { $(ovrlay).remove(); });
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'visible' });
		}
		/**
		 / THIRD FUNCTION
		 * getPageSize() by quirksmode.com
		 *
		 * @return Array Return an array with page width, height and window width, height
		 */
		function ___getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};
		/**
		 / THIRD FUNCTION
		 * getPageScroll() by quirksmode.com
		 *
		 * @return Array Return an array with x,y page scroll values.
		 */
		function ___getPageScroll() {
			var xScroll, yScroll;
			if (self.pageYOffset) {
				yScroll = self.pageYOffset;
				xScroll = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
				yScroll = document.documentElement.scrollTop;
				xScroll = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				yScroll = document.body.scrollTop;
				xScroll = document.body.scrollLeft;	
			}
			arrayPageScroll = new Array(xScroll,yScroll);
			return arrayPageScroll;
		};
		 /**
		  * Stop the code execution from a escified time in milisecond
		  *
		  */
		 function ___pause(ms) {
			var date = new Date(); 
			curDate = null;
			do { var curDate = new Date(); }
			while ( curDate - date < ms);
		 };
		// Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
		return this.unbind('click').click(_initialize);
	};
})(jQuery); // Call and execute the function immediately passing the jQuery object


jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


function UpdateAge()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  //document.myForm.time.value=xmlhttp.responseText;
  }
}
xmlhttp.open("GET","update_adult_session.php",true);
xmlhttp.send(null);
}
