function ChooseCountry(sl,txt,sp) {
	var slt = sl[sl.selectedIndex].text;
	if(slt=='Other') {
		document.getElementById(sp).style.visibility='visible';
		document.getElementById(txt).value = '';
	}
	else {
		document.getElementById(sp).style.visibility='hidden';
		document.getElementById(txt).value = '';
	}
}
function fitPicture(){
	imageheight = document.images[0].height;
	imagewidth = document.images[0].width;
	screenwidth = screen.width;
	screenheight = screen.height;
	newimageheight = imageheight + 180;
	newimagewidth = imagewidth + 175;
	if(newimagewidth >= screenwidth)
		newimagewidth = screenwidth -100;
	if(newimageheight >= screenheight)
		newimageheight = screenheight -50;
	if(newimagewidth < 500)
		newimagewidth = 500;
	if(newimageheight < 400)
		newimageheight = 400;
	self.resizeTo(newimagewidth,newimageheight);
}
	
function fitPictureJ(){
	imageheight = document.images[0].height;
	imagewidth = document.images[0].width;
	newimageheight = imageheight + 150;
	newimagewidth = imagewidth + 35;
	self.resizeTo(newimagewidth,newimageheight);
}
	
function CheckMail(txtEmailBox,frmForm) {
	var txtEmail = document.getElementById(txtEmailBox);
	var EMAIL = "^[a-zA-Z0-9_-]+(\.([a-zA-Z0-9_-])+)*@[a-zA-Z0-9_-]+[.][a-zA-Z0-9_-]+([.][a-zA-Z0-9_-]+)*$";
	var re = new RegExp(EMAIL);
	if(!txtEmail.value.match(re)) {
		alert('Email address is not valid.');
		txtEmail.value='';
		txtEmail.focus();
		return false;
	} 
	else 
		document.getElementById(frmForm).submit();
}

// Copies the contact info into the shipping info
function copyInfo() {
	if(document.addressForm.billSame.checked == true) { // they are the same, so copy the information from up above
		document.addressForm.billFirstName.value = document.addressForm.txtFirstName.value;
		document.addressForm.billLastName.value = document.addressForm.txtLastName.value;
		if(document.addressForm.txtEmailaddress) 
			document.addressForm.billEmail.value =  document.addressForm.txtEmailaddress.value;;
		document.addressForm.billCompanyName.value = document.addressForm.txtCompanyName.value;
		document.addressForm.billAddress1.value = document.addressForm.txtAddress1.value;
		document.addressForm.billAddress2.value = document.addressForm.txtAddress2.value;
		document.addressForm.billCity.value = document.addressForm.txtCity.value;
		document.addressForm.billZip.value = document.addressForm.txtZip.value;
		document.addressForm.billFirstName.value = document.addressForm.txtFirstName.value;
		document.addressForm.billCountry.selectedIndex = document.addressForm.ddCountry.selectedIndex ;
		document.addressForm.billPhone.value = document.addressForm.txtPhone.value;
	}
	else {	// They are different, so erase the information from the form
		document.addressForm.billFirstName.value = "";
		document.addressForm.billLastName.value = "";
		document.addressForm.billEmail.value = "";
		document.addressForm.billCompanyName.value = "";
		document.addressForm.billAddress1.value = "";
		document.addressForm.billAddress2.value = "";
		document.addressForm.billCity.value = "";
		document.addressForm.billZip.value = "";		
		document.addressForm.billCountry.selectedIndex = 0;
		document.addressForm.billPhone.value = ""
	}
}

// View Billing Address
function ShowHideBillingAddress() {
	var billingAddress = document.getElementById('BillingAddressSpan');
	if (!document.addressForm.billSame.checked) {
		billingAddress.className = "viewableBillingInfo";
		//document.addressForm.billSame.value = "1";
	}
	else {
		billingAddress.className = "hiddenBillingInfo";
		//document.addressForm.billSame.value = "";
	}
}

// JScript source code

function PopWindow(url,Wh,Ww,idx)
 {
   var Sz="scrollbars,HEIGHT="+Wh+",WIDTH="+Ww + ",resizable=yes"
   window.open(url,"",Sz);
}

function popup(url,name,toolbar,location,directories,status,menubar,scrollbars,resizable,width,height,top,left) {
		var w = window.open(url,name,"toolbar="+toolbar+",location="+location+",directories="+directories+",status="+status+",menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable+",width="+width+",height="+height+",top="+top+",left="+left+"");		
		w.focus();
}

function loginPopup() {
	url= "popup_login.php";
	popup(url,'LoginPopup','no','no','no','no','no','yes','yes',525,523,10,10);	
}

function newsletterPopup() {
	url= "newsletters/indoor.html";
	popup(url,'Newsletter','no','no','no','no','no','yes','no',570,630,0,0);	
}

function loginPopupError() {
	url= "popup_login.aspx?error=noLogin"
	popup(url,'LoginPopup','no','no','no','no','no','yes','yes',525,523,10,10);	
}

function genericPopup(gotoPage) {	
	popup(gotoPage, 'GenericPopup','no','no','no','no','no','yes','yes',532,432,10,10);	
}

function helpPopup(layout) {
	url= "help.aspx?layout=" + layout;
	popup(url,'HelpPopup','no','no','no','no','no','yes','yes',780,500,10,10);	
}

function faqPopup() {
	url= "faq.aspx";
	popup(url,'HelpPopup','no','no','no','no','no','yes','yes',700,500,10,10);	
}


function passPopUp() {
	url="popup_sendpassword.aspx"
	popup(url,'LoginPopup','no','no','no','no','no','yes','yes',525,523,10,10);	
}

function searchTipsPopup() {
	url = "popup_searchTips.aspx"
	popup(url,'SearchTips','no','no','no','no','no','yes','yes',530,500,10,10);	
}

function goHome() {
	top.location="index.php";
}

function ToggleAll(op,checkboxname,cnt) {
	var op =  document.getElementById(op);
	if(op.value == 'Select All') {	
		for(var i=0;i<cnt;i++) {
			var chkbxitem =  document.getElementById(checkboxname + i);
			chkbxitem.checked=true;
		}
		op.value='Deselect All';
	}
	else {
		for(var i=0;i<cnt;i++) {
			var chkbxitem =  document.getElementById(checkboxname + i);
			chkbxitem.checked=false;
		}
		op.value='Select All'
	}		 
}

function ToggleChckBox(checkboxname,cnt) {
	var chkbx =  document.getElementById(checkboxname+'0');

	for(var i=1;i<cnt;i++) {
		var chkbxitem =  document.getElementById(checkboxname + i);
		if(chkbx.checked)
			chkbxitem.checked=true;
		else
			chkbxitem.checked=false;
	}
}
	

function UncheckParentChckBox(chkname,pchkname, cnt) {
	var chkname2 =  document.getElementById(chkname);	
	var allchecked = true;
	if(!chkname2.checked)
		document.getElementById(pchkname+'0').checked=false;
	else {
		for(var i = 1; i < cnt ; i++) {
			if(!document.getElementById(pchkname+i).checked) {
				allchecked = false;
				break;
			}					
		}
		if(allchecked)
			document.getElementById(pchkname+'0').checked=true;				
	}
}
	
function ToggleComBo(chkname,cboname) {
	var chkname =  document.getElementById(chkname);
	var cboname =  document.getElementById(cboname);
	
	for(var i=0;i<cboname.length;i++)
		if(chkname.checked)
			cboname.options[i].selected=true;
		else
			cboname.options[i].selected=false;
}				

function showPicture(imgno,comp) {
	wintitle=escape(comp.replace(/-/gi,'').replace(/ /gi,'')+imgno.replace(/-/gi,'').replace(/ /gi,''));
	imgno = imgno.replace(/-/gi, '#');
	comp = comp.replace(/-/gi,'#');
	window.open("popup_comp.php?imgid="+escape(imgno)+'&company='+escape(comp),wintitle,"resizable=yes,status=no,scrollbars=yes,toolbar=no,titlebar='Dijitalimaj', alwaysRaised,width=500,height=400,left=10,top=0");
	return true;
}
			
function showJImage(img) {
	wintitle=img.replace(/[._]/gi,"");
	window.open("jshow.php?file="+img,wintitle,"resizable=no,status=no,scrollbars=no,toolbar=no,titlebar='DIA', alwaysRaised,width=450,height=450,left=20,top=20");
	return true;
}

function RefreshDisplay(strurl) {
	var pos = strurl.indexOf('&pagesize=');
	if(pos == -1)
		window.document.location = strurl + '&pagesize='+document.getElementById('pagesize')[document.getElementById('pagesize').selectedIndex].value;
	else
		window.document.location = strurl.substring(0,pos) + strurl.substring(pos+12,strurl.length) + '&pagesize='+document.getElementById('pagesize')[document.getElementById('pagesize').selectedIndex].value;
}

function fashPutHref(href) { location.href = href; }
function fashPutTitle(title) { document.title = title; }

function clearCDProviders(){
	if (document.getElementById("ctl00$ContentPlaceHolder1$CBX_ALL_BRAND").checked == true) {
		for (i=0; i < 88; i++) {
		    eval("var CBX=document.getElementById('ctl00$ContentPlaceHolder1$CBL_PARTNERS$" + i + "');")
		    CBX.checked = true;
		}
    }
	else if (document.getElementById("ctl00$ContentPlaceHolder1$CBX_ALL_BRAND").checked == false) {
		for (i=0; i < 88; i++) {
			eval("var CBX=document.getElementById('ctl00$ContentPlaceHolder1$CBL_PARTNERS$" + i + "');")
		    CBX.checked = false;
		}
	}
}
	
function ActivateAllCDProviders(chk){
	var allchecked = true;
	if(!chk.checked)
		document.getElementById("ctl00$ContentPlaceHolder1$CBX_ALL_BRAND").checked = false;
	else {
		for (i=0; i < 88; i++){
		    eval("var CBX=document.getElementById('ctl00$ContentPlaceHolder1$CBL_PARTNERS$" + i + "');")
			if(!CBX.checked) {
				allchecked = false;
				break;
			}
		}
		if(allchecked)
			document.getElementById("ctl00$ContentPlaceHolder1$CBX_ALL_BRAND").checked = true;
	}
}
			
	
//Toggle For Category Group headers
function toggleCatGroupHeader(subjectID) {
	eval("var CatBox=document.getElementById('catbox" + subjectID + "');")
	if (CatBox.checked == true)
		CatBox.checked = false;	
}

	
function toggleNavGroupVisibility( groupIdentifier, groupName) {
	var disp = document.getElementById(groupIdentifier + '-search').style.display;
	var dispimg = document.getElementById(groupIdentifier + '-image').src;
  
	var expandTitle = "Expand " + groupName;
	var collapseTitle = "Collapse " + groupName;
	
	if (disp == 'none') {
		document.getElementById(groupIdentifier + '-image').src = dispimg.replace('arrow_expand.gif', 'arrow_collapse.gif');
		document.getElementById(groupIdentifier + '-image').alt = collapseTitle;
		document.getElementById(groupIdentifier + '-image').title = collapseTitle;
		document.getElementById(groupIdentifier + '-href').alt = collapseTitle;
		document.getElementById(groupIdentifier + '-href').title = collapseTitle;
		document.getElementById(groupIdentifier + '-search').style.display = 'inline';
	}
	else {
		document.getElementById(groupIdentifier + '-image').src = dispimg.replace('arrow_collapse.gif', 'arrow_expand.gif');
		document.getElementById(groupIdentifier + '-image').alt = expandTitle;
		document.getElementById(groupIdentifier + '-image').title = expandTitle;
		document.getElementById(groupIdentifier + '-href').alt = expandTitle;
		document.getElementById(groupIdentifier + '-href').title = expandTitle;
		document.getElementById(groupIdentifier + '-search').style.display = 'none';
	}
	// set the value of the group preference using a cookie
	document.groupDisplayStatus.groupName.value = groupIdentifier;
	document.groupDisplayStatus.groupDisplay.value = document.getElementById(groupIdentifier + '-search').style.display;
	callToServer('groupDisplayStatus', 'setNavBarGroupDisplay')
}

function TglRename(v,box) {
	if(document.getElementById(v).innerHTML == '')
		content = "<form method='POST'><input type='text' name='rename' size=20 maxlength=50 style='font-size:11px;margin: 2px 2px;'><input type='hidden' name='boxID' value='"+box+"'><input type='submit' name='sendrename' class='submitButton' value='Rename' style='background-color: #E88810;	font-size:11px;'></form>";
	else
		content = '';
	document.getElementById(v).innerHTML = content;
}
							
function TglNote(v,box,cnt) {
	if(document.getElementById('switch').value == '0') {
		content = "<form method='POST'><textarea name='note' style='width:180px;height:50px;font-size:11px;margin: 2px 2px;'>"+cnt+"</textarea><input type='hidden' name='boxID' value='"+box+"'><br><input type='submit' name='sendnote' class='submitButton' value='Save Note' style='background-color: #E88810;	font-size:11px;'></form>";
		document.getElementById('switch').value = 1;
	}
	else {
		content = '';
		document.getElementById('switch').value = 0;
	}
		document.getElementById(v).innerHTML = content;
}

function TglCreate(v) {
	var vid = document.getElementById(v);
	if(vid.innerHTML == '')
		content = "<input type='text' name='createlb' id='createlb' maxlength=50 style='font-size:11px;margin: 2px 2px; width:120px;'><input type='button' name='sendcreate' id='sendcreate' class='submitButton' value='Create' style='background-color: #E88810;font-size:11px;' onClick=\"xajax_CreateLightbox(document.getElementById('createlb').value);document.getElementById('createlb').style.visibility='hidden';document.getElementById('sendcreate').style.visibility='hidden';\">";
	else
		content = '';
	vid.innerHTML = content;
}

/* Tips Film  js utilities*/
function embed(fname, fwidth, fheight) {
	document.write('<OBJECT');
	document.write('classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"');
	document.write('width="' + fwidth + '"');
	document.write('height="' + fheight + '"');
	document.write('codebase="http://www.apple.com/qtactivex/qtplugin.cab">');
	document.write('<param name="src" value="'+ fname +'">');
	document.write('<param name="autoplay" value="false">');
	document.write('<param name="controller" value="true">');
	document.write('<param name="loop" value="false">');
	document.write('<param name="scale" value="ToFit">');
	document.write('<EMBED ');
	document.write(' src="'+ fname +'" ');
	document.write(' width="' + fwidth + '" ');
	document.write(' height="' + fheight + '" ');
	document.write(' autoplay="false" ');
	document.write(' controller="true" ');
	document.write(' loop="false" ');
	document.write(' scale="ToFit" ');
	document.write(' pluginspage="http://www.apple.com/quicktime/download/">');
	document.write('</EMBED>');
	document.write('</OBJECT>');
}
function embedfilm(fname, fwidth, fheight) {
	document.write('<OBJECT');
	document.write('classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"');
	document.write('width="' + fwidth + '"');
	document.write('height="' + fheight + '"');
	document.write('codebase="http://www.apple.com/qtactivex/qtplugin.cab">');
	document.write('<param name="src" value="'+ fname +'">');
	document.write('<param name="autoplay" value="true">');
	document.write('<param name="controller" value="true">');
	document.write('<param name="loop" value="true">');
	document.write('<EMBED ');
	document.write(' src="'+ fname +'" ');
	document.write(' width="' + fwidth + '" ');
	document.write(' height="' + fheight + '" ');
	document.write(' autoplay="true" ');
	document.write(' controller="true" ');
	document.write(' loop="true" ');
	document.write(' pluginspage="http://www.apple.com/quicktime/download/">');
	document.write('</EMBED>');
	document.write('</OBJECT>');
}