// JavaScript Document


//swap image..

function toCaps(v){
		return String(v).substr(0,1).toUpperCase() + String(v).substr(1, String(v).length).toLowerCase();
	}
	

var dys = String("sunday,monday,tuesday,wednesday,thursday,friday,saturday").split(",");

var mths = String("january,february,march,april,may,june,july,august,september,october,november,december").split(",");

function gettime(){
		var gd = new Date();
		yd = gd.getDay();
		yt = gd.getDate();
		ym = gd.getMonth();
		fy = gd.getFullYear();
		
		//the foot txt...
		$("#footxt").html('&copy; ' + fy + ' All Rights Reserved :: The Capital Assembly');
		
		//the send the date...		
		return toCaps(dys[yd]) +" "+  yt +" "+  toCaps(mths[ym]) +", "+ fy;
	}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var totalpictures  = 70;


function setmvrs(tp,msg){
		$("#vrs > #tp").html(tp);	
		$("#vrs > #txt").html(msg);
	}

function getmverse(){	
		$.ajax({
			type:"post",
			url:"admin/getmverse.php",
			success:function(msg){
				pts = String(msg).split("%%%%");
				setmvrs(pts[0],pts[1])// set the memory verse...
			}
		})	
	}
	

$(document).ready(function(){
	getmverse();
	
	$("#gallerybox > a").fadeTo("medium", 0.4);
	//$("#grypix > a").fadeTo("medium", 0.4);
	//$("#tbody").fadeTo("fast", 0.3);
	$("#pimg").bind("load", function(){
		$("#pixframe").fadeTo("fast",1);
	})
	
	
	
	//for every of that <p> tag.. add this in the front...
	$("#unittabs > div > p").prepend('<img src="assets/penx.png" width="13" height="16" align="absmiddle" />&nbsp;&nbsp;');

	$.get("config.xml", function(data){
			  
			  //for the main text...
			  topmg = $(data).find("topmsg").text();
			  
			  dt = 'Tuesday 13th October, 2010';
			  
			  xtr = '<img src="assets/cdricon.png" align="absmiddle"/>&nbsp;&nbsp;' + gettime() + '<br /><span>' + topmg + '</span>';
			  
			  $("#dailycdr").html(xtr);			  
			  
			  
			
			

		});




});



function fin(obj){
		//$(obj).fadeTo("medium", 1);
		//$("#thmb").fadeTo("medium", 1);
	}


function clsgallrx(){
			
		$("#halbum").fadeOut("medium", function(){
			$("#pixframe").html("");
		});
	}



function shwimg(v){
			
		so = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="800" height="600"> <param name="movie" value="roller.swf" /> <param name="quality" value="high" /> <param name="wmode" value="transparent"/> <param name="flashVars" value="ig=' + v + '" /> <embed src="roller.swf" flashVars="ig=' + v + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="800" height="600"></embed></object>';
		  
		 //fit in the value of the flash file..
		 
		 $("#pixframe").html(so);
		 $("#halbum").fadeIn("medium", function(){
			
		});	  

	 }


function fout(obj){
		$(obj).fadeTo("medium", 1);
	}
	
function reveal(){
		$("#firstimg").css("display","none");
		$("#tbody").fadeTo("medium", 1);
	}	
	
	
function sendquickmail(){
		$("#ctform").slideDown("medium");	
	}
	
	
function submitmsg(){
		$("#cltldx").show("fast",function(){
			
		});	
	}	
	
	
function clsctform(){
		$("#ctform").slideUp("medium");	
	}
	
	
function showthis(v){
		for(i=1;i<=6;i++){
				if(v == i){
					$("#msg"+i).slideDown("fast");
				}else{
					$("#msg"+i).slideUp("fast");
				}
				
			}
		}	
	

function getsongfile(v){
		window.location.href = v;
	}
	
function shwringtones(){
		$("#wallpapers").css("display","none");
		$("#ringtones").css("display","block");
	}	

	
function shwwallpapers(){
		$("#wallpapers").css("display","block");
		$("#ringtones").css("display","none");
	}

function gotopage(v){
		tx = "";	
		
		minx = (30 * v) - 29;
		maxx = (30 * v);
		
		
		for(i = minx; i <= maxx; i++){
			if(i <= totalpictures){
				tx += '<a id="thmb" href="javascript:;" onclick="shwimg('+i+')"><img src="gallery/thumbs/pix'+ i +'.jpg" width="100" height="75"/></a>';
			}
		}	
		
		$("#gallerybox").html(tx);		
	}
	
/////////////////////////////////////////////////////////////////////////

function showregform(){
		resetfields();
		$("#regmember").fadeIn("fast");
	}
	
function clsregform(){
		$("#regmember").fadeOut("fast");
		resetfields();
	}
	
	
///////////////////////////////////////////////////for the email part...

var fullnames = String("Lastname,Firstname,Address,Email,Phone,Occupation,Mobile,Marital Status,Number of Children,your Postal Address,Age Group,Why i want to be an E-member,Have you Given your Life to chirst").split(",");

var objs = String("lname,fname,addr,email,phone,occp,mobile,mstatus,childnum,agerg,paddr,emember,lifecht").split(",");

var msg;

function resetfields(){
	for(i=0;i<=objs.length-1;i++){			
				$("#"+objs[i]).removeAttr("disabled");
				$("#"+objs[i]).val("");
			}
	}

function disableall(){
		for(i=0;i<=objs.length-1;i++){			
				$("#"+objs[i]).attr("disabled", "disabled");
			}
	}
	
function treatit(v){
		$.ajax({
			type:"post",
			url:"sendmsg.php",
			data:v,
			success:function(msg){					
					if(msg == "sent"){
						alert("Message Sent, We'll get back to you \nwithin the next 24hrs");					
					}else{
						alert("error sending message...");
					}
					resetfields();
					$("#rollimg").css("display","none");
				}	
		});
		
	}
	
function submitreg(){
		msg = "msg=";
		
		$("#rollimg").css("display","block");
		
		for(i=0;i<=objs.length-1;i++){
			if(i<objs.length-1){
				msg += "<b>" + fullnames[i] + "</b>:" + $("#"+objs[i]).val()+", <br>";
			}else{
				msg += "<b>" + fullnames[i] + "</b>:" + $("#"+objs[i]).val();
			}	
		}
		disableall();
		treatit(msg);
	}
	
	
	
function getallevents(){
	
		$.ajax({
			type:"post",
			url:"allevents.php",
			success:function(msg){
				$("#evnts").html(msg);
			}
		})
	
	}
