/***********************************************************************************
*	(c) Jim MacDonald
***********************************************************************************/

// Get cookie routine by Shelley Powers
function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) {
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function getArgs() {
	var args = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	for(var i = 0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		args[argname] = unescape(value);
	}
	return args;
}

var args = getArgs();
if (args.r) {
	refemail = (args.r);
	document.cookie = "referral=" + refemail + "; expires=Friday, 31-Dec-10 23:59:59 GMT";
	}
	else
	{
	refemail=get_cookie("referral")
	if (refemail == null || refemail == "")
		refemail = "none";
}

// Checks load time of page
function PageFinished( ) {
   if (document.images) {
      img1 = new Image();
      img1.src=
      "images/finished_loading.gif";
   }
}


///////////////////////////////////
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}



/***********************************************
* Email Validation script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}




// Email Validation. Written by PerlScriptsJavaScripts.com

function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

for(i=0; i < e.length ;i++){
if(ok.indexOf(e.charAt(i))<0){ 
return (false);
} 
} 

if (document.images) {
re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (!e.match(re) && e.match(re_two)) {
return (-1);    
} 

}

}



function check_form(f) { // f is the form (passed using this keyword)
if(f.r_fname.value.length < 1){
alert("You entered less than one character in the name field.");
f.r_fname.focus(); // put the prompt in the name field 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
f.r_fname.style.background = "Orange";
}
// make sure the form is not submitted
return false;
}

// check the first email address ( the exclamation means "not" )
if(!check_email(f.re_email.value)){
alert("Invalid email detected.");
f.re_email.focus(); 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
f.re_email.style.background = "Orange";
}
// make sure the form is not submitted
return false;
}

}




function check_form(q) { // q is the form (passed using this keyword)
// check the email address ( the exclamation means "not" )
if(!check_email(q.vemail.value)){
alert("Please enter a valid email");
q.vemail.focus(); 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
q.vemail.style.background = "Orange";
}
// make sure the form is not submitted
return false;
}

}



function check_form(newsletter) { // newsletter is the form (passed using this keyword)
// check the email address ( the exclamation means "not" )
if(!check_email(newsletter.email.value)){
alert("Please enter a valid email");
newsletter.email.focus(); 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
newsletter.email.style.background = "Orange";
}
// make sure the form is not submitted
return false;
}

}


//Popup Window Script
//By JavaScript Kit (http://javascriptkit.com)
//JavaScript tutorials and over 400+ free scripts
function noimage(){
var popurl="http://www.higherawareness.com/previews/noimage-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function creativitybook(){
var popurl="http://www.higherawareness.com/previews/creativitybook-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function developingintuition(){
var popurl="http://www.higherawareness.com/previews/developingintuition-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function journalwriting(){
var popurl="http://www.higherawareness.com/previews/journalwriting-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function trackingsuccess(){
var popurl="http://www.higherawareness.com/previews/trackingsuccess-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function writeyourlife(){
var popurl="http://www.higherawareness.com/previews/writeyourlife-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function growyourself(){
var popurl="http://www.higherawareness.com/previews/growyourself-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function blockbusting(){
var popurl="http://www.higherawareness.com/previews/blockbusting-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function whoami(){
var popurl="http://www.higherawareness.com/previews/whoami-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function facilitatortraining(){
var popurl="http://www.higherawareness.com/previews/facilitatortraining-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function timemanskills(){
var popurl="http://www.higherawareness.com/previews/timemanskills-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function personalgoalsetting(){
var popurl="http://www.higherawareness.com/previews/personalgoalsetting-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function lifepurpose(){
var popurl="http://www.higherawareness.com/previews/lifepurpose-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
function manifestingabundance(){
var popurl="http://www.higherawareness.com/previews/manifestingabundance-lg.html"
winpops=window.open(popurl,"","width=350,height=430")
}
