var catchCries=[
"Shindig - the integrated business application for small businesses",
"do it yourself website, marketing tools, product and ordering...",
"free or 29.95 per month with website or 49.95 with more ",
"do it yourself business web site in four simple steps",
"have a site with shopping, customer registration...",
"your own domain or use the free subdomain to "+document.domain,
"group your customers and create targeted campaigns",
"stay organised with Shindig's reminders, calendar...",
"integrate email with your business data ",
"no setup costs, no maintenance or upgrade fees",
"our mission is to make it easy for anyone to run their business",
"contact us - we are always happy to answer questions",
"signup now for immediate access"]

var salesMessages=[
"hosted business web site with business tools",
"build your own professional web site with product catalog and much more",
"more users and more data storage with Shindig Pro",
"website, marketing and customer support tools integrated with web site",
"access your business applications wherever you are whenever you want"
];

var defaultCry=0;

var thisPage="indexNEW.html";

var httpsPort='8443';

function setThisPage(tpg,cry) {
	
	thisPage=tpg;
	defaultCry=cry;
}

function setSelected(){
var opg=document.getElementById(thisPage);

  if (!opg) {
  	//alert(' cannot find menu option named '+thisPage);
  	return false;
  }	
  
  opg.className="nav_item_selected";
  
  writit('<font class="nav_text">'+thisPage+'</font>',thisPage);
  // change window title
		
	//document.title = getAppName() + " - "+thisPage;
	
}
function pausecomp(millis) 
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); } 
while(curDate-date < millis);
} 



function runMessages(i) {
var le=salesMessages.length;
var callfn='';

   if (i>=le) i=0;
   writit(salesMessages[i],'messages');
   callfn='showMessage("'+salesMessages[i]+'",'+i+')';
  
   setTimeout(callfn,5000);
}

function showMessage(mess,i){	
	  
	runMessages(i+1);
		
}

function setDefaultCry(ind) {
  defaultCry=ind;
}

function showCatchCry(ind){
	showLayer('catchCryDiv');
	writit(catchCries[ind],'catchCryDiv');
	
}
function showDefaultCatchCry(){
	
	//writit(catchCries[defaultCry],'catchCryDiv');
	hideLayer('catchCryDiv');
}
function openLoginPage(sp) {
 //alert(navigator.appName);
 if (sp==null) sp='/shindig/';
 if ((navigator.appName!="Microsoft Internet Explorer")&&(navigator.appName!="Netscape")) {
 
  alert('you need to login using Microsoft Internet Explorer or Firefox');
  return;
 }
 
 else
 {
  var loc=window.location.href;
  var windowparams='width=800,height=640,scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no,copyhistory=no';

  //
  // A little trick for local access
  //
  if ((loc.substring(7,17)=='192.168.1.')||(loc.substring(7,20)=='59.167.253.97')||(loc.substring(7,20)=='150.101.114.108'))
   windowparams='width=800,height=640,scrollbars=yes,resizable=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,copyhistory=no';
 

  var win=window.open(sp+'common/login_page.jsp','Shindig_Application',windowparams);

  if (win) {

  //alert('The application will open in a new window');
   win.focus();
   deleteCookie ("NickCookie");
   //window.document.location.href=sp+'index.html';
  }
  else { 
    alert('It seems like you have popups blocked. To use shindig follow these simple steps:\n1: close this  window by clicking the OK button below\n2:click on the yellow bar and select \'Allow popups from this site...\'\n3:When asked \'Would you like to allow popups from \'*.' + getBrandName() + '\'?\' select Yes\n4:Select Cancel when asked to retry sending information\nFinish: You have now allowed shindig to start in a new window. Click Login again for the window to pop up.');
  }
 }
 
}


function autoLogin() {
 var frm = window.document.forms[0];


 alert('Login in to ' + getAppName() + ' with username john@company.' + getBrandName() + ' and password secret');
 
 //return false;
}

function validate() {
  var frm = window.document.forms[0];
  var dott=0; 
  var IE=1;

  if (navigator.appName!="Microsoft Internet Explorer") {
    IE=0;
    alert (getAppName() + " is optimised to run under Microsoft Internet explorer. You are using " + navigator.appName + ". For best experience we recommend that you access " + getAppName() + " with Microsoft IE. Please login using Microsoft Internet Explorer.");
    return false;
    }

  
  if (frm.nickname.value=="") {
    alert ("Username must not be empty");
    return false;
  }

  if (frm.nickname.value.indexOf('@')<0) 
  {
  	// (RT branding edit) 11-jan-2007
	
    //alert('The login format is username@domain.shindig.com.au\nThe @ is missing');
	alert('The login format is username@domain.' + getBrandName() + '\nThe @ is missing');
    frm.nickname.focus();
    return false;
  }

  if (frm.nickname.value.length<14) {
    dott=frm.nickname.value.indexOf('.');
    if (dott<0) 
		
		// (RT branding edit) 11-jan-2007
		
		//frm.nickname.value=frm.nickname.value+'.shindig.com.au';
		frm.nickname.value=frm.nickname.value+'.'+ getBrandName();
    else {
      frm.nickname.value=frm.nickname.value.substring(0,dott);
	  
	  // (RT branding edit) 11-jan-2007
	  
      //frm.nickname.value=frm.nickname.value+'.shindig.com.au';
	  frm.nickname.value=frm.nickname.value+'.'+ getBrandName();
    }
  }

  if (!check_email(frm.nickname.value)) {
    alert ("e-mail address is not valid");
    return false;
  }

  if (ltrim(frm.pwd_text.value)=="") {
    alert ("Password must not be empty");
    return false;
  }
    
  // This cookie is used for detecting whether or not the client browser
  // accepts session cookies. NickCookie is set in this page and later
  // readed by login_check. If the cookie cannot be readed by login_check
  // (NickCookie!=nickname) then that means that client has disabled cookies

	var dt1Min = new Date();
	dt1Min.setTime(dt1Min.getTime()+60000);	// Give cookie 1 minute lifetime
  setCookie ("NickCookie",frm.nickname.value,dt1Min);

	// Erase previous user id	  
  setCookie ("userid","");
  setCookie ("authstr","");
  
	showLayer('shindigLogin');
  return true;
}


function register(arg)
{
var baseUrl=getBrandName();

  if (baseUrl=='shindig360.com') baseUrl=baseUrl+':'+httpsPort;

	if (arg==null) arg='/shindig/';
	document.location.href='https://www.' + baseUrl + '/shindig/registration/shindig_registration.jsp';
	
	//document.location.href =arg+ "registration/shindig_registration.jsp";
}		

var oldWindowWidth=0;
var imbusy=0;

function resized() {
  moveLayers(layers);
}	  


function goToReggo() {
var baseUrl=document.domain;

if (baseUrl=='www.shindig360.com') baseUrl=baseUrl+':'+httpsPort;

 document.location.href='https://'+baseUrl+'/shindig/registration/shindig_registration.jsp';
 
}