Cufon.replace('li.l1')('div.phone')('h1')('h2')('h3');

if ($.browser.webkit){
	$('head').append('<link rel="stylesheet" type="text/css" href="/stylesheets/webkit-fix.css">');
}

$(function(){
	$('div.buttons li.l1').not('div.buttons li.nolink').hover(function(){ $(this).toggleClass('over'); }).click(function(){ document.location = $(this).find('a').attr("href"); });
	$('a.cb').colorbox({current: "{current} of {total}"});

});

$(document).ready(function(){
	$('div.special div.photos img').each(function(){
		$this = $(this);
		
		myheight = $this.height();
		boxheight = $this.parents('div.photos').height();
		if (myheight > boxheight) {
			$this.css("top",(parseInt((boxheight - myheight)/2) + "px"));
		}
	});
    $('.rotator').cycle();
});

function despace(testVal)
{ return testVal.replace(/ +/g, ''); }

function doVal(thisform) {
    var re = new RegExp;
    re.compile("[.\r\n]*?[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+[.\r\n]*?");

    if (re.test(thisform.ccomments.value) || re.test(thisform.cname.value) || re.test(thisform.caddress.value))
    { alert("You cannot enter URLs in this form."); return false; }

    if (!despace(thisform.cname.value)) { alert("You must enter a name."); return false; }
    if (!despace(thisform.ccity.value)) { alert("You must enter a city."); return false; }
    if (!despace(thisform.cemail.value)) { alert("You must enter an email address."); return false; }
    if (!despace(thisform.cphone.value) && !despace(thisform.cemail.value)) { alert("Please enter a phone number or an e-mail address."); return false; }
    if (despace(thisform.cemail.value)) { if (!thisform.cemail.value.match(/\w+@\w+.\w{2,}/)) { alert("You must enter a valid e-mail address."); return false; } }
    if (radioIndex(thisform.ccontact) < 0) { alert("Please choose a contact method."); return false; }
}

function radioIndex(rb) {
    checkedIndex = -1;
    for (i = 0; i < rb.length; i++)
    { if (rb[i].checked) { checkedIndex = i; } }
    return checkedIndex;
}
