// check Query string variables
var qstr = "";
var success =0;
var error =0;
var code="";
var qstr = window.location.search.substring(0);
var qstrJSON = window.location.search.substring(1);
//alert(qstr);
if (qstrJSON.length > 0) 
	{ 
		var pairs = qstrJSON.split('&'); 
								 
		for(var i = 0; i < pairs.length; i++) 
		{ 
			var pairs2 = pairs[i].split('='); 
			 
			switch(pairs2[0].toLowerCase()) 
			{ 
				case 'success': 
					success = pairs2[1]; 
					break; 
				case 'error': 
					error = pairs2[1]; 
					break; 
				case 'code': 
					code = pairs2[1]; 
					break; 
			} 
		} //end for 
	}//end if 
//alert(success+'---'+error);

// Create Browser compatible XMLHTTP Object
//var remoteURL = 'http://localhost/dapplebaby/';
//var remoteURL = 'http://suthapa/dapplebaby/';
var remoteURL = 'http://secure-ecommerce-services.com/storeservices/dapplebaby/';

var _http;
var _gShow="";
function _getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {

      try {

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (E) {

        xmlhttp = false;

      }

    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

// Global _http object
_http = _getHTTPObject(); 


function check_url(sUrl,content,DIV){ //  Check whether value is exist.
	if(sUrl==""){
		alert("Please enter value!");		
	}
	else{
		_http.open("POST", sUrl , true);
		_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
		_http.send(content);
		_http.onreadystatechange = function(){
			if (_http.readyState == 4) {
				if(document.getElementById(DIV)){
					document.getElementById(DIV).innerHTML =  _http.responseText;
				}
			}
		}
		return true;
	}
}


function GetDay(iDay) {
	var DayArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") ;
	return DayArray[iDay] ;
}

function GetMonth(iMonth) {
	var arMonth = new Array("January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December") ;
	return arMonth[iMonth] ;
}

function GetYear(year) {
	if (year < 2000) {
		year = year + 1900;
	}
	return year;
}

function getDateStrWithDOW() {
	var today = new Date() ;
	var mon = GetMonth(today.getMonth()) ;
	var day = GetDay(today.getDay()) ;
	var year = GetYear(today.getYear()) ;
	var hours = today.getHours() ;
	return ('<font color=\"#ffffff\">' + day + ', ' + mon + ' ' + today.getDate() + ', ' + year + '</font>') ;
}

function checkEmail()
	{
	var strEmail, strError, countAtRate, countDot, i;
	var checkAtRate, checkDot;
	var ValidChars,CountValidChars;
	ValidChars="abcdefghijklmnopqrstuvwxyz0123456789_.@ABCDEFGHIJKLMNOPQRSTUVWXYZ-";
	strEmail = checkEmail.arguments[0];

	countAtRate=0;
	countDot=0;
	CountValidChars=0;
	if (strEmail.length >= 7)
		{
		for(i=0;i<strEmail.length;i++)
			{
			if(strEmail.charAt(i)=="@")
				countAtRate++;
			if(strEmail.charAt(i)==".")
				countDot++;
			CountValidChars=0;
			for(j=0;j<ValidChars.length;j++)
				{
				if(strEmail.charAt(i)==ValidChars.charAt(j))
					{
					CountValidChars++;
					}
				}
			if(CountValidChars==0)
				{
				strError=0;
				break;
				}
			}
		}
	checkAtRate=strEmail.indexOf("@",1);
	checkDot=strEmail.indexOf(".",1);
	for(i=1;i<countDot;i++)
		checkDot=strEmail.indexOf(".",checkDot+1);
	if(countAtRate==1 && countDot > 0 && strEmail.length >=7 && strError != 0)
		strError=1;
	else
		strError=0;
	if(checkDot>=strEmail.length-2)
		strError=0;
	if(strEmail.charAt(0)=="@" || strEmail.charAt(strEmail.length-1)=="@")
		strError=0;
	if(strEmail.charAt(0)=="." || strEmail.charAt(strEmail.length-1)==".")
		strError=0;
	if(checkDot < checkAtRate)
		strError=0;

	return strError;
}

function set_Attribute(txtField,attr,val){
	var box = document.getElementById(txtField);
	box.setAttribute(attr,val);
}

function form_focus(dm,txtField,txtValue){
	var field = eval("dm."+txtField);
	if(field.value==txtValue){
		field.value = "";
		/*
		if(txtField=="txtareacode" || txtField=="txtphone3digits" || txtField=="txtareacode1" || txtField=="txtphone3digits1"){
      			setMaxLength(txtField, 3);
      		}
		if(txtField=="txtphone4digits" || txtField=="txtphone4digits1"){
      			setMaxLength(txtField, 4);
      		}
      		*/
	}
}

function form_focus_out(dm,txtField,txtValue){
	var field = eval("dm."+txtField);
	if(field.value==""){
	
		/*
		if(txtField=="txtareacode" || txtField=="txtphone3digits" || txtField=="txtphone4digits" || txtField=="txtareacode1" || txtField=="txtphone3digits1" || txtField=="txtphone4digits1"){
      			setMaxLength(txtField, 9);
      		}
      		*/
		field.value = txtValue;
	}	
}

function isBlank(C) {
	for (i=0;i<C.length;i++) {if (C.charAt(i) != " ") return false}
	return true;
}

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;
} //End Function


function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

function emailValidator(elem){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		return false;
	}
}


function showImage(t){
	var stxt = "";
	
	stxt += "<html><head><title>Image viewer</title></head><body>";
	stxt += "<table border=0 cellpadding=0 cellspacing=0><tr><td align=center><br><font size=2 face=arial><b>Image Viewer</b></td></tr>";
	stxt += "<tr><td><br>";
	stxt += "<img src='"+ t +"'>";
	stxt += "</td></tr><tr><td align=center><br><a href=javascript:window.close();><font size=2 face=arial color=blue>Close Window</font></a></td></tr></table>";
	
	var win = window.open("","","width=625,height=625,resizable=yes,scrollbars=yes")
	win.document.write(stxt);
	
}

function aLoctionHref(pg) {
	window.location.href = pg;
}

function SubmitThisPage(dm,pg){
	dm.method = "Post";
	dm.action = pg;
	dm.submit();
}

function IsNumeric(strString)
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
   if (strString.length == 0) return false;
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
	  {
	  strChar = strString.charAt(i);
	  if (strValidChars.indexOf(strChar) == -1)
		 {
		 blnResult = false;
		 }
	  }
   return blnResult;
}

function clearDefault(el,val,mod) {
	if(mod=='focus'){
		if (el.defaultValue==el.value) el.value = ""
		el.focus();
	}
	else if(mod=='blur')
		if(el.value=="") el.value = val;
}


String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function checkRequestPswForm(dm){
	var err = "Please enter the following information correctly<br>";
	
	if(dm.txtEmail.value.trim()==""){
		err += '- Email Address (Required)<br>';
	}else	if(!echeck(dm.txtEmail.value)){	
			err += '- Email Address (Invalid format)<br>';
		}
	
	if(err=="Please enter the following information correctly<br>"){	// && document.getElementById('usr_err_msg').innerHTML==""
		document.getElementById('usr_err_msg_6').style.display = 'none';
		return true;
	}else{
		document.getElementById('usr_err_msg_6').style.display = 'block';
		document.getElementById('usr_err_msg_6').innerHTML = err+'<br>';
		return false;
	}
}

function checkResetPswForm(dm){
	var err = "Please enter the following information correctly<br>";
	
	if(dm.txtEmail.value.trim()==""){
		err += '- Email Address (Required)<br>';
	}else	if(!echeck(dm.txtEmail.value)){	
			err += '- Email Address (Invalid format)<br>';
		}
	if(dm.txtPassword.value.trim()==""){
		err += '- Password (Required)<br>';
	}
	if(dm.txtPasswordConfirm.value.trim()==""){
		err += '- Confirm Password (Required)<br>';
	}
	
	if(err=="Please enter the following information correctly<br>"){	// && document.getElementById('usr_err_msg').innerHTML==""
		document.getElementById('usr_err_msg_7').style.display = 'none';
		return true;
	}else{
		document.getElementById('usr_err_msg_7').style.display = 'block';
		document.getElementById('usr_err_msg_7').innerHTML = err+'<br>';
		return false;
	}
}

function checkAddShoutForm(dm){
	var err = "Please enter the following information correctly<br>";
	
	if(dm.txtEmail.value.trim()==""){
		err += '- Email Address (Required)<br>';
	}
	if(dm.txtPassword.value.trim()==""){
		err += '- Password (Required)<br>';
	}
	else
		if(dm.txtEmailToggle3.value.trim()!=""){
			err += '- Email Address (Not Authenicated)<br>';
		}
	if(dm.txtShouts.value.trim()==""){
		err += '- Shouts (Required)<br>';
	}
	shoutsVal = dm.txtShouts.value.trim();
	if(shoutsVal.length > 250){
		err += '- Shouts (Max 250 chars is allowed)<br>';
	}
	if(dm.security_code.value.trim()==""){
		err += '- Security Code (Required)<br>';
	}
	
	if(err=="Please enter the following information correctly<br>"){	// && document.getElementById('usr_err_msg').innerHTML==""
		document.getElementById('usr_err_msg_3').style.display = 'none';
		return true;
	}else{
		document.getElementById('usr_err_msg_3').style.display = 'block';
		document.getElementById('usr_err_msg_3').innerHTML = err+'<br>';
		return false;
	}
}

function checkAddMemberForm(dm, mode){
	var err = "Please enter the following information correctly<br>";

	if(dm.txtFirstName.value.trim()==""){
		err += '- Display name (Required)<br>';
	}
	if(dm.txtEmail.value.trim()==""){
		err += '- Email Address (Required)<br>';
	}else{
		if(!echeck(dm.txtEmail.value)){	
			err += '- Email Address (Invalid format)<br>';
		}else
		if(mode=="add")
			if(dm.txtEmailToggle1 && dm.txtEmailToggle1.value.trim()!=""){
				err += '- Email Address (Not Unique)<br>';
			}
		else
			if(dm.txtEmailToggle2 && dm.txtEmailToggle2.value.trim()!=""){
				err += '- Email Address (Not Unique)<br>';
			}
	}
	if(mode=="add"){
		if(dm.txtPassword.value.trim()==""){
		err += '- Password (Required)<br>';
		}
		if(dm.txtPasswordConfirm.value.trim()==""){
			err += '- Confirm Password (Required)<br>';
		}
		if(dm.txtPassword.value.trim()!="" && dm.txtPasswordConfirm.value.trim()!=""){
			if(dm.txtPassword.value.trim()!=dm.txtPasswordConfirm.value.trim()){	
				err += '- Confirm Password (Please do Confirm)<br>';
			}
		}
	}
	if(mode=="edit"){
		if(dm.txtPasswordCurrent.value.trim()==""){
			err += '- Current Password (Required)<br>';
		}
		/*if(dm.txtPassword.value.trim()==""){
			err += '- New Password (Required)<br>';
		}*/
		if(dm.txtPassword.value.trim()!=""){
			if(dm.txtPasswordConfirm.value.trim()==""){
				err += '- Confirm New Password (Required)<br>';
			}
			if(dm.txtPassword.value.trim()!="" && dm.txtPasswordConfirm.value.trim()!=""){
				if(dm.txtPassword.value.trim()!=dm.txtPasswordConfirm.value.trim()){	
					err += '- Confirm New Password (Please do Confirm)<br>';
				}
			}
		}
	}
	
	if(err=="Please enter the following information correctly<br>"){
		//checkUserValidity(mode, dm, dm.txtFirstName.value.trim(), dm.txtLastName.value.trim(), dm.txtPassword.value.trim());
		checkUserValidityJSON(mode, dm, dm.txtEmail.value.trim(), dm.txtPassword.value.trim());
	}
		
	if(err=="Please enter the following information correctly<br>"){	// && document.getElementById('usr_err_msg').innerHTML==""
		document.getElementById('usr_err_msg_1').style.display = 'none';
		document.getElementById('usr_err_msg_2').style.display = 'none';
		return true;
	}else{
		if(mode=="add"){
			document.getElementById('usr_err_msg_1').style.display = 'block';
			//document.getElementById('usr_err_msg_1').innerHTML = '<div class="error">'+err+'<br></div>';
			document.getElementById('usr_err_msg_1').innerHTML = err+'<br>';
		}else{
			document.getElementById('usr_err_msg_2').style.display = 'block';
			document.getElementById('usr_err_msg_2').innerHTML = err+'<br>';
		}
		return false;
	}
}

function checkAddInvitationsForm(dm, mode){
	var err = "Please enter the following information correctly<br>";

	if(dm.txtFirstName.value.trim()==""){
		err += '- First name (Required)<br>';
	}
	if(dm.txtLastName.value.trim()==""){
		err += '- Last name (Required)<br>';
	}
	if(dm.txtEmail.value.trim()==""){
		err += '- Email Address (Required)<br>';
	}else{
		if(!echeck(dm.txtEmail.value)){	
			err += '- Email Address (Invalid format)<br>';
		}
	if(dm.txtCMEmailToggle2.value.trim()!=""){
		err += '- Email (Already a member)<br>';
	}
		/*else
		if(mode=="add")
			if(dm.txtEmailToggle1.value.trim()!=""){
				err += '- Email Address (Not Unique)<br>';
			}
		else
			if(dm.txtEmailToggle2.value.trim()!=""){
				err += '- Email Address (Not Unique)<br>';
			}*/
	}
	if(dm.txtPassword.value.trim()==""){
		err += '- Password (Required)<br>';
	}else
		if(dm.txtPassword.value.length<6){
			err += '- Password (Min 6 chars accepted)<br>';
		}
	if(dm.txtConfirmPassword.value.trim()==""){
		err += '- Confirm Password (Required)<br>';
	}
	if(dm.txtPassword.value.trim()!="" && dm.txtConfirmPassword.value.trim()!="")
		if(dm.txtPassword.value.trim() != dm.txtConfirmPassword.value.trim()){
			err += '- Confirm Password (Not matching)<br>';
		}
	/*if(dm.txtCompany.value.trim()==""){
		err += '- Company (Required)<br>';
	}
	if(dm.txtPhone.value.trim()==""){
		err += '- Phone (Required)<br>';
	}
	if(dm.txtTitle.value.trim()==""){
		err += '- Title (Required)<br>';
	}*/
	if(dm.txtReason.value.trim()==""){
		err += '- Reason (Required)<br>';
	}
	if(dm.security_code_2.value.trim()==""){
		err += '- Security Code (Required)<br>';
	}
	
	/*if(err=="Please enter the following information correctly<br>"){
		//checkUserValidity(mode, dm, dm.txtFirstName.value.trim(), dm.txtLastName.value.trim(), dm.txtPassword.value.trim());
		checkUserValidity(mode, dm, dm.txtEmail.value.trim(), dm.txtPassword.value.trim());
	}*/
		
	if(err=="Please enter the following information correctly<br>"){	// && document.getElementById('usr_err_msg').innerHTML==""
		document.getElementById('usr_err_msg_4').style.display = 'none';
		return true;
	}else{
		if(mode=="add"){
			document.getElementById('usr_err_msg_4').style.display = 'block';
			//document.getElementById('usr_err_msg_1').innerHTML = '<div class="error">'+err+'<br></div>';
			document.getElementById('usr_err_msg_4').innerHTML = err+'<br>';
		}else{
			document.getElementById('usr_err_msg_5').style.display = 'block';
			document.getElementById('usr_err_msg_5').innerHTML = err+'<br>';
		}
		return false;
	}
}

function checkAddInvitationsFormRight(dm, mode){
	var err = "Please enter the following information correctly<br>";

	if(dm.txtFirstName.value.trim()==""){
		err += '- First name (Required)<br>';
	}
	if(dm.txtLastName.value.trim()==""){
		err += '- Last name (Required)<br>';
	}
	if(dm.txtEmail.value.trim()==""){
		err += '- Email Address (Required)<br>';
	}else{
		if(!echeck(dm.txtEmail.value)){	
			err += '- Email Address (Invalid format)<br>';
		}
	if(dm.txtCMEmailToggle1.value.trim()!=""){
		err += '- Email (Already a member)<br>';
	}
		/*else
		if(mode=="add")
			if(dm.txtEmailToggle1.value.trim()!=""){
				err += '- Email Address (Not Unique)<br>';
			}
		else
			if(dm.txtEmailToggle2.value.trim()!=""){
				err += '- Email Address (Not Unique)<br>';
			}*/
	}
	if(dm.txtPassword.value.trim()==""){
		err += '- Password (Required)<br>';
	}else
		if(dm.txtPassword.value.length<6){
			err += '- Password (Min 6 chars accepted)<br>';
		}
	if(dm.txtConfirmPassword.value.trim()==""){
		err += '- Confirm Password (Required)<br>';
	}
	if(dm.txtPassword.value.trim()!="" && dm.txtConfirmPassword.value.trim()!="")
		if(dm.txtPassword.value.trim() != dm.txtConfirmPassword.value.trim()){
			err += '- Confirm Password (Not matching)<br>';
		}
	/*if(dm.txtCompany.value.trim()==""){
		err += '- Company (Required)<br>';
	}
	if(dm.txtPhone.value.trim()==""){
		err += '- Phone (Required)<br>';
	}
	if(dm.txtTitle.value.trim()==""){
		err += '- Title (Required)<br>';
	}*/
	if(dm.txtReason.value.trim()==""){
		err += '- Reason (Required)<br>';
	}
	if(dm.security_code_2.value.trim()==""){
		err += '- Security Code (Required)<br>';
	}
	
	/*if(err=="Please enter the following information correctly<br>"){
		//checkUserValidity(mode, dm, dm.txtFirstName.value.trim(), dm.txtLastName.value.trim(), dm.txtPassword.value.trim());
		checkUserValidity(mode, dm, dm.txtEmail.value.trim(), dm.txtPassword.value.trim());
	}*/
		
	if(err=="Please enter the following information correctly<br>"){	// && document.getElementById('usr_err_msg').innerHTML==""
		document.getElementById('usr_err_msg_5').style.display = 'none';
		return true;
	}else{
		if(mode=="add"){
			document.getElementById('usr_err_msg_5').style.display = 'block';
			//document.getElementById('usr_err_msg_1').innerHTML = '<div class="error">'+err+'<br></div>';
			document.getElementById('usr_err_msg_5').innerHTML = err+'<br>';
		}else{
			document.getElementById('usr_err_msg_6').style.display = 'block';
			document.getElementById('usr_err_msg_6').innerHTML = err+'<br>';
		}
		return false;
	}
}

function checkEditCommunityMembershipForm(dm, mode){
	var err = "Please enter the following information correctly<br>";

	if(dm.txtFirstName.value.trim()==""){
		err += '- Full name (Required)<br>';
	}
	if(dm.txtLastName.value.trim()==""){
		err += '- Last name (Required)<br>';
	}
	if(dm.txtEmail.value.trim()==""){
		err += '- Email Address (Required)<br>';
	}else{
		if(!echeck(dm.txtEmail.value)){	
			err += '- Email Address (Invalid format)<br>';
		}
		/*else
		if(mode=="add")
			if(dm.txtEmailToggle1.value.trim()!=""){
				err += '- Email Address (Not Unique)<br>';
			}
		else
			if(dm.txtEmailToggle2.value.trim()!=""){
				err += '- Email Address (Not Unique)<br>';
			}*/
	}
	/*if(dm.txtCompany.value.trim()==""){
		err += '- Company (Required)<br>';
	}
	if(dm.txtPhone.value.trim()==""){
		err += '- Phone (Required)<br>';
	}
	if(dm.txtTitle.value.trim()==""){
		err += '- Title (Required)<br>';
	}*/
	if(dm.txtNewPassword.value.trim()!=dm.txtConfirmNewPassword.value.trim()){
		err += '- Confirm New Password<br>';
	}
	
	/*if(err=="Please enter the following information correctly<br>"){
		//checkUserValidity(mode, dm, dm.txtFirstName.value.trim(), dm.txtLastName.value.trim(), dm.txtPassword.value.trim());
		checkUserValidity(mode, dm, dm.txtEmail.value.trim(), dm.txtPassword.value.trim());
	}*/
		
	if(err=="Please enter the following information correctly<br>"){	// && document.getElementById('usr_err_msg').innerHTML==""
		document.getElementById('usr_err_msg_12').style.display = 'none';
		return true;
	}else{
		document.getElementById('usr_err_msg_12').style.display = 'block';
		document.getElementById('usr_err_msg_12').innerHTML = err+'<br>';
		return false;
	}
}

function checkUserValidity(mode, dm, email, psw){
		//var content = "mod="+mode+"&fname="+fname+"&lname="+lname+"&psw="+psw;
		var content = "mod="+mode+"&email="+email+"&psw="+psw;
		page = remoteURL + "validate-member.php";
		
		if(mode=="add")
			div1 = 'usr_err_msg_1';
		else
			div1 = 'usr_err_msg_2';
		check_url(page, content, div1, '');	
}

function checkUserValidityJSON(mode, dm, email, psw){
		
		var content = "mod="+mode+"&email="+email+"&psw="+psw;
		var page = remoteURL + "validate-member-json.php?" + content + "&callback=?";
		
		if(mode=="add")
			div1 = 'usr_err_msg_1';
		else
			div1 = 'usr_err_msg_2';
		
		$.getJSON(page, function(data){
			//alert(data.remoteContent);
			retString = data.remoteContent;
			if(retString!=""){
				document.getElementById(div1).innerHTML =  retString;
			}else{
				document.getElementById(div1).innerHTML = '';
			}
		});
}

function validateCommunityMember(dm){
	var retString = "";
	var email = dm.login_email.value.trim();
	var psw = dm.login_psw.value.trim();		
	var DIV = 'usr_err_msg_11';
					
	if(email==""){
		retString = '- Email Address format is not valid<br>';
	}else if(!echeck(email)){
		retString = '- Email Address format is not valid<br>';
	}
	if(retString!=""){
		if(email!=""){ 
			document.getElementById(DIV).style.display = 'block';
			document.getElementById(DIV).innerHTML = retString;
		}
		return false;
	}else{
		document.getElementById(DIV).innerHTML = '';
		document.getElementById(DIV).style.display = 'none';
	
		//var content = "&fname="+fname+"&lname="+lname+"&psw="+psw;
		var content = "mod=edit&email="+email+"&psw="+psw;
		var page = remoteURL + "validate-community-member.php";		
		//check_url(page, content, 'usr_err_msg_2', '');
	
		_http.open("POST", page , true);
		_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		_http.send(content);
		_http.onreadystatechange = function(){
			if (_http.readyState == 4) {
					//alert(_http.responseText);
					retString = _http.responseText;
					if(retString!=""){
						document.getElementById(DIV).style.display = 'block';
						document.getElementById(DIV).innerHTML = retString;
						//dm.txtEmailToggle3.value = retString;
						document.getElementById('ecfBox_12').style.display = 'none';
						return false;
					}else{
						document.getElementById(DIV).innerHTML = '';
						document.getElementById(DIV).style.display = 'none';
						//dm.txtEmailToggle3.value = '';
						//document.getElementById('ecfBox_11').style.display = 'none';
						//document.getElementById('ecfBox_12').style.display = 'block';
						dm.submit();
						return true;
					}
			}
		}//alert(retString);
		/*if(retString!=""){
			return true;
		}else {
			return false;
		}*/
		return false;
	}
}

function validateCMemberForgotPsw(dm){
	var retString = "";
	var email = dm.login_email.value.trim();
	var DIV = 'usr_err_msg_11_2';
					
	if(email==""){
		retString = '- Email format is not valid<br>';
	}else if(!echeck(email)){
		retString = '- Email format is not valid<br>';
	}
	if(retString!=""){
		document.getElementById(DIV).style.display = 'block';
		document.getElementById(DIV).innerHTML = retString;
		return false;
	}else {
		return true;
	}
}

function validateShouter(dm){
		var retString = "";
		var email = dm.txtEmail.value.trim();
		var psw = dm.txtPassword.value.trim();		
		var DIV = 'usr_err_msg_3';
						
		if(email==""){
			retString = '- Email Address format is not valid<br>';
		}else
			if(!echeck(email)){
				retString = '- Email Address format is not valid<br>';
			}
		if(retString!=""){
			document.getElementById(DIV).style.display = 'block';
			document.getElementById(DIV).innerHTML = retString;
			return false;
		}else{
			document.getElementById(DIV).innerHTML = '';
			document.getElementById(DIV).style.display = 'none';
		
			//var content = "&fname="+fname+"&lname="+lname+"&psw="+psw;
			var content = "mod=edit&email="+email+"&psw="+psw;
			var page = remoteURL + "validate-shouter.php";		
			//check_url(page, content, 'usr_err_msg_2', '');
		
			_http.open("POST", page , true);
			_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			_http.send(content);
			_http.onreadystatechange = function(){
				if (_http.readyState == 4) {
						//alert(_http.responseText);
						retString = _http.responseText;
						if(retString!=""){
							document.getElementById(DIV).style.display = 'block';
							document.getElementById(DIV).innerHTML = retString;
							dm.txtEmailToggle3.value = retString;
						}else{
							document.getElementById(DIV).innerHTML = '';
							document.getElementById(DIV).style.display = 'none';
							dm.txtEmailToggle3.value = '';
						}
				}
			}
			return true;
		}
}

function validateShouterJSON(dm){
		var retString = "";
		var email = dm.txtEmail.value.trim();
		var psw = dm.txtPassword.value.trim();		
		var DIV = 'usr_err_msg_3';
						
		if(email==""){
			retString = '- Email Address format is not valid<br>';
		}else
			if(!echeck(email)){
				retString = '- Email Address format is not valid<br>';
			}
		if(retString!=""){
			document.getElementById(DIV).style.display = 'block';
			document.getElementById(DIV).innerHTML = retString;
			return false;
		}else{
			document.getElementById(DIV).innerHTML = '';
			document.getElementById(DIV).style.display = 'none';
		
			var content = "mod=edit&email="+email+"&psw="+psw;
			var page = remoteURL + "validate-shouter-json.php?" + content + "&callback=?";		
			//check_url(page, content, 'usr_err_msg_2', '');
			
			$.getJSON(page, function(data){
				//alert(data.remoteContent);
				retString = data.remoteContent;
				if(retString!=""){
					document.getElementById(DIV).style.display = 'block';
					document.getElementById(DIV).innerHTML = retString;
					dm.txtEmailToggle3.value = retString;
				}else{
					document.getElementById(DIV).innerHTML = '';
					document.getElementById(DIV).style.display = 'none';
					dm.txtEmailToggle3.value = '';
				}
			});
		
			return true;
		}
}

function checkUserUnique(dm,mode){
		var retString = "";
		var email = dm.txtEmail.value.trim();
		if(mode=="add")
			DIV = 'usr_err_msg_1';
		else
			DIV = 'usr_err_msg_2';
						
		if(email==""){
			retString = '- Email Address format is not valid<br>';
		}else
			if(!echeck(email)){	
				retString = '- Email Address format is not valid<br>';
			}
		if(retString!=""){
			document.getElementById(DIV).style.display = 'block';
			document.getElementById(DIV).innerHTML = retString;
			return false;
		}else{ 
			document.getElementById(DIV).innerHTML = '';
			document.getElementById(DIV).style.display = 'none';
		
			//var content = "&fname="+fname+"&lname="+lname+"&psw="+psw;
			var content = "mod="+mode+"&email="+email;
			var page = remoteURL + "unique-member.php";		
			//check_url(page, content, 'usr_err_msg_2', '');
		
			_http.open("POST", page , true);
			_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
			_http.send(content);
			_http.onreadystatechange = function(){
			if (_http.readyState == 4) {
					//alert(_http.responseText);
					retString = _http.responseText;
					if(retString!=""){
						document.getElementById(DIV).style.display = 'block';
						document.getElementById(DIV).innerHTML = retString;
						if(mode=="add")
							dm.txtEmailToggle1.value = retString;
						else
							dm.txtEmailToggle2.value = retString;
					}else{
						document.getElementById(DIV).innerHTML = '';
						document.getElementById(DIV).style.display = 'none';
						if(mode=="add")
							dm.txtEmailToggle1.value = '';
						else
							dm.txtEmailToggle2.value = '';
					}
				}
			}
			return true;
		}
}

function checkUserUniqueJSON(dm,mode){
		var retString = "";
		var email = dm.txtEmail.value.trim();
		if(mode=="add")
			DIV = 'usr_err_msg_1';
		else
			DIV = 'usr_err_msg_2';
						
		if(email==""){
			retString = '- Email Address format is not valid<br>';
		}else
			if(!echeck(email)){	
				retString = '- Email Address format is not valid<br>';
			}
		if(retString!=""){
			document.getElementById(DIV).style.display = 'block';
			document.getElementById(DIV).innerHTML = retString;
			return false;
		}else{ 
			document.getElementById(DIV).innerHTML = '';
			document.getElementById(DIV).style.display = 'none';
			
			var content = "mod="+mode+"&email="+email;
			var page = remoteURL + "unique-member-json.php?" + content + "&callback=?";
			
			$.getJSON(page, function(data){
				//alert(data.remoteContent);
				retString = data.remoteContent;
				if(retString!=""){
					document.getElementById(DIV).style.display = 'block';
					document.getElementById(DIV).innerHTML = retString;
					if(mode=="add")
						dm.txtEmailToggle1.value = retString;
					else
						dm.txtEmailToggle2.value = retString;
				}else{
					document.getElementById(DIV).innerHTML = '';
					document.getElementById(DIV).style.display = 'none';
					if(mode=="add")
						dm.txtEmailToggle1.value = '';
					else
						dm.txtEmailToggle2.value = '';
				}
			});
			
			return true;
		}
}

function checkCMemberUnique(dm,mode){
		var retString = "";
		var email = dm.txtEmail.value.trim();
		if(dm.name=="frmReqInvRight")
			DIV = 'usr_err_msg_5a';
		else
			DIV = 'usr_err_msg_4a';
						
		if(email==""){
			retString = '- Email Address format is not valid<br>';
		}else
			if(!echeck(email)){	
				retString = '- Email Address format is not valid<br>';
			}
		if(retString!=""){
			document.getElementById(DIV).style.display = 'block';
			document.getElementById(DIV).innerHTML = retString;
			return false;
		}else{ 
			document.getElementById(DIV).innerHTML = '';
			document.getElementById(DIV).style.display = 'none';
		
			//var content = "&fname="+fname+"&lname="+lname+"&psw="+psw;
			var content = "mod="+mode+"&email="+email;
			var page = remoteURL + "validate-community-member.php";		
			//check_url(page, content, 'usr_err_msg_2', '');
		
			_http.open("POST", page , true);
			_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
			_http.send(content);
			_http.onreadystatechange = function(){
			if (_http.readyState == 4) {
					//alert(_http.responseText);
					retString = _http.responseText;
					if(retString!=""){
						document.getElementById(DIV).style.display = 'block';
						document.getElementById(DIV).innerHTML = retString;
						//alert(dm.name);
						if(dm.name=="frmReqInvRight")
							dm.txtCMEmailToggle1.value = retString;
						else
							dm.txtCMEmailToggle2.value = retString;
					}else{
						document.getElementById(DIV).innerHTML = '';
						document.getElementById(DIV).style.display = 'none';
						if(dm.name=="frmReqInvRight")
							dm.txtCMEmailToggle1.value = '';
						else
							dm.txtCMEmailToggle2.value = '';
					}
				}
			}
			return true;
		}
}

function populateMemberInfo(dm){
	//var fname = dm.txtFirstName.value.trim();
	//var lname = dm.txtLastName.value.trim();
	var email = dm.txtEmail.value.trim();
	var psw 	= dm.txtPasswordCurrent.value.trim();
	var stringList = "";
	
	//var content = "&fname="+fname+"&lname="+lname+"&psw="+psw;
	var content = "&email="+email+"&psw="+psw;
	var page = remoteURL + "populate-member.php";
	var DIV = 'usr_err_msg_2';
	//check_url(page, content, 'usr_err_msg_2', '');
	
	_http.open("POST", page , true);
	_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
	_http.send(content);
	_http.onreadystatechange = function(){
		if (_http.readyState == 4) {
			//alert(_http.responseText);
			stringList = _http.responseText;
			if(stringList!=""){
				var listArray = stringList.split("::");
				
				dm.txtTitle.value = listArray[0];
				dm.txtCompany.value = listArray[1];
				dm.txtFirstName.value = listArray[4];
				dm.txtHowHear.value = listArray[5];
				if(listArray[3]!=""){
					document.getElementById('imgDisplay').style.display = 'block';
					//document.getElementById('imgMember').src = 'pics/'+listArray[3];
					document.getElementById('imgMember').src = remoteURL + 'inc/imager.php?upfile=../pics/'+listArray[3]+'&max_width=60&max_height=80';
					//inc/imager.php?upfile=../pics/<?=$rowSouts->Photo?>&max_width=60&max_height=80
				}
				
				document.getElementById(DIV).style.display = 'none';
				document.getElementById(DIV).innerHTML = '';
				dm.txtEmailToggle2.value = '';
			}else{
				retString = "Sorry, member's Email/Password combination is not correct!";
				document.getElementById(DIV).style.display = 'block';
				document.getElementById(DIV).innerHTML = retString;
				dm.txtEmailToggle2.value = retString;
			}
		}
	}
	return true;
}

function populateMemberInfoJSON(dm){
	//var fname = dm.txtFirstName.value.trim();
	//var lname = dm.txtLastName.value.trim();
	var email = dm.txtEmail.value.trim();
	var psw 	= dm.txtPasswordCurrent.value.trim();
	var stringList = "";
	
	var content = "&email="+email+"&psw="+psw;
	var page = remoteURL + "populate-member-json.php?" + content + "&callback=?";
	var DIV = 'usr_err_msg_2';
	
	$.getJSON(page, function(data){
		//$.each(data.remoteContent, function(i,row){
		//alert(data.remoteContent);
		stringList = data.remoteContent;
		if(stringList!=""){
			dm.txtTitle.value = stringList.Title;
			dm.txtCompany.value = stringList.Company;
			dm.txtFirstName.value = stringList.FirstName;
			dm.txtHowHear.value = stringList.HowHear;
			if(stringList.Photo!=""){
				document.getElementById('imgDisplay').style.display = 'block';
				//document.getElementById('imgMember').src = 'pics/'+listArray[3];
				document.getElementById('imgMember').src = remoteURL + 'inc/imager.php?upfile=../pics/' + stringList.Photo + '&max_width=60&max_height=80';
				//inc/imager.php?upfile=../pics/<?=$rowSouts->Photo?>&max_width=60&max_height=80
			}
			
			document.getElementById(DIV).style.display = 'none';
			document.getElementById(DIV).innerHTML = '';
			dm.txtEmailToggle2.value = '';
		}else{
			retString = "Sorry, member's Email/Password combination is not correct!";
			document.getElementById(DIV).style.display = 'block';
			document.getElementById(DIV).innerHTML = retString;
			dm.txtEmailToggle2.value = retString;
		}
		//});
	});
	
	return true;
}

function populateMemberInfoJSON_bak(dm){
	//var fname = dm.txtFirstName.value.trim();
	//var lname = dm.txtLastName.value.trim();
	var email = dm.txtEmail.value.trim();
	var psw 	= dm.txtPasswordCurrent.value.trim();
	var stringList = "";
	
	var content = "&email="+email+"&psw="+psw;
	var page = remoteURL + "populate-member-json.php?" + content + "&callback=?";
	var DIV = 'usr_err_msg_2';
	
	$.getJSON(page, function(data){
		//alert(data.remoteContent);
		stringList = data.remoteContent;
		if(stringList!=""){
			var listArray = stringList.split("::");
			
			dm.txtTitle.value = listArray[0];
			dm.txtCompany.value = listArray[1];
			dm.txtFirstName.value = listArray[4];
			dm.txtHowHear.value = listArray[5];
			if(listArray[3]!=""){
				document.getElementById('imgDisplay').style.display = 'block';
				//document.getElementById('imgMember').src = 'pics/'+listArray[3];
				document.getElementById('imgMember').src = remoteURL + 'inc/imager.php?upfile=../pics/'+listArray[3]+'&max_width=60&max_height=80';
				//inc/imager.php?upfile=../pics/<?=$rowSouts->Photo?>&max_width=60&max_height=80
			}
			
			document.getElementById(DIV).style.display = 'none';
			document.getElementById(DIV).innerHTML = '';
			dm.txtEmailToggle2.value = '';
		}else{
			retString = "Sorry, member's Email/Password combination is not correct!";
			document.getElementById(DIV).style.display = 'block';
			document.getElementById(DIV).innerHTML = retString;
			dm.txtEmailToggle2.value = retString;
		}
	});
	
	return true;
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
}


function popup(myform)
{
	if (myform.OILB_EMAIL.value=="") {
		alert("Please enter email address");
		myform.OILB_EMAIL.focus();
		 return false;
	}
	else if (!echeck(myform.OILB_EMAIL.value)) {
		alert("Invalid Email Address");
		myform.OILB_EMAIL.select();
		return false;
	}
	else
	{
		if (! window.focus)return true;
		var d = new Date();

		windowname = d.getTime();
		window.open('thankyou.php', windowname, 'top=100,left=100,height=200,width=200,location=no,resizable=no,scrollbars=no,status=no');
		myform.target=windowname;
		return true;
	}
}


function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

function ShowMe(obj) {
	for(i=1; i<=12; i++){
		if(obj!=("ecfBox_"+i)) {
			if(document.getElementById("ecfBox_"+i)){
				document.getElementById("ecfBox_"+i).style.display = "none";
				document.getElementById("ecfBox_"+i).style.visibility = "hidden";
			}
		}
	}
	
	/*if(obj!="ecfBox_2") {
		document.getElementById("ecfBox_2").style.display = "none";
		document.getElementById("ecfBox_2").style.visibility = "hidden";
	}
	if(obj!="ecfBox_3") {
		document.getElementById("ecfBox_3").style.display = "none";
		document.getElementById("ecfBox_3").style.visibility = "hidden";
	}
	if(obj!="ecfBox_4") {
		document.getElementById("ecfBox_4").style.display = "none";
		document.getElementById("ecfBox_4").style.visibility = "hidden";
	}*/
	
	if(document.getElementById("ecfBox_15")) {
		document.getElementById("ecfBox_15").style.display = "none";
		document.getElementById("ecfBox_15").style.visibility = "hidden";
	}
	document.getElementById(obj).style.display = "block";
	document.getElementById(obj).style.visibility = "visible";
	
}
//if (window.attachEvent) window.attachEvent("onload", sfHover);

function hideMe(obj, parent1) {
	var parent = parent1;	
	if(parent) {
		document.getElementById(parent).style.display = "block";
		document.getElementById(parent).style.visibility = "visible";	
	}
	//sfEls[i].onmouseout=function hideMe(obj) {
	//this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
	document.getElementById(obj).style.display = "none";
	document.getElementById(obj).style.visibility = "hidden";
}

function submit_tell_a_friend() {
	if($('#frm_tell_a_friend').checkValidity() == false) {
		return false;
	}
	return true;
}

function submit_contact_us() {
	if($('#frm_contact_us').checkValidity() == false) {
		return false;
	}
	return true;
}

function submit_suggest_speaker() {
	if($('#frm_suggest_speaker').checkValidity() == false) {
		return false;
	}
	return true;		
}
function submit_hot_seat() {
	if($('#frm_hot_seat').checkValidity() == false) {
		return false;
	}
	return true;		
}

/*** Remote shouts functionaliy related files ***/

function include(file) {
 	if (document.createElement && document.getElementsByTagName) {
	 	//var head = document.getElementsByTagName('head')[0];

	 	//var script = document.createElement('script');
		var script = document.getElementsByTagName('script').item(6);
	 	script.setAttribute('type', 'text/javascript');
	 	script.setAttribute('src', file);

	 	//head.appendChild(script);
 	}
	/*else {
	 	alert('Your browser can\'t deal with the DOM standard. That means it\'s old. Go fix it!');
 	}*/
}

function clientSideInclude2(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id +
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

function clientSideInclude(id, urls, data) {
	/*$.ajax({
   type: "GET",
   url: urls,
	 datatype: "jsonp",
	 success: function(jsonp){
    	$(id).append(jsonp);
   }
 });*/
	$.getJSON(
		urls,
		data,
		function(jsonp){$(id).append(jsonp);}
	);
	/*requestNumber = JSONRequest.get(
    urls, 
    function (requestNumber, value, exception) {
        if (value) {
            processResponse(value);
        } else {
            processError(exception);
        }
    }
	);*/
}

window.onload = function() {
	//initChatStatus();
	//instantiateScroller(0, "scroll0", 8, 0, 258, 215, 100);	
	//include('http://localhost/dapplebaby/shout-box2.php'+qstr);
	//document.getElementsByTagName('script').item(6).src = 'http://localhost/dapplebaby/shout-box2.php';
	//alert(document.getElementsByTagName('script').item(6).src);	
	//if(qstr!="")
		//document.getElementById('ecfBox_15').style.display = 'block';
	
	//clientSideInclude('shoutRemote', 'http://localhost/dapplebaby/shout-box.php'+qstr);
	//clientSideInclude2('shoutRemote', remoteURL + 'shout-box.php' + qstr);	
	//clientSideInclude('#shoutRemote', remoteURL + 'shout-box.php', qstrJSON);	
	/*$.ajax({
			url: "http://localhost/dapplebaby/shout-box.php",
			cache: false,
			success: function(html){
				$("#shoutRemote").append(html);
			}
	
	 });*/
	
	/*$.ajax({
   type: "GET",
   url: "http://localhost/dapplebaby/shout-box.php",
   success: function(html){
    $("#shoutRemote").append(html);
   }
 });*/
	
	if(error>0) {
		center('overlayss','mybox');
		switch(parseInt(error)) {
			case 1:
				ShowMe('ecfBox_7');
				break;
			case 2:
				ShowMe('ecfBox_6');
				break;
			case 3:
				ShowMe('ecfBox_5');
				break;
			case 6:
				ShowMe('ecfBox_10');
				break;
		}
	}
		
	if(success>0) {
		center('overlayss','mybox');
		switch(parseInt(success)) {
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 10:
				ShowMe('ecfBox_15');
				break;
		}
	}
}

function overlay() {
	xyz = document.getElementById("overlay");
	xyz.style.visibility = (xyz.style.visibility == "visible") ? "hidden" : "visible";
}


function hideDiv(oID,frmDiv){
		document.getElementById('overlayss'+oID).style.display='none';
		document.getElementById(frmDiv).style.display='none';
		//document.getElementById(Msgbox).style.display='none';
}

function BrowserInfo()	
{
	if(navigator.userAgent.indexOf("Opera")!=-1){
		return 2;
	}else
		if(navigator.userAgent.indexOf("MSIE")!=-1){
		return 3;
	}else
		if(navigator.userAgent.indexOf("Firefox")!=-1){
		return 19;
		}
}

function getPageSizeWithScroll(){ 
	if (window.innerHeight && window.scrollMaxY) {// Firefox         
		yWithScroll = window.innerHeight + window.scrollMaxY;         
		xWithScroll = window.innerWidth + window.scrollMaxX;     
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac         
		yWithScroll = document.body.scrollHeight;         
		xWithScroll = document.body.scrollWidth;     
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari         
		yWithScroll = document.body.offsetHeight;         
		xWithScroll = document.body.offsetWidth;       
	}     
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);     
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll ); 
	return yWithScroll; 
} 

function center(Divname,Formbox){

//alert(document.getElementById(Divname).screenY);
//alert(onClick.screenY);
var my_width  = 0;
	var my_height = 0;
	var decreaseWidth = 0;
	decreaseWidth = BrowserInfo();
	
	if ( typeof( window.innerWidth ) == 'number' ){
		my_width  = window.innerWidth;
		my_height = window.innerHeight;
	}else if ( document.documentElement && 
			 ( document.documentElement.clientWidth ||
				 document.documentElement.clientHeight ) ){
		my_width  = document.documentElement.clientWidth;
		my_height = document.documentElement.clientHeight;
	}
	else if ( document.body && 
			( document.body.clientWidth || document.body.clientHeight ) ){
		my_width  = document.body.clientWidth;
		my_height = document.body.clientHeight;
	}
	my_new_height = getPageSizeWithScroll();
	//alert(my_width);
	//alert(my_height);
	
	
	document.getElementById(Divname).style.position = 'absolute';
	document.getElementById(Divname).style.zIndex   = 99;
	document.getElementById(Divname).style.display='block';
	
	document.getElementById(Formbox).style.position = 'absolute';
	document.getElementById(Formbox).style.zIndex   = 99;
	document.getElementById(Formbox).style.display='block';
	//document.getElementById(Divname).appendChild(Formbox);
	
	var scrollY = 0;
	
	if ( document.documentElement && document.documentElement.scrollTop ){
		scrollY = document.documentElement.scrollTop;
	}else if ( document.body && document.body.scrollTop ){
		scrollY = document.body.scrollTop;
	}else if ( window.pageYOffset ){
		scrollY = window.pageYOffset;
	}else if ( window.scrollY ){
		scrollY = window.scrollY;
	}
	
	//Divname.style.left =my_width/2+ "px";
	//Divname.style.top  = my_height/2 + "px";
	
	
	var divWidth = document.getElementById(Formbox).offsetWidth;
	var divHeight = document.getElementById(Formbox).offsetHeight;
	
	
	//var elementDimensions = Element.getDimensions(element);
	
	var setX = ( my_width  - divWidth  ) / 2;
	var setY = ( my_height - divHeight ) / 2 +scrollY;
	
	setX = ( setX < 0 ) ? 0 : setX;
	setY = ( setY < 0 ) ? 0 : setY;
	
	//document.getElementById(Divname).style.left = setX + "px";
	//document.getElementById(Divname).style.top  = setY + "px";
	
	document.getElementById(Divname).style.left =0 + "px";
	document.getElementById(Divname).style.top  = 0 + "px";
	//alert(my_height);
	document.getElementById(Divname).style.height= (my_new_height + my_height - 510)+ "px";
	document.getElementById(Divname).style.width= (my_width - decreaseWidth) + "px";
	
	
	document.getElementById(Formbox).style.left = setX + "px";
	document.getElementById(Formbox).style.top  = setY + "px";
	//element.style.left = setX + "px";
	//element.style.top  = setY + "px";*/
}

$(document).ready(function(){
	//instantiateScroller(0, "scroll0", 8, 0, 258, 215, 100);	
	// this initialises the demo scollpanes on the page.
	/*$('#pane1').jScrollPane({showArrows:true});
	reinitialiseScrollPane = function() {
		$('#pane1').jScrollPane();
	}*/
	//alert(2222222);
	//$('#pane1').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
	$.getJSON(remoteURL + "shout-box.php?" + qstrJSON + "&callback=?", function(data){
		//$('#pane1').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
		//alert(data.remoteContent);
		//$("#shoutRemote").empty();
		//alert(33333333);
		$("#shoutRemote").empty().append(data.remoteContent);
		//$("#scroll0Content").empty();
		//$("#scroll0Content").append(data.remoteContent);
		//$('#pane1').load(data.remoteContent, '', reinitialiseScrollPane);
		//$('#pane1').append(data.remoteContent.jScrollPane({scrollbarWidth:20, scrollbarMargin:10});
		//$("#pane1").append(data.remoteContent);
	});
});

function sleep(delay) {
    var start = new Date().getTime();
    while (new Date().getTime() < start + delay);
}

var timeInterval_Status = 5000; // 5 second
var gTimerStatus = null;
var gTimerCountStatus = 0;

var RootFolder = ""

function initChatStatus(root) {
		RootFolder="../"
		if (root=="x")
			RootFolder=""
		startTimerStatus();
	}
	

function myTimerStatus() {
	gTimerCountStatus++;
	//myfile = "salelist_ajax.php";
	//Ajax_ChatStatus("myresults",myfile);
	//instantiateScroller(0, "scroll0", 8, 0, 258, 215, 100);	
}

function startTimerStatus() {
	gTimerStatus = window.setInterval("myTimerStatus()",timeInterval_Status);
}

function stopTimerStatus() {
	window.clearInterval(gTimerStatus);
}

$(function()
{
	// this initialises the demo scollpanes on the page.
	//$('#pane1').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
	//$('#pane1').jScrollPane({showArrows:true});
	/*$('#pane2').jScrollPane({showArrows:true});
	$('#pane3, #pane4').jScrollPane({scrollbarWidth:20, scrollbarMargin:10});
	
	// this allows you to click a link to add content to #pane4 and shows how to 
	// reinitialise the scrollbars when you have done this.
	$('#add-content').bind(
		'click',
		function()
		{
			$('#pane4').append($('<p></p>').html($('#intro').html())).jScrollPane({scrollbarWidth:20, scrollbarMargin:10});
		}
	);
	// and this allows you to click the link to reduce the amount of content in
	// #pane4 and reinitialise the scrollbars.
	$('#remove-content').bind(
		'click',
		function()
		{
			$('#pane4').empty().append($('<p></p>').html($('#intro').html())).jScrollPane({scrollbarWidth:20, scrollbarMargin:10});
		}
	);*/
});

