// JavaScript Document
 
//
// INITIALIZE
//Event.observe(window, 'load', init, false);

var dropdownComboArray = new Array();
var dropdown_togglestatus="closed";
var finalFnameStatus="false";
var tgtul=""; 


//var oMbox=setInterval("loadmbox()",600000); 
var loadingHTML="<img src='"+ROOT+"/common/imgs/long_loader.gif' width='220' height='19' alt='Loading...' titl='Loading...' />";
var ROOT = "";


function init(){
	//rotateBG_init();	
}


function navlnkhover(navelement){
	navelement.style.borderBottom="1px solid white";
}

function navlnkoff(navelement){
	navelement.style.borderBottom="0px solid white";
}

function social_hover(navelement){
	//document.getElementById('#'+navelement.id).delay(200).fadeTo('normal', 1.0);
}

function social_hide(navelement){
	//$('#'+navelement.id).delay(150).fadeOut();
	//document.getElementById('#'+navelement.id).delay(200).fadeTo('normal', 0.1);
}

function openpopup(url, width, height){
	window.open(url, 'ecrm_pop','width='+width+',height='+height); 
}


function socialLoad(navelement){
	switch(navelement.id){
		case "social_youtube":
			window.open(url, 'social_youtube_pop');
		break;
		case "social_facebook":
			window.open('http://www.facebook.com/jstreetbranding', 'social_facebook_pop');
		break;
		case "social_vimeo":
			window.open('http://vimeo.com/user3040631', 'social_vimeo_pop');
		break;
		case "social_twitter":
			window.open('http://twitter.com/#!/jstreetbranding', 'social_twitter_pop');
		break;
	}
}

function catlnkhover(navelement){
	//alert(navelement.id);
	//var tgt_elem='#'.navelement.id+'_IMG';
	
	//document.getElementById('cat_bridge_da_gap_IMG').addClass('category_wrapper_content_hvr');
	//$('cat_bridge_da_gap_IMG').removeClass('category_wrapper_content');
	//$('#'+navelement.id+'_IMG').removeClass('category_wrapper_content').addClass('category_wrapper_content_hvr');
	//alert(navelement.id + '_IMG');
 	//$('cat_bridge_da_gap_overlay').fadeTo("fast", 0.1);

}

function catlnkoff(navelement){
	//$(navelement.id).addClass('category_wrapper_content_hvr');
	//$('#'+navelement.id+'_IMG').removeClass('category_wrapper_content_hvr').addClass('category_wrapper_content');
	//$('#'+navelement.id+'_IMG').delay(350).fadeOut();
	//$('cat_bridge_da_gap_IMG').fadeTo('fast', 0.7, function() {
      // Animation complete.
    //});
}


//
// LOAD A PAGE
function loadpage(url){
	window.location=url;
}

 
//
// GENERIC JS FORM SUBMIT
function submitform(formID){
	document.getElementById(formID).submit();
}

function updateMainImage(contentFocus, ROOT, FOLDERNAME){
	var imageName = contentFocus;
	
	document.getElementById('main_img').innerHTML="<img src=" + ROOT + "/onthestreet/" + FOLDERNAME + "/content/img_main/" + imageName + " width='846' height='420' alt='' />";
}




function fullYear(theDate)
{
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}
   
 
function validData(formID){
	var formHandle=$(formID);
	
	switch(formID){
		case "contactus":
			//
			// REQUIRED FIELDS INCLUDE
			var email=document.getElementById("email").value.toUpperCase();
			var emailconfim=document.getElementById("emailconfirm").value.toUpperCase();
			var fnamevalue=document.getElementById("fname").value;				// NOT NULL
			var lnamevalue=document.getElementById("lname").value;				// NOT NULL	
			
			//
			// NOT REQUIRED...BUT IF ENTERED...NEED TO BE CORRECT
			var phonenumber=document.getElementById("phone").value;				// REQUIRED, STRIP TO DIGITS ONYL?
 			var zipcode=document.getElementById("zip").value;					// 5 DIGITS
			
			if(validReqField(fnamevalue) && validReqField(lnamevalue) && validEmail(email) && checkvalue(phonenumber, 'phonenumber') && checkvalue(zipcode, 'zipcode') && validEmailConfirm(email,emailconfim)){
				return true;
			}else{
				showerror(validReqField(fnamevalue),'fnamevalue');
				showerror(validReqField(lnamevalue),'lnamevalue');
				showerror(validEmail(email),'email');
				showerror(checkvalue(phonenumber, 'phonenumber'),'phonenumber');
				showerror(checkvalue(zipcode, 'zipcode'),'zipcode');
				showerror(validEmailConfirm(email,emailconfim),'emailconfirm');
				return false;
			}
		
		break;	
	}
}

function checkvalue(input_value, input_type){
	if(input_value==""){
		return true;
	}
	
	switch(input_type){
		case "zipcode":	
			return validZip(input_value);
		break;
		
		case "phonenumber":
			return validPhone(input_value);
		break;
	}
}

function showerror(input_status, input_type){
	switch(input_type){
		case "fnamevalue":
			if(!input_status){
				document.getElementById("fname_err").style.borderColor = '#e10000';
				document.getElementById("fname_req").style.display = 'inline';
			}else{
				document.getElementById("fname_err").style.borderColor = '#CCCCCC';
				document.getElementById("fname_req").style.display = 'none';
			}
		break;
		case "lnamevalue":
			if(!input_status){
				document.getElementById("lname_err").style.borderColor = '#e10000';
				document.getElementById("lname_req").style.display = 'inline';
			}else{
				document.getElementById("lname_err").style.borderColor = '#CCCCCC';
				document.getElementById("lname_req").style.display = 'none';
			}
		break;
		case "email":
			if(!input_status){
				document.getElementById("email_err").style.borderColor = '#e10000';
				document.getElementById("email_req").style.display = 'inline';

			}else{
				document.getElementById("email_err").style.borderColor = '#CCCCCC';				
				document.getElementById("email_req").style.display = 'none';

			}
		break;
		case "emailconfirm":
			if(!input_status){
				document.getElementById("emailconfirm_err").style.borderColor = '#e10000';
				document.getElementById("emailconfirm_req").style.display = 'inline';

			}else{
				document.getElementById("emailconfirm_err").style.borderColor = '#CCCCCC';
				document.getElementById("emailconfirm_req").style.display = 'none';
			}
		break;
		case "phonenumber":
			if(!input_status){
				document.getElementById("phone_err").style.borderColor = '#e10000';
				document.getElementById("phone_req").style.display = 'inline';
			}else{
				document.getElementById("phone_err").style.borderColor = '#CCCCCC';
				document.getElementById("phone_req").style.display = 'none';
			}
		break;
		case "zipcode":
			if(!input_status){
				document.getElementById("zip_err").style.borderColor = '#e10000';
				document.getElementById("zip_req").style.display = 'inline';
			}else{
				document.getElementById("zip_err").style.borderColor = '#CCCCCC';
				document.getElementById("zip_req").style.display = 'none';
			}
		break;
	}
}

