function checktag(e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key==null) || (key==0) || (key==8) ||
    (key==9) || (key==13) || (key==27) )
   return true;

// alphas and numbers
else if ((("abcdefghijklmnopqrstuvwxyz0123456789,- ").indexOf(keychar) > -1))
   return true;
else
	alert('Only alphanumeric characters and - are allowed in Tag.');
   return false;
}

var testimonial_index = Math.floor(Math.random()*4);
function switchtestimonial(){
    var ids=new Array('testimonial1','testimonial2','testimonial3','testimonial4');	
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}
	showdiv(ids[testimonial_index]);
	testimonial_index=testimonial_index+1;
	 // when at the end, start again
 	if(testimonial_index==4) { 
 		testimonial_index=0; 
 	}
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	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';
		}
	}
}

function showdiv(id) {
    
	//safe function to show an element with a specified id
		  
	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';
		}
	}
}

var bannerAD = new Array();  
var bannerADlink = new Array();  
var adNum = 0;  
   
bannerAD[0]="/images/banner_homepage5.jpg";  
bannerADlink[0]="#";  
bannerAD[1]="/images/banner_homepage1.jpg";  
bannerADlink[1]="#";  
bannerAD[2]="/images/banner_homepage2.jpg";   
bannerADlink[2]="#";  
bannerAD[3]="/images/banner_homepage3.jpg";   
bannerADlink[3]="#";  
bannerAD[4]="/images/banner_homepage4.jpg";   
bannerADlink[4]="#";
   
var preloadedimages = new Array();  
for (i=1;i<bannerAD.length;i++){  
   preloadedimages[i] = new Image();  
   preloadedimages[i].src = bannerAD[i];  
}  
   
function setTransition(){  
	if (document.all){  
    	bannerADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);  
    	bannerADrotator.filters.revealTrans.apply();  
	}  
}  
   
function playTransition(){  
    if (document.all){ 
    	bannerADrotator.filters.revealTrans.play();
    }  
}  
   
function nextAd(){  
    if(adNum<bannerAD.length-1)
    	adNum++;  
    else   
    	adNum=0;  
    setTransition();  
    document.images.bannerADrotator.src=bannerAD[adNum];  
    playTransition();  
    theTimer=setTimeout("nextAd()", 5000);  
}  
   
function jump2url(){  
   jumpUrl=bannerADlink[adNum];  
   jumpTarget='';  
   if (jumpUrl   !=   ''){  
       if(jumpTarget != '')
       		window.open(jumpUrl,jumpTarget);  
       else   
       		location.href=jumpUrl;  
   }  
}  

function displayStatusMsg(){    
   status=bannerADlink[adNum];  
   document.returnValue = true;  
}

function preview(){
	var formElement = $("editCssForm");
	var params = 'cssContent='+$("cssContent").value;
	new Ajax.Request("edit-css.php?savePreview=true",
	{
					    method:"post",
						postBody:params,
					    onSuccess: function(transport){
							//alert(transport.responseText);
					    	refreshPreviewBox();
					    }
					  }
			)
	
}

function refreshPreviewBox(){
	$("previewBox").src = $("previewBox").src;
}

function reset_member_password(user_id) {
	
	var params = 'user_id='+user_id;
	
	new Ajax.Request("private-member-resetpasswd.php",
	{
					    method:"post",
						postBody:params,
					    onSuccess: function(transport){
							//alert(transport.responseText);
							$('pw_'+user_id).innerHTML = '<br />Password reset to [<strong>'+transport.responseText+'</strong>]';
					    }
					  }
	);	
	
}