/*
////////////////////////////////////
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; }
}

/*
////////////////////////////////////
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*/
		}
	}
}

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

$j(document).ready(function(){
	/*
	/// CONFIGURE sIFR
	*/
	//var fontGothamLt = sifr_path + "gotham-lt-it.swf";
	
	if(typeof sIFR == "function" && sIFR.UA.bHasTransparencySupport){
	//if(typeof sIFR == "function"){
		//var H1Template = named({sFlashSrc : fontGothamBk, sColor : "#135B99", sLinkColor : "#CB5F29", sHoverColor : "#CB5F29", sBgColor : "#FFFFFF", nPadding : "0,0,0,0", sFlashVars : "textalign=left&offsetLeft=0&offsetTop=0&underline=true", sWmode : "transparent", sCase : "upper"});
		//sIFR.replaceElement("#pagetitle h1", H1Template);
	}
	/*
	/// CONFIGURE ALIGNED IMAGES
	*/
	$j('img[align="left"]').addClass('left');
	$j('img[align="right"]').addClass('right');
	//SET COOKIES
	if ($j('body').hasClass('en')) {
		setCookie('lang','en',365,'/' );
	} else if ($j('body').hasClass('jp')) {
		setCookie('lang','jp',365,'/' );
	}
	//deleteCookie('lang');
	if ($j('body').hasClass('main') && getCookie('lang') == 'en') {
		window.location = 'http://www.minekokawamura.com/en/';
	} else if ($j('body').hasClass('main') && getCookie('lang') == 'jp') {
		window.location = 'http://www.minekokawamura.com/jp/';
	}
	//IDX TWEAKS
	$j('link').remove('[href*="www.minekokawamura.idxco.com"]');
	$j('#IDX-main').addClass('clearfix');
	$j('div.IDX-contactForm table td').removeAttr('align');
	$j('div.IDX-contactForm table td input').removeAttr('style');
});