$(document).ready(function(){
	//-------------initModal------------------------
	$.jqm.params.modal = true;
	$('#dialog').jqm();
	
	//-------------red------------------------------
	$('.redboxheader').corner('top 5px');
	$('.redboxcontentborder').corner('bottom 5px');
	$('.redboxcontent').corner('bottom 5px');
	//-------------yellow---------------------------
	$('.yellowboxheader').corner('top 5px');
	$('.yellowboxcontentborder').corner('bottom 5px');
	$('.yellowboxcontent').corner('bottom 5px');
	//-------------blue-----------------------------
	$('.blueboxheader').corner('top 5px');
	$('.blueboxcontentborder').corner('bottom 5px');
	$('.blueboxcontent').corner('bottom 5px');
	//-------------green----------------------------
	$('.greenboxheader').corner('top 5px');
	$('.greenboxcontentborder').corner('bottom 5px');
	$('.greenboxcontent').corner('bottom 5px');
	//-------------buttons--------------------------
	$('.redbutton').hover(function(){$(this).css({'background-color':'#FFC800','border-color':'#FF4B00','color':'#EB1400'})},function(){$(this).css({'background-color':'#FF4B00','border-color':'#620000','color':'#FFF'})});
	$('.yellowbutton').hover(function(){$(this).css({'background-color':'#0082FF','border-color':'#0082FF','color':'#FFF'})},function(){$(this).css({'background-color':'#FFC800','border-color':'#FF4B00','color':'#EB1400'})});
	$('.bluebutton').hover(function(){$(this).css({'background-color':'#FFC800','border-color':'#FF4B00','color':'#EB1400'})},function(){$(this).css({'background-color':'#0082FF','border-color':'#0062E9','color':'#FFF'})});
	$('.greenbutton').hover(function(){$(this).css({'background-color':'#FFC800','border-color':'#FF4B00','color':'#EB1400'})},function(){$(this).css({'background-color':'#85B700','border-color':'#4C901D','color':'#FFF'})});
	//-------------leftimages pages-----------------
	$('.acornleftimage').css({'background-image':ACORNUTILS.load_random_image()});
	$('.leftimagediv').corner("round 5px").parent().css('padding', '1px').corner("round 5px");

});
var ACORNUTILS = {
	o_cached_doc : document,
	a_leftimages:[
		'leftimage1.jpg',
		'leftimage2.jpg',
		'leftimage3.jpg',
		'leftimage4.jpg',
		'leftimage5.jpg',
		'leftimage6.jpg',
		'leftimage7.jpg',
		'leftimage8.jpg',
		'leftimage9.jpg',
		'leftimage10.jpg'
	],
	a_quikfacts:[
		'50% of women believe they are more stressed than their mothers were at the same age, however 52% also believe they are more satisfied.',
		'4 in 5 mothers believe there is a silent battle between working mums and stay-at-home mums.',
		'69% of women have doubts about whether they have chosen the right career path.',
		'Getting fit and losing weight are the top goals for Australian women in the next 2-5 years.',
		'38% of women vote Cate Blanchett as they ideal Australian woman, while only 10% voted for Nicole Kidman.',
		'85% of women would choose wealth over beauty.',
		'Half of all women have seen a therapist or health professional to deal with stress or relationship issues.',
		'75% of women believe that a happy family life and relationship defines success in their life.',
		'82% of women would choose their relationship over their career.',
		'78% of women believe there is pressure to have a perfect family life as well as a great career.',
		'Only 12% of women are happy with their bodies.',
		'42% of  working women believe they would be more successful in their careers if they were more attractive.',
		'63% of women are trying to lose weight.',
		'38% of women are open to having botox.',
		'46% of women think about the fat content of food at least once a day.',
		'28% of our days are spent feeling stressed.',
		'62% describe themselves as confident.',
		'35% describe themselves as beautiful.',
		'51% of women consider themselves happy. On average they rate their happiness a 7 out of 10.',
		'Women are more focused on their health and relationships than their career.'
	],
	randomise_int:function (min, max){
		var _i_random = Math.floor(Math.random() * (max - min + 1)) + min;
		return _i_random;
	},
	load_random_image:function(){
		return 'url(images/' 
			+ this.a_leftimages[this.randomise_int(0, this.a_leftimages.length-1)]
			+ ')';
	},
	load_quikfacts:function(){
		return this.a_quikfacts[this.randomise_int(0, this.a_quikfacts.length-1)]
	},
	checkemail:function(str){//same as PublicEye's IsEmail()
		// checks for a vaild email
		// returns False for invalid addresses
		// returns True for valid addresses

		// chk length

		var atpos = str.indexOf("@");
		if (str.length < 6){
			//a@b.c should be the shortest an address could be
			return false;
		}

		// At least one @ and not at front or back
		if (atpos==-1 || atpos==0 || atpos==(str.length-1)){
		   return false;
		}

		// At least one . and not at front or back
		if (str.indexOf(".")==-1 || str.indexOf(".")==0 || str.indexOf(".")==(str.length-1)){
			return false;
		}

		// Only one @
		if (str.indexOf("@",(atpos+1))!=-1){
			return false;
		}

		var before = "1234567890qwertyuiopasdfghjklzxcvbnm+.@-_'QWERTYUIOPASDFGHJKLZXCVBNM";
		for(i=0; i < atpos ;i++){
			if(before.indexOf(str.charAt(i))<0){
				return false;
			}
		}

		var after = "1234567890qwertyuiopasdfghjklzxcvbnm.-QWERTYUIOPASDFGHJKLZXCVBNM";
		for(i=atpos+1; i < str.length ;i++){
			if(after.indexOf(str.charAt(i))<0){
				return false;
			}
		}

		var last_dot_pos=str.length-str.lastIndexOf(".")-1;
		if (last_dot_pos>4 || last_dot_pos<2){
			return false;
		}
		return true;
	},
	logout:function(){
		window.location = 'index.php?logout=true';
	}

};

