curleft = 0;
curtop = 0;

function getPosition(objpos){
	//alert(objpos);
	if (objpos.offsetParent) {
		curleft = objpos.offsetLeft;
		curtop = objpos.offsetTop;
		while (objpos = objpos.offsetParent) {
			curleft += objpos.offsetLeft;
			curtop += objpos.offsetTop;
		}
	}
}

var runtimeout = 0;
/*Need to change*/
function moveDivs(){ 
	getPosition(document.getElementById("World_Target"));
	var Logo_left = curleft + 166;
	var Logo_top = curtop + 42.5;
	document.getElementById("WorldTop_Div").style.left = Logo_left + 'px';
	document.getElementById("WorldTop_Div").style.top = Logo_top + 'px';
	
	getPosition(document.getElementById("World_Target_Right"));
	var Logo_left = curleft + 6;
	var Logo_top = curtop + 17;
	document.getElementById("WorldRight_Div").style.left = Logo_left + 'px';
	document.getElementById("WorldRight_Div").style.top = Logo_top + 'px';
	
	getPosition(document.getElementById("Twitter_Target"));
	var Logo_left = curleft + 590;
	var Logo_top = curtop + 35;
	document.getElementById("Twitter_Div").style.left = Logo_left + 'px';
	document.getElementById("Twitter_Div").style.top = Logo_top + 'px';
	
}
var newWindow = null
function windowOpen(loadpos){
        if (! newWindow || newWindow.closed)
        {
        	newWindow = window.open(loadpos,"","resizable=yes,scrollbars=yes,width=600,height=480,left=2,top=2");
        }else
        {
         	newWindow.focus();
        	newWindow.location.href=loadpos;
        }
}

var pictureWindow = null
function pictureOpen(loadpos){
        if (! pictureWindow || pictureWindow.closed)
        {
        	pictureWindow = window.open(loadpos,"","resizable=no,scrollbars=no,width=620,height=350,left=2,top=2");
        }else
        {
         	pictureWindow.focus();
        	pictureWindow.location.href=loadpos;
        }
}


var unPopupWindow = null
function unPopupOpen(loadpos){
        if (! unPopupWindow || unPopupWindow.closed)
        {
        	unPopupWindow = window.open(loadpos,"","resizable=no,scrollbars=no,width=290,height=315,left=2,top=2");
        }else
        {
         	unPopupWindow.focus();
        	unPopupWindow.location.href=loadpos;
        }
}


var chilumbaWindow = null
function chilumbaOpen(loadpos){
        if (! chilumbaWindow || chilumbaWindow.closed)
        {
        	chilumbaWindow = window.open(loadpos,"","resizable=no,scrollbars=no,width=315,height=700,left=2,top=2");
        }else
        {
         	chilumbaWindow.focus();
        	chilumbaWindow.location.href=loadpos;
        }
}


var haitiWindow = null
function haitiOpen(loadpos){
        if (! haitiWindow || haitiWindow.closed)
        {
        	haitiWindow = window.open(loadpos,"","resizable=no,scrollbars=no,width=285,height=340,left=2,top=2");
        }else
        {
         	haitiWindow.focus();
        	haitiWindow.location.href=loadpos;
        }
}





function validEmail(email){
	invalidChars = " /:,;"
	for(i=0;i<invalidChars.length;i++){
		badChar = invalidChars.charAt(i)
		if(email.indexOf(badChar,0) > -1){
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if(atPos == -1){
		return false
	}
	if(email.indexOf("@",atPos+1) > -1){
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if(periodPos == -1){
		return false
	}
	if(periodPos+3 > email.length){
		return false
	}
	return true
}

var newEmail = null;
function emailOpener(url){
	posleft=screen.width/2-240;
	postop=screen.height/2-280;
	if ( newEmail && !newEmail.closed){
		newEmail.focus();
	}else{
		newEmail = window.open("emailpopup.php?url="+url,"emailfriend","resizable=no,scrollbars=no,width=482,height=480,left="+posleft+",top="+postop);
	}
}

function submitContact(form1){
	
	if(form1.Firstname.value == ""){
		alert("You must enter your first name.");
		form1.Firstname.focus();
		return false;
	}
	if(form1.Lastname.value == ""){
		alert("You must enter your last name.");
		form1.Lastname.focus();
		return false;
	}
	if(form1.Email.value == ""){
		alert("You must enter your email.");
		form1.Email.focus();
		return false;
	}
	if (!validEmail(form1.Email.value)){
		alert("You must enter a valid email.");
		form1.Email.focus();
		form1.Email.select();
		return false;
	}	
	var VEnter = form1.VEnter.value;
	if (VEnter == "")
	{
		alert("Please enter the validation code!");
		form1.VEnter.focus();
		form1.VEnter.select();
		return false;
	}
	if (VEnter.length != 6)
	{
		alert("The code is invalid! Please re-enter it.");
		form1.VEnter.focus();
		form1.VEnter.select();
		return false;
	}
	return true;
}


/*Javascript code that will increase or decrease the text inside <p> tags
Modified the script so that it will also increase the line-height each time as well.*/

/*var min=10;
var max=18;
var lsmax=21;
var lsmin=12;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
	  if(p[i].style.lineHeight) {
		 var ls = parseInt(p[i].style.lineHeight.replace("px",""));
	  } else {
		  var ls = 15;
	  }	  
      if(s!=max) {
         s += 2;
      }
	  if(ls!=lsmax) {
		  ls += 3;
	  }
      p[i].style.fontSize = s+"px"
	  p[i].style.lineHeight = ls+"px"
	  moveDivs();
	  cupshadowheight();
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
	  if(p[i].style.lineHeight) {
		 var ls = parseInt(p[i].style.lineHeight.replace("px",""));
	  } else {
		  var ls = 15;
	  }	  
      if(s!=min) {
         s -= 2;
      }
	  if(ls!=lsmin) {
		  ls -= 3;
	  }
      p[i].style.fontSize = s+"px"
  	  p[i].style.lineHeight = ls+"px"
	  moveDivs();
	  cupshadowheight();
   }   
}

function rolloverMessage(message){
	document.getElementById('messageStrip').innerHTML = message;
	
	if (message == ""){
		document.getElementById('messageStrip').innerHTML = "<span style='color:#FFFFFF;'>.</span>";
	}
}
function openPrint(printpage){
	winwidth=900
	winheight=700	
	posleft=(screen.width-winwidth)/2
	postop=(screen.height-winheight)/2-60

	//posleft=(screen.width-winwidth)/2
	//postop=(screen.height-winheight)/2-60
	if(postop<20){postop=20}
	newP = window.open(printpage,"PrintWin","left="+posleft+",top="+postop+",width="+winwidth+",height="+winheight+",directories=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=left,resizable=yes");
	if (newP.opener == null){
		newP.opener = window;
	}else{
		newP.focus();
	}
	newP.opener.name = "opener";
}

function printerFriendly(url){
	winwidth=625;
	winheight=500;
	posleft=(document.body.clientWidth-winwidth)/2;
	postop=(document.body.clientHeight-winheight)/2-60;
	if(postop<20){postop=20}
	newP = window.open(url,"PrintWin","left="+posleft+",top="+postop+",width="+winwidth+",height="+winheight+",directories=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=left,resizable=yes");
	if (newP.opener == null){
		newP.opener = window;
	}else{
		newP.focus();
	}
	newP.opener.name = "opener";
}


var prevBg;
function swapBg(obj){
	if(document.getElementById){
		
		var bl = document.getElementById("div_"+obj);
		prevBg = bl.className;
		 
		bl.className = "leftnav_ro";
	}
}
function swapBgRestore(obj){
	if(document.getElementById){
		
		var bl = document.getElementById("div_"+obj);
		//prevBg = bl.style.className;
		 
		bl.className = prevBg;
	}
}



var offs = 50;
var shadowheight = 0;
var thisheight = 0;
function cupshadowheight() {

	var contentheight = document.getElementById("maintableheight").offsetHeight;
	var browserheight = document.body.clientHeight;
	
	if(contentheight > 700){
		
		shadowheight = 200;		
	}
	else{
		shadowheight = (browserheight - offs) - contentheight;
	}
	document.getElementById("CupShadow_Div").style.height = shadowheight + 'px';
}

var initialClickid = "";
function expandCollapse(id)//function that hides and shows Questions on the faq page
{
	element = document.getElementById("id_"+id);
	if(element.className == 'show') {
		element.className = "hide";
		document.getElementById("plusminus_"+id).src = "images/expand_button.jpg";

	}else{
		element.className = "show";
		document.getElementById("plusminus_"+id).src = "images/minimize_button.jpg";

	}
	moveDivs();
	moveDivs();
}

function expandAll(){
	for($i=1; $i<=11; $i++){
	element = document.getElementById("id_Q"+$i);
	document.getElementById("plusminus_Q"+$i).src = "images/minimize_button.jpg";
	element.className = "show";
	}
	moveDivs();
	moveDivs();//method called once more to fix bug with certain browsers
}

function collapseAll(){
	for($i=1; $i<=11; $i++){
	element = document.getElementById("id_Q"+$i);
	document.getElementById("plusminus_Q"+$i).src = "images/expand_button.jpg";
	element.className = "hide";
	}
	cupshadowheight();
	moveDivs();
	moveDivs();//method called once more to fix bug with certain browsers
}


var current_snav;
current_snav = ""

function showSubnav(snav){
	//obj_sn = document.getElementById("nav_"+snav);
	if(current_snav == ""){
		document.getElementById("leftnav_"+snav+"_sub").style.display = "block";
	}else{
		//obj_csn = document.getElementById("nav_"+current_snav);
		if(current_snav != snav){
			document.getElementById("leftnav_"+current_snav+"_sub").style.display = "none";
			document.getElementById("leftnav_"+snav+"_sub").style.display = "block";
		}else if(document.getElementById("leftnav_"+snav+"_sub").style.display == "none"){
			document.getElementById("leftnav_"+snav+"_sub").style.display = "block";
			//document.getElementById("nav_"+snav+"_sub").style.clip = "rect(0 50 50 0)";
			//showSlide(document.getElementById("nav_"+snav+"_sub"));
		}else{
			document.getElementById("leftnav_"+snav+"_sub").style.display = "none";
		}
	}
	current_snav = snav;
	moveDivs();
}


var prevSubBg;
function swapSubBg(snav,obj){
	if(document.getElementById){
		var b = document.getElementById("leftnav_"+snav+"_sub_"+obj);
		prevSubBg = b.style.backgroundColor;
		b.style.backgroundColor="#ede9de";
		b.style.color="#a58744";
	}
}
function swapSubBgRestore(snav,obj){
	if(document.getElementById){
		var b = document.getElementById("leftnav_"+snav+"_sub_"+obj);
		//prevBg = bl.style.className;
		b.style.backgroundColor=prevSubBg;
	}
}

function submitPopup(form1) {
	if (!Isempty(form1.FriendName.value))
	{
		alert("Please enter your friend's name!")
		form1.FriendName.focus()
		form1.FriendName.select()
		return false
	}
	if (!Isempty(form1.FriendEmail.value))
	{
		alert("Please enter your friend's email!")
		form1.FriendEmail.focus()
		form1.FriendEmail.select()
		return false
	}
	if (!validEmail(form1.FriendEmail.value))
	{
		alert("Please enter a valid email address!")
		form1.FriendEmail.focus()
		form1.FriendEmail.select()
		return false
	}
	if (!Isempty(form1.Name.value))
	{
		alert("Please enter your name!")
		form1.Name.focus()
		form1.Name.select()
		return false
	}
	if (!Isempty(form1.Email.value))
	{
		alert("Please enter your email!")
		form1.Email.focus()
		form1.Email.select()
		return false
	}
	if (!validEmail(form1.Email.value))
	{
		alert("Please enter a valid email address!")
		form1.Email.focus()
		form1.Email.select()
		return false
	}
	return true
}

function submitChangeForm(form1){
	if(form1.Firstname.value == ""){
		alert("You must enter your first name.");
		form1.Firstname.focus();
		return false;
	}
	if(form1.Lastname.value == ""){
		alert("You must enter your last name.");
		form1.Lastname.focus();
		return false;
	}
	if(form1.UANumber.value == ""){
		alert("You must enter your UA#.");
		form1.UANumber.focus();
		return false;
	}
	
	if(form1.OldAddress1.value == ""){
		alert("You must enter your old address.");
		form1.OldAddress1.focus();
		return false;
	}
	if(form1.OldCity.value == ""){
		alert("You must enter the city.");
		form1.OldCity.focus();
		return false;
	}
	
	if(form1.OldProvince.selectedIndex == 0){
		alert("You must select the province.");
		form1.OldProvince.focus();
		return false;
	}
	if(form1.OldPostalcode.value == ""){
		alert("You must enter the postal code.");
		form1.OldPostalcode.focus();
		return false;
	}
	
	if(form1.NewAddress1.value == ""){
		alert("You must enter your new address.");
		form1.NewAddress1.focus();
		return false;
	}
	if(form1.NewCity.value == ""){
		alert("You must enter the city.");
		form1.NewCity.focus();
		return false;
	}
	
	if(form1.NewProvince.selectedIndex == 0){
		alert("You must select the province.");
		form1.NewProvince.focus();
		return false;
	}
	if(form1.NewPostalcode.value == ""){
		alert("You must enter the postal code.");
		form1.NewPostalcode.focus();
		return false;
	}
	return true;
}

function submitLogin(form1){
	if(form1.MemberName.value == ""){
		alert("You must enter your email address.");
		form1.MemberName.focus();
		return false;
	}
	if (!validEmail(form1.MemberName.value)){
		alert("You must enter a valid email.");
		form1.MemberName.focus();
		form1.MemberName.select();
		return false;
	}
	if(form1.MemberNumber.value == ""){
		alert("You must enter your your UA Number.");
		form1.MemberNumber.focus();
		return false;
	}
	
	return true;
}


function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint =
window.open('','','left=0,top=0,width=0,height=0,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
//prtContent.innerHTML=strOldOne;
}


function pickup_BackGround() {
	if(document.images){
 		rnum = Math.floor((Math.random() * 4) +1);
		//alert(rnum);
		if(document.getElementById) {
			document.getElementById("RightCol").style.backgroundImage = "url('/images/bg/bg_" + rnum + ".jpg')";
		}
	}
}

function switchPic(){
	
	if (picnum == 5){
		picnum = 0;
		clearTimeout(timer);
		timer = null;
	}
	timer =	window.setTimeout('SlideSwitch()', 1000);//change back to 4000	
	picnum ++;
}

var picnum = 1;
function SlideSwitch(){
	
	if(document.getElementById) {
		document.getElementById("RightCol").style.backgroundImage = "url('/images/bg/bg_" + picnum + ".jpg')";
		timer =	window.setTimeout('switchPic()', 4000);//change back to 5500		
	}
}*/
