/*
////////////////////////////////////
FOR IE6 - Enter the IDs in an array for each nav for IE6's sfhover
///////////////////////////////////
*/
var IE6navID = new Array('nav');

/*
////////////////////////////////////
FORM VALIDATION
///////////////////////////////////
*/
/*
	//CHECK REQUIRED INPUT FIELD FOR TEXT
	//Works for both <textarea> and <input type="text"> tags
	// checkField(obj,'reqTextInputName','nameForAlertMessage')
	if (!checkField(obj,'Name','Name')) { valid = false; return valid; }
	
	//FILE UPLOAD EXTENSION CHECKER
	//This optional version checks a file uploading field to see if it's got a correct file extension in it
	//NOTE that checkExt needs to be present, extList must be a delimited string, 
	//and you must supply the delimiter which matches the one in the string
	var extList = "PDF|PSD|AI|QXD|EPS|PS|JPG|JPEG|TIF|TIFF|ZIP|SIT|SITX|DOC|TXT|RTF";
	var checkExt = "yes";
	if (!checkField(obj,'testFileName','Upload File',checkExt,extList,"|")) { valid = false; return valid; }
	
	//OTHER TYPES OF FORM FIELDS
	// checkEMail(obj,'reqEmailFieldName','nameForAlertMessage')
	if (!checkEmail(obj,'testEmail','Email')) { valid = false; return valid; }
	// checkSelect(obj,'reqDropdownName','nameForAlertMessage')
	if (!checkSelect(obj,'testState','Please select a state.')) { valid = false; return valid; }
	// checkCheckbox(obj,'reqCheckboxName','nameForAlertMessage')
	if (!checkCheckbox(obj,'testChecky','Select the damn checkbox!')) { valid = false; return valid; }
	// checkRadio(obj,'reqRadioName','isRequired','requiredMessage','correctOption','alertMsgForCorrectOption')
	if (!checkRadio(obj,'testRadio','required','Please select one of the Yes/No/Maybe options.','Maybe','Please select "Maybe" from the options.')) { valid = false; return valid; }
	*/

function checkContactForm(obj) {
	valid = true;
	if (!checkField(obj,'Name','Name')) { valid = false; return valid; }
	if (!checkEmail(obj,'Email','Email')) { valid = false; return valid; }
	if (!checkSelect(obj,'Inquiry','Please select the nature of your inquiry.')) { valid = false; return valid; }
	if (!checkSelect(obj,'HowFound','Please select how you found this site.')) { valid = false; return valid; }
	if (!checkField(obj,'Comments','How Can We Help')) { valid = false; return valid; }
	if (!checkField(obj,'captcha','Spam Prevention Code')) { valid = false; return valid; }
}
function checkReferForm(obj) {
	valid = true;
	if (!checkField(obj,'YName','Your Name')) { valid = false; return valid; }
	if (!checkEmail(obj,'YEmail','Your Email')) { valid = false; return valid; }
	if (!checkField(obj,'CName','Your Contact\'s Name')) { valid = false; return valid; }
	if (!checkEmail(obj,'CEmail','Your Contact\'s Email')) { valid = false; return valid; }
	if (!checkField(obj,'captcha','Spam Prevention Code')) { valid = false; return valid; }
}
function checkSiteSearch(obj) {
	valid = true;
	if (!checkField(obj,'mcsmSiteSearch','Site Search')) { valid = false; return valid; }
}

/*
////////////////////////////////////
NAVIGATION FUNCTIONS
///////////////////////////////////
*/

function toggleLink(id,text,url) {
	if (url) {
		ajaxResults(url,'getData',id);
		$('link-'+id).setAttribute('href','javascript:void(toggleLink(\''+id+'\',\''+text+'\'))');
	}
	toggle(id);
	if ($(id).style.display == 'none') {
		$('link-'+id).innerHTML = 'Show ' + text;
		if($('title-'+id)) {
			$('title-'+id).style.fontSize = '11px';
			$('title-'+id).style.fontWeight = 'bold';
			$('title-'+id).style.color = '#494B4D';
		}
	} else {
		$('link-'+id).innerHTML = 'Hide ' + text;
		if($('title-'+id)) {
			$('title-'+id).style.fontSize = '18px';
			$('title-'+id).style.fontWeight = 'normal';
			$('title-'+id).style.color = '#A4A5A6';/*#C2C6CC*/
		}
	}
}

/*
////////////////////////////////////
COMMENTING FUNCTIONS
///////////////////////////////////
*/

function commentLink(orig) {
	toggle('comments');
	if ($('comments').style.display == 'none') {
		$('commentLink').innerHTML = orig;
	} else {
		$('commentLink').innerHTML = 'Close comments';
	}
}

/*
////////////////////////////////////
SET UP SIFR
///////////////////////////////////
*/
/*
var sifrColor = '#9DA1A6';
var sifrLink = '#AFBD21';
var sifrHover = '#FFFFFF';
var sifrBg = '#616366';
var fontDinLt = sifr_path + "din-lt.swf";
var fontDinRg = sifr_path + "din-rg.swf";
var fontDinMd = sifr_path + "din-md.swf";
var fontDinBd = sifr_path + "din-bd.swf";
var fontDinBlk = sifr_path + "din-blk.swf";

if(typeof sIFR == "function" && sIFR.UA.bHasTransparencySupport){
	var sifrDinLt = named({sFlashSrc : fontDinLt, sColor : sifrColor, sLinkColor : sifrLink, sHoverColor : sifrHover, sBgColor : sifrBg, nPadding : "0,0,0,0", sFlashVars : "textalign=left&offsetLeft=0&offsetTop=0&underline=true", sWmode : "transparent"});
	var sifrDinRg = named({sFlashSrc : fontDinRg, sColor : sifrColor, sLinkColor : sifrLink, sHoverColor : sifrHover, sBgColor : sifrBg, nPadding : "0,0,0,0", sFlashVars : "textalign=left&offsetLeft=0&offsetTop=0&underline=true", sWmode : "transparent"});
	var sifrDinMd = named({sFlashSrc : fontDinMd, sColor : sifrColor, sLinkColor : sifrLink, sHoverColor : sifrHover, sBgColor : sifrBg, nPadding : "0,0,0,0", sFlashVars : "textalign=left&offsetLeft=0&offsetTop=0&underline=true", sWmode : "transparent"});
	var sifrDinBd = named({sFlashSrc : fontDinBd, sColor : sifrColor, sLinkColor : sifrLink, sHoverColor : sifrHover, sBgColor : sifrBg, nPadding : "0,0,0,0", sFlashVars : "textalign=left&offsetLeft=0&offsetTop=0&underline=true", sWmode : "transparent"});
	var sifrDinBlk = named({sFlashSrc : fontDinBlk, sColor : sifrColor, sLinkColor : sifrLink, sHoverColor : sifrHover, sBgColor : sifrBg, nPadding : "0,0,0,0", sFlashVars : "textalign=left&offsetLeft=0&offsetTop=0&underline=true", sWmode : "transparent"});
	var sifrH4 = named({sFlashSrc : fontDinBd, sColor : sifrColor, sLinkColor : sifrLink, sHoverColor : sifrHover, sBgColor : sifrBg, nPadding : "0,0,0,0", sFlashVars : "textalign=left&offsetLeft=0&offsetTop=0&underline=true", sCase:"upper", sWmode : "transparent"});
}
*/

/*
////////////////////////////////////
jQUERY FUNCTIONS
///////////////////////////////////
*/

$j(document).ready(function(){
	//SIFR
	/*
	if(typeof sIFR == "function" && sIFR.UA.bHasTransparencySupport){
		sIFR.replaceElement("h1",sifrDinBd);
		sIFR.replaceElement("h2",sifrDinBd);
		sIFR.replaceElement("h3",sifrDinBd);
		sIFR.replaceElement("h4",sifrH4);
	}
	*/
	//ADD CLASS TO IMAGES
	$j('img[align=left],img[align=right]').each(function(){
		var align = $j(this).attr('align');
		if (align == 'left' && !$j(this).hasClass('left'))
			$j(this).addClass('left');
		if (align == 'right' && !$j(this).hasClass('right'))
			$j(this).addClass('right');
	});
	//SEARCH
	$j('#search-field')
		.each(function(){
			if($j(this).val() == '') {
				$j('#search-text').text('Enter your search');
			}
		})
		.blur(function(){
			if($j(this).val() == '') {
				$j(this).css({ backgroundColor:'transparent' });
				$j('#search-text').text('Enter your search');
			}
		})
		.focus(function(){
			$j(this).css({ backgroundColor:'#9DA1A6' });
		});
	//HOME ROLLOVERS
	$j('div.thumb-img')
		.each(function(index){
			var orig = $j(this).css('backgroundImage').toString();
			var origArrLen = orig.split('/').length;
			var getLgImg = 'http://www.roddyscheer.com/photo/'+orig.split('/')[origArrLen-2]+'/' + orig.split('/')[origArrLen-1].replace(/\)/g,'').replace(/_tn/g,'');
			var thisOne = index;
			$j(this).data('bgimg','url('+getLgImg+')');
			loadImgs(getLgImg);
			if(index == 0) {
				$j('div.thumb-pic div.thumb-frame').eq(index).show();
				$j('div.thumb-pic div.graybar').eq(index).show();
			}
			$j(this).find('a').each(function(){
				//$j('#index').html($j('#index').html()+'<br>'+$j(this).attr('href')+' / '+ thisOne);
				$j(this)
					.hover(
						function(){
							$j('#home-slides div.largepic img').css({ backgroundImage:'none' }).css({ backgroundImage:$j(this).parent().data('bgimg') });
							$j('#home-slides div.largepic a').attr('href',$j(this).attr('href'));
							$j('div.thumb-pic div.thumb-frame:visible').hide();
							$j('div.thumb-pic div.graybar:visible').hide();
							$j('div.thumb-pic div.thumb-frame').eq( thisOne).show();
							$j('div.thumb-pic div.graybar').eq( thisOne).show();
						},
						function(){
							
						}
					);
			}).end()
		});
	//SEARCH LINKS
	//$j('#links').html(getText());
});

function loadImgs(url){
	var newImg = new Image();
	newImg.onload = $j('#index').text(url + ' & height is: '+newImg.height+' & complete is: '+newImg.complete);
	newImg.src = url;
}
function getText(){
	var text = '<a href="#">Back</a> &nbsp; ';
	for(i=1;i<136;i++)
		text = text + '<a href="#">'+i+'</a> &nbsp; ';
	text = text + '<a href="#">Next</a>';
	return text;
}
