// Amazing Frameless Popup Window - Version I
// (C) 2000 www.CodeLifter.com
// Free for all users, but leave in this  header

// set the popup window width and height

//alert('<%=Session("window_opened")%>')
var windowW=258 // wide
var windowH=493 // high

// set the screen position where the popup should appear

var windowX = 260 // from left
var windowY = 100 // from top

// set the url of the page to show in the popup

var urlPop

// set the title of the page

var title =  "This Is A Frameless Popup Window"

// set this to true if the popup should close
// upon leaving the launching page; else, false

var autoclose = true

// ============================
// do not edit below this line
// ============================

s = "width="+windowW+",height="+windowH+",title=Join Us"
var beIE = document.all?true:false

function openFrameless(page){
 urlPop = page
  if (beIE){
    NFW = window.open(urlPop,"",s)     
    NFW.blur()
    window.focus()       
    NFW.resizeTo(windowW,windowH)
    NFW.moveTo(windowX,windowY)
  } else {
    NFW=window.open(urlPop,"",s)
    NFW.blur()
    window.focus() 
    NFW.resizeTo(windowW,windowH)
    NFW.moveTo(windowX,windowY)
  }   
  NFW.focus()   
  if (autoclose){
    //window.onunload = function(){NFW.close()}
  }
}


function hide_div() 
{
  var argv = hide_div.arguments;
  var argc = argv.length;
  for (var i = 0; i < argc; i++) 
  {
    if (document.getElementById) 
    { // DOM3 = IE5, NS6
     document.getElementById(argv[i]).style.display = 'none';
    }
    else 
    {
     if (document.layers) 
     { // Netscape 4
      document.argv[i].display = 'none';
     }
     else 
     { // IE 4
      document.all.argv[i].style.display = 'none';
     }
    }	  
  }
}

function show_div() 
{
  var argv = show_div.arguments;
  var argc = argv.length;
  for (var i = 0; i < argc; i++) 
  {
    if (document.getElementById) 
    { // DOM3 = IE5, NS6
     document.getElementById(argv[i]).style.display = 'block';
    }
    else 
    {
     if (document.layers) 
     { // Netscape 4
      document.argv[i].display = 'block';
     }
     else 
     { // IE 4
      document.all.argv[i].style.display = 'block';
     }
    }	  
  } 
}


function Validateabn(val,id)
{
 var checkOK = new String("0123456789");
 var strNo = new String(val); 

// alert(strNo)



 var checkStr = val.value; var allValid = true;
 	for (i = 0;  i < checkStr.length;  i++)	
{		
ch = checkStr.charAt(i);		
for (j = 0;  j < checkOK.length;  j++)		
if (ch == checkOK.charAt(j))		
break;		
if (j == checkOK.length)		
{			
allValid = false;	
break;		
}	
}

//alert(allValid)	
if (!allValid)	
{		
//alert("Please enter 9 digits in TFN 1.");	
//document.all['postcode_error'].style.display = 'inline'	

	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else 
	{
		if (document.layers) 
	               { // Netscape 4
			document.id.display = 'block';
	                }
		else 
	               { // IE 4
			document.all.id.style.display = 'block';
	                }
	}


val.focus();error1=true;		
return (false);		
}
else
{
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else 
	{
	    if (document.layers) 
                           { // Netscape 4
			document.id.display = 'none';
		}
	    else 
                           { // IE 4
			document.all.id.style.display = 'none';
		}
	}

}

if ( (val.value.length <  9) || (val.value.length >  9) )	
{		
//alert("Please enter 9 digits in TFN 2.");	
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else 
	{
		if (document.layers) 
	               { // Netscape 4
			document.id.display = 'block';
	                }
		else 
	               { // IE 4
			document.all.id.style.display = 'block';
	                }
	}
val.focus();error1=true;		
return (false);	
}
else
{
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else 
	{
	    if (document.layers) 
                           { // Netscape 4
			document.id.display = 'none';
		}
	    else 
                           { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
error1=false;
return true;
}



function ValidateField(num,val,id,mycountry)
{
 if (val.value != '')
 {
  if (!IsNumeric(val.value)) 
  {
   alert('Please enter a numeric value!')
   val.value = ""
   val.focus()
  }
  else
  {
   if (mycountry.toLowerCase().trim() == 'australia')
    {
     if ((val.value.length > 4) || (val.value.length < 4))
     {
      document.getElementById(id).style.display = 'block';
      alert('Enter 4 digits in postcode')
      val.focus()
      return false;
     } 
     else
      document.getElementById(id).style.display = 'none';     
    } 
    else
     document.getElementById(id).style.display = 'none';   
  }
 }  
}

function CheckRadio(frm, btnName, id)
{
    var error = ""
	var btn = frm[btnName]
	var valid
	
	for (var x = 0;x < btn.length; x++)
	{
		valid = btn[x].checked
		if (valid) {break}
	}

   if (!(valid)) {
        error = "Please select the option'\n";
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.backgroundColor='F99'
	}
	else {
		if (document.layers) { // Netscape 4
			document.getElementById(id).style.backgroundColor='F99'
		}
		else { // IE 4
			document.all.id.style.display = 'block';
			document.getElementById(id).style.backgroundColor='F99'
		}
	}
    }
else
{
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.backgroundColor='white'
	}
	else {
		if (document.layers) { // Netscape 4
			document.getElementById(id).style.backgroundColor='white'
		}
		else { // IE 4
			document.getElementById(id).style.backgroundColor='white'
		}
	}
}
 return error;
}

function checkText(strng1) 
{
var error = "";
strng = strng1.value
if ((strng.trim() == "") || (strng == 'Type here or pick from list below'))
{
 error = 'Please enter a value !'
 strng1.style.backgroundImage = ''
 strng1.style.backgroundColor = 'F99' 
}
else
{
 strng1.style.backgroundColor = 'FEEE73' 
}
return error;    
}

function f1(val,factor)
{
 if(val =='Type here or pick from list below')
 {
   factor.value = ''
  }
} 

function changebackground(myimage,myfield)
{
 if(myfield.value == "")
 {
   myfield.style.backgroundImage = 'url(' + myimage + ')'
 }
}

function retain(val,factor)
{
// alert(val)
// alert(val.length)
 if (val.length == 0)
 {
   factor.value = 'Type here or pick from list below'
 }
} 

function clean(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = ""; }
	else
	{
 	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	//i = parseInt((i + .005) * 100);
	//i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
	}
	return i
}// end of function clean()
/*function clean (w){
    spacing="$               ";
    max_length=12;
	if(!w){
	    alert("missing input after "+ w2.name);         
	    return(0);
	}
	y="0"+w.value;                          //0 to prevent NaN
	yl=y.length;
	for(z=0;z<yl;z++){
		if(y.charAt(z)<"." || y.substring(z,z+1)>"9" || y.substring(z,z+1)=="/"){
			y=(y.substring(0,z) + y.substring(z+1));
			z--;
			yl--;
		}
	}
	y=parseFloat(y);
	x=Math.floor(y);
	xx=y-x;
	xx=xx +"00.00"                 //xx=the cents only (with zeroes).
	a=xx.indexOf(".");
	q=x+xx.substring(a,a+3);

	ql= (q.length < max_length)?(max_length-q.length):0;
	w.value=(y)?spacing.substring(0,ql)+q:"";
	r=parseFloat(q);                            //should be dddd.dd
	w2=w;
	return (r);
}
*/
function tidy(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = ""; }
	else
	{
 	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	//i = parseInt((i + .005) * 10000);
	//i = i / 10000;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
	}
	return i
}
// end of function clean()
/*
function tidy (y){
    max_length=12;                         //max_length= length of text input
    spacing="$               ";
    x=Math.floor(y);
    xx=y-x;
    xx=xx+"00.00"                 //xx=the cents only (with zeroes).
    a=xx.indexOf(".");
    q=x+xx.substring(a,a+4);
	alert(q)    
    ql= (q.length<max_length)?(max_length-q.length):0;   
    r=(y)?spacing.substring(0,ql)+q:"";
    return (r);
}
*/

//display tidys up a number for display: hopefully leaving 2 decimal points

function roundNumber(number,decimal_points) {
	if(!decimal_points) return Math.round(number);
	if(number == 0) {
		var decimals = "";
		for(var i=0;i<decimal_points;i++) decimals += "0";
		return "0."+decimals;
	}

	var exponent = Math.pow(10,decimal_points);
	var num = Math.round((number * exponent)).toString();
	return num.slice(0,-1*decimal_points) + "." + 

num.slice(-1*decimal_points)
}
 String.prototype.trim = function()
 {
  return this.replace(/^\s+/,'').replace(/\s+$/,'');
 } 

function days_between(date1, date2) {

    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24

    // Convert both dates to milliseconds
    var date1_ms = date1.getTime()
    var date2_ms = date2.getTime()

    // Calculate the difference in milliseconds
    var difference_ms = Math.abs(date1_ms - date2_ms)
    
    // Convert back to days and return
    return Math.round(difference_ms/ONE_DAY)

}

function calc_age(day,month,year)
{
// Store the current date and time
var current_date = new Date()

// Store the date of the next New Year's Day
var new_years_date = new Date()
//new_years_date.setYearnew_years_date.getFullYear() + 1)
//new_years_date.setMonth(0)
//new_years_date.setDate(1)

new_years_date.setYear(year)
new_years_date.setMonth(month)
new_years_date.setDate(day)

// Call the days_between function
var days_left = days_between(current_date, new_years_date)

// Write the result to the page
return(days_left/365)
}



var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'name');
	if (window.focus) {newwindow.focus()}
}

function makeUppercase() 
{
 document.form1.outstring.value = document.form1.instring.value.toUpperCase();
}

function Validateamt(arg,nos,amtpaid,amtunpaid,tamtpaid,tamtunpaid)
{
if (nos.value != "")
 if (nos.value != 0) 
 {
  if (amtpaid.value > parseFloat(arg))
  {
   alert('The amount paid per share cannot be greater than value per share !\n The value for this share is $' + parseFloat(arg))
   amtpaid.focus()
   return false;
  }
  else
  {
    amtpaid.value = tidy(amtpaid.value)
    amtunpaid.value =  tidy(parseFloat(arg) -  amtpaid.value)
    tamtpaid.value =  tidy(amtpaid.value * nos.value)
    tamtunpaid.value = tidy(amtunpaid.value * nos.value)
  }
 } 
return true; 
}
 
function ValidateNOS(arg,nos,amtpaid,amtunpaid,tamtpaid,tamtunpaid)
{ 
  if (amtpaid.value != '')
  {
    amtpaid.value = tidy(amtpaid.value)  
    amtunpaid.value =  tidy(parseFloat(arg) -  amtpaid.value)
    tamtpaid.value =  tidy(amtpaid.value * nos.value)
    tamtunpaid.value = tidy(amtunpaid.value * nos.value)
  } 
}

function Validateshares(myform,arg1,arg2,nos)
{
 if(arg1 != '')
 {
   if (isNaN(parseInt(nos.value)))
   {
    nos.value = ''
    arg2 = arg2 - 0
   } 
   else
   {
    arg2 = arg2 + parseInt(nos.value)
   }
 }
 return(arg2)
} 


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function setTab(num)
{

}

function PasteAddress(address1,address2,suburb1,suburb2,state1,state2,postcode1,postcode2,country1,country2,num1,num2)
{
// alert(country1.value)
// alert(country2.value)
 address2.value = address1.value
 suburb2.value = suburb1.value
 state2.value = state1.value
 postcode2.value = postcode1.value
 country2.value = country1.value
// document.getElementById('yourcountryM' + num2).innerHTML = '<input type=text size=21 style="border: 0px solid white; background-color: #FFFFFF; color: #000000;" name = "member"' + num2 + '"_country" value="' + country1.value + '" readonly>'
}

function clearDefault(el) {
  if ('Type here or pick from list below'==el.value) el.value = ""
}
function toUpper(obj) {
var mystring = obj.value;
var sp = mystring.split(' ');
var wl=0;
var f ,r;
var word = new Array();
for (i = 0 ; i < sp.length ; i ++ ) {
f = sp[i].substring(0,1).toUpperCase();
r = sp[i].substring(1).toLowerCase();
word[i] = f+r;
}
newstring = word.join(' ');
obj.value = newstring;
return true;   
}

function setTitle(mytextfield,mydiv,text,mylength)
{ 
  document.getElementById(mydiv).innerHTML = text
  document.getElementById(mytextfield).maxLength = mylength
}