// JavaScript Document

//catalog_detail.asp++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function btm_lb(dropdown, codeprod)
{
	//subcategory
	var myindex  = dropdown.selectedIndex
	var SelValue = dropdown.options[myindex].value	
			
	var baseURL  = "catalog_detail.asp?codeprod=";
	top.location.href = baseURL+codeprod+"&codelght="+SelValue;
	
	return true;
}

//lightbox.asp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function change_lb(dropdown)
{
	//subcategory
	var myindex  = dropdown.selectedIndex
	var SelValue = dropdown.options[myindex].value	
		
	var baseURL  = "lightbox.asp?codelght=";
	top.location.href = baseURL+SelValue;
	
	return true;
}

function delete_item(codeitem){
	ok = confirm("Are you sure want to delete this item from the selected Lightbox?")
	
	if(ok){
		top.location.href = "delete_item.asp?codeitem="+codeitem;
	}
}

function delete_lightbox(codelght, namelght){
	ok = confirm("Are you sure you want to delete Lightbox, "+namelght+"?");
	
	if(ok){
		top.location.href = "lightbox_delete.asp?codelght="+codelght;
	}
}

//lightbox_rename.asp++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function check_rename(){
	if(document.form.namelght.value ==""){
		alert("Please enter a new Lightbox name.");	
		document.form.namelght.focus();
		return false;
	}
}

//lightbox_select.asp+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function name_lght(){
	document.form.namelght.value= "";
	
	radio_len = document.form.codelght.length
	if(radio_len >0){
		for( i=0 ; i < radio_len ; i++){
			if(document.form.codelght[i].value == "000")
				document.form.codelght[i].checked = true;
		}
	}else{
		document.form.codelght.checked = true;
	}
}
//newacct.asp+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function form_newacct(){
	pref = document.form;
	if(pref.mailcust.value==""){
		alert("Please enter your email address.");	
		pref.mailcust.focus();
		return false;
	}else{
		var theEmail = pref.mailcust.value;
		var atLoc = theEmail.indexOf("@", 1);
		var dotLoc = theEmail.indexOf(".", atLoc+2);
		var len = theEmail.length;
		if(atLoc > 0 && dotLoc > 0 && len > dotLoc+2){
			
		}else{
			alert("Please enter your e-mail address properly.");
			pref.mailcust.focus();
			return false;
		}	
	}
	
	if(pref.passcust.value.length < 6){
		alert("Your password must be at least 6 characters in length.");	
		pref.passcust.focus();
		return false;
	}
	
	if(pref.frstcust.value ==""){
		alert("Please enter you first name.");	
		pref.frstcust.focus();
		return false;
	}
	if(pref.lastcust.value ==""){
		alert("Please enter your last name.");	
		pref.lastcust.focus();
		return false;
	}
	if(pref.telecust.value.length < 10){
		alert("Please enter your phone number.");
		pref.telecust.focus();
		return false;
	}else{
		submitonce(document.form);
		return true;	
	}
	
	
}

//framing_2_list.asp+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\
function change_color(dropdown)
{
	//color
	var myindex  = dropdown.selectedIndex
	var SelValue = dropdown.options[myindex].value	
		
	var baseURL  = "framing_2_list.asp?codecolo=";
	top.location.href = baseURL+SelValue;
	
	return true;
}

//lightbox.asp===========================================================================================
function textCounter(field,maxlimit) {
	if (field.value.length > maxlimit){ // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	}else{
		//cntfield.value = maxlimit - field.value.length;
	}
}


//newacct.asp
function submitonce(theform){
	
	//if IE 4+ or NS 6+
	if (document.all||document.getElementById){
		//screen thru every element in the form, and hunt down "submit" and "reset"
		for (i=0;i<theform.length;i++){
			var tempobj=theform.elements[i]
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
				//disable em
				tempobj.disabled=true
		}
	}
	
	
}
