if (document.images){
/*
upl_off = new Image();  upl_off.src = view_path+"images/icon_camera.gif";
upl_on = new Image();   upl_on.src = view_path+"images/icon_camera_on.gif";
next_off = new Image(); next_off.src = view_path+"images/button_next.gif";
next_on = new Image(); next_on.src = view_path+"images/button_next_on.gif";
prev_off = new Image(); prev_off.src = view_path+"images/button_prev.gif";
prev_on = new Image(); prev_on.src = view_path+"images/button_prev_on.gif";

star1 = new Image();  star1.src = view_path + "images/stars_1.gif";
star1h = new Image(); star1h.src = view_path + "images/stars_1h.gif";
star2 = new Image();  star2.src = view_path + "images/stars_2.gif";
star2h = new Image(); star2h.src = view_path + "images/stars_2h.gif";
star3 = new Image();  star3.src = view_path + "images/stars_3.gif";
star3h = new Image(); star3h.src = view_path + "images/stars_3h.gif";
star4 = new Image();  star4.src = view_path + "images/stars_4.gif";
star4h = new Image(); star4h.src = view_path + "images/stars_4h.gif";
star5 = new Image();  star5.src = view_path + "images/stars_5.gif";
*/
}
function clearTabs(set,total){
    for(i=1;i<=total;i++){
        tab = id2elem(set+'_t'+i);

        tab.className = "";
        section = id2elem(set+'_s'+i);
        section.style.display = "none";
    }
}

function filterNonNumeric(field) {
	var result = new String();
	var numbers = "0123456789";
	var chars = field.value.split(""); // create array
	for (i = 0; i < chars.length; i++) {
	if (numbers.indexOf(chars[i]) != -1) result += chars[i];
	}
	if (field.value != result) field.value = result;
}

function displaynameFilter(field) {
	var result = new String();
	var vals = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var chars = field.value.split(""); // create array
	for (i = 0; i < chars.length; i++) {
	if (vals.indexOf(chars[i]) != -1) result += chars[i];
	}
	if (field.value != result) field.value = result;
}

function emailLookup(val) {
	var fldval = $(val).value;
	var pars = 'v='+fldval;
	var URL = '/ola/ajax/emaillookup/';

	if (!fldval == '') {
    	var myAjax = new Ajax.Request(
		URL,
		{
			asynchronous: true,
			method: 'post',
			parameters: pars,
			onLoading: showLookup,
			onSuccess: showEmailSearchResults
		});
	}
}

function showEmailSearchResults (response) {
	var SEARCH_GOOD = 0;
	var SEARCH_FAILED = 1;
    var responseCode = response.responseText;

    //alert(responseCode);
    if (responseCode == SEARCH_GOOD) {
		//alert('Good Displayname');
		$('email-error').style.display = 'block';
		$('email-error').addClassName('formsuccess').update('You Can Use The Email Address Provided!');
    } else {
		//alert('email already in the system');
		$('email-error').style.display = 'block';
		$('email-error').addClassName('formerror').update('The Email Address Provided Has Already Been Registered');
		$('email').focus();
    }
}


function displaynameLookup(val) {
	var fldval = $(val).value;
	var pars = 'v='+fldval;
	var URL = '/ola/ajax/displaynamelookup/';

	if (!fldval == ''){
    	var myAjax = new Ajax.Request(
		URL,
		{
			asynchronous: true,
			method: 'post',
			parameters: pars,
			onLoading: showLookup,
			onSuccess: showNameSearchResults
		});
	}
}

function showLookup () {
	$('loading').style.display = 'block';

}

function showNameSearchResults (response) {
	var SEARCH_GOOD = 0;
	var SEARCH_FAILED = 1;
    var responseCode = response.responseText;

    //alert(responseCode);
    if (responseCode == SEARCH_GOOD) {
		//alert('Good Displayname');
		$('username-error').style.display = 'block';
		$('username-error').addClassName('formsuccess').update('Your Choosen Display Name is Available!');
    } else {
		//alert('Displayname already in the system');
		$('username-error').style.display = 'block';
		$('username-error').addClassName('formerror').update('Your Choosen Display Name is Already Taken');
		$('displayname').focus();
    }
}

function verifyPass () {
	var pwd1 = $('password').value;
	var pwd2 = $('pwd2').value;

	if (pwd1 != pwd2){
		$('password2-error').update('Passwords Do NOT Match!');
		$('password').focus();
	}
}

function videohover(num,dir){
    title = id2elem('title'+num);
    thumb = id2elem('thumb'+num);
    if (dir==1){
       //title.style.display = 'block';
       thumb.style.border = '1px solid #090';
    }else{
       //title.style.display = 'none';
       thumb.style.border = '1px solid #999';
    }
}

function setscrollwidth(holderid, tNum, tWidth, border, margins){
    holder = id2elem(holderid);
    hWidth = ((tNum+1)*tWidth)+(2*border)+(2*margins);
    holder.style.width = hWidth+'px';
}

function tabswitch(set,tNum,total){
    clearTabs(set,total);
    tab = id2elem(set+'_t'+tNum);

    tab.className = 'on';
    section = id2elem(set+'_s'+tNum);
    section.style.display = "block";
}
function roll(sname,rname){
    sname = id2elem(sname);
    sname.src = rname.src;
}
function id2elem(id) {
	if (typeof(id) != 'string') {
		return id;
	}
	if (document.getElementById) {
		id = document.getElementById(id);
	} else if (document.all) {
		id=document.all[id];
	} else {
		id = null;
	}
	return id;
}
function popup(url,width,height){
    nw = window.open(url,"newwindow","width="+width+",height="+height+",status=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,location=0");
    nw.focus();
}

function swapThumb(sid) {
	//alert('starting the image swap');
	var img = 'images/bff/'+sid+'_big.jpg';
	$("#big_photo").css({backgroundImage:'url('+img+')'});
	//alert('finished the image swap');
}


function checkForm(){
if (document.subscribeForm.elements['Email Address'].value.length > 0){
 return true;
 }
else{
 alert('Please enter your email address.');
 document.subscribeForm.elements['Email Address'].focus();
 return false;
 }
}
