var mdiv = 'blank_receiver';
var tmpvar = '';
//expands and retracts narrow column content*******************************************************************
function expander(id1,id2){
	obj1 = document.getElementById(id1);
	obj2 = document.getElementById(id2);
	if (obj2.childNodes[0].data =='more'){
		i=obj1.style.height;
		obj1.style.height='100%';
		obj2.childNodes[0].data = 'less';
	}
	else {
		obj1.style.height=i;
		obj2.childNodes[0].data = 'more';
	}
}
//validation for ask our expert form****************************************************************************
function askit(form){
	if(form.name.value==""){
		alert('Please enter your name.  ');
		form.name.focus();
	}
	else if (form.email.value==""){
		alert('Please enter your email address.  ');
		form.email.focus();
	}
	else if (isEmail(form.email.value)==false){
		alert('Please enter a valid email address.  ');
		form.email.select();
		return false;
	}
	else if(form.question.value==""){
		alert('Please enter a comment or question.  ');
		form.question.focus();
	}
	else {
		form.submit();
	}
}
//validation for email addresses***********************************************************************************
function isEmail(str) {
  //return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

//validation for sales questions************************************************************************************
function validate_question(form){
	if (form.support.value == ''){
		alert('Please tell us how we can help you.  ');
		form.support.focus();
		return false;
	}
	else if (form.name.value == ''){
		alert('Please enter your Name.  ');
		form.name.focus();
		return false;		
	}
	else if (form.org.value == ''){
		alert('Please enter the name of your Organization.  ');
		form.org.focus();
		return false;		
	}
	else if (form.email.value == ''){
		alert('Please enter your Email Address.  ');
		form.email.focus();
		return false;		
	}
	else if (isEmail(form.email.value)==false){
		alert('Please enter a valid Email Address.  ');
		form.email.select();
		return false;
	}
	else if (form.phone.value == ''){
		alert('Please enter your Phone Number.  ');
		form.phone.focus();
		return false;		
	}
	else if (form.country.value < 1){
		alert('Please select your Country.  ');
		form.country.focus();
		return false;		
	}
	return true;
}
//thumbnail scroller***********************************************************************************
function scroller(id,way,px){
	if (way=='right'){
		margin=document.getElementById(id).style.marginLeft.substring(0,document.getElementById(id).style.marginLeft.length-2);
		document.getElementById(id).style.marginLeft=margin-px + 'px';		
	}
	else {
		margin=document.getElementById(id).style.marginLeft.substring(0,document.getElementById(id).style.marginLeft.length-2);
		if (margin >= 0){
			margin=0;
		}
		else{
		document.getElementById(id).style.marginLeft=margin*1+px*1 + 'px';		
		}
	}
}
// returns random number between 1 and passed variable
function getRandom(upto){
   return (Math.round(Math.random()*(upto-1)))+1;
}
// Loads random images
function rand_image(image_name,num){
	//alert(num);
	document.getElementById(image_name).src='images/index' + getRandom(num) + '.jpg';
}

function reload_quick(){
	if (document.quick.back_refresh.value==1){
		location.replace('/33');
		//location.href='/33';
	}
}
function addLoadListener(fn){
	if (typeof window.addEventListener != 'undefined'){
		window.addEventListener('load', fn, false);
 	}
 	else if (typeof document.addEventListener != 'undefined'){
   		document.addEventListener('load', fn, false);
	}
 	else if (typeof window.attachEvent != 'undefined'){
   		window.attachEvent('onload', fn);
 	}
 	else {
   		var oldfn = window.onload;
   		if (typeof window.onload != 'function'){
     		window.onload = fn;
   		}
   		else {
     		window.onload = function(){
       			oldfn();
       			fn();
     		};
   		}
 	}
}
//find element position from quirksmode
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

//add file into the head
function add_scripts(file){
	var head = document.getElementsByTagName('head').item(0)
	var scriptTag = document.getElementById('loadScript');
	if(scriptTag) head.removeChild(scriptTag);
	script = document.createElement('script');
	script.src = file;
	script.type = 'text/javascript';
	script.id = 'loadScript';
	head.appendChild(script)
}  

function load_calendar(field){
	Calendar.setup({
		inputField     :    field,   // id of the input field
		ifFormat       :    "%m/%d/%Y",       // format of the input field
		showsTime      :    false,
		cache:true,
		weekNumbers:true
	});
}


function menu_search(form,str,menu){
	search_string = str.toUpperCase();
	text_length = search_string.length;
	var i=document.getElementById(menu).options.length;
	var e=0;
	do {
		test_item = document.getElementById(menu).options[e].text;
		match_item = test_item.substr(0, text_length).toUpperCase();	
		if(search_string == match_item){
			document.getElementById(menu).selectedIndex = e;
			break;
		}
		e++;
	}
	while (--i);
}

//http://www.expertsforge.com/Web-Development/Tutorial-217.asp
function Left(str, n)
{
   if (n <= 0)
         return "";
   else if (n > String(str).length)
         return str;
   else
         return String(str).substring(0,n);
}


function kill_tiny_mces(){
	tinytokill = document.getElementsByTagName("iframe");
	start = 0;
	if(tinytokill.item(0) != null && tinytokill.item(0).id == ''){start = 2};
	if(tinytokill.length > start){
		for(i=start;i<=tinytokill.length;i++){
			if(tinytokill.item(0).id.length > 4){
				tinyMCE.execCommand('mceRemoveControl', false, Left(tinytokill.item(0).id,tinytokill.item(0).id.length-4));
			};
		}
	kill_tiny_mces()
	}
}

function kill_tiny_mces2(){
	tinytokill = document.getElementsByTagName("iframe");
	if(tinytokill.length > 2){
		for(i=2;i<=tinytokill.length;i++){
				tinyMCE.execCommand('mceRemoveControl', false, Left(tinytokill.item(0).id,tinytokill.item(0).id.length-4));
		}
	kill_tiny_mces2()
	}
}


function dumpProps(obj, parent) {
   // Go through all the properties of the passed-in object
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to
      // build the message. Message includes i (the object's property name)
      // then the object's property value on a new line
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they
      // click "CANCEL" then quit this level of recursion
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object
      if (typeof obj[i] == "object") {
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}

function myCustomOnChangeHandler(inst) {
	tinyMCE.triggerSave(false,true);
}

function inittiny(ht){
	var h = (!ht)?'400px':ht;
	tinyMCE.init
		({
		theme : "advanced",
		//height: '400',
		mode : "specific_textareas",
		editor_selector : "tiny_area",
		onchange_callback : "myCustomOnChangeHandler",
		plugins : "table,fullscreen,emotions,contextmenu,paste",
		theme_advanced_buttons1 : "bold,italic,underline,format,separator,bullist,numlist,separator,link,unlink,separator,image,separator,table,hr,charmap,h1,separator,code,fullscreen,help",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		setup : function(ed) {
			ed.onClick.add(function(ed) {
				$('#'+ed.id+'_ifr').height(h);
				//alert('#'+ed.id+'_ifr > body');
				$('#'+$(this).attr("id")+"_savebutton").html('Save Me!').css({'color':'#cc0033','font-weight':'bold'});
				document.getElementById(ed.id+'_ifr').contentDocument.getElementById('tinymce').setAttribute('spellcheck','true');
	//			alert($('#'+ed.id+'_ifr').contents().('#tinymce').html());
			})
		},
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_styles:"tgray = tgray",
		valid_elements : "a[href],strong/b,em/i,br,p[*],table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],li,ol,ul,strike,img[src|height|width|style],h2[style],h3[style],input[*],form[*],div[*],button[*],sub[*],sup[*]",
		fullscreen_settings : {
			theme_advanced_buttons1 : "bold,italic,underline,format,separator,bullist,numlist,separator,link,unlink,separator,image,separator,table,hr,charmap,h1,separator,code,fullscreen",
			//valid_elements : "a[href],strong/b,em/i,br,p,table,tr,td,li,ol,ul,strike,img[src|height|width]"
		paste_create_paragraphs : true,
		paste_create_linebreaks : true,
		paste_use_dialog : true,
		paste_auto_cleanup_on_paste : true,
		paste_convert_middot_lists : false,
		paste_unindented_list_class : "unindentedList",
		paste_convert_headers_to_strong : false,
		paste_remove_styles : true,
		paste_insert_word_content_callback : "convertWord",
		paste_strip_class_attributes: "all"
		}
	})
}

function convertWord(type, content) {
	switch (type) {
		// Gets executed before the built in logic performes it's cleanups
		case "before":
			//content = content.toLowerCase(); // Some dummy logic
			break;

		// Gets executed after the built in logic performes it's cleanups
		case "after":
			//content = content.toLowerCase(); // Some dummy logic
			break;
	}

	return content;
}

function stripVowelAccent(str)
{
var s=str;

var rExps=[ /[\xC0-\xC2]/g, /[\xE0-\xE2]/g,
/[\xC8-\xCA]/g, /[\xE8-\xEB]/g,
/[\xCC-\xCE]/g, /[\xEC-\xEE]/g,
/[\xD2-\xD4]/g, /[\xF2-\xF4]/g,
/[\xD9-\xDB]/g, /[\xF9-\xFB]/g ];

var repChar=['|A|','|a|','|E|','|e|','|I|','|i|','|O|','|o|','|U|','|u|'];

for(var i=0; i<rExps.length; i++)
s=s.replace(rExps[i],repChar[i]);

return s;
}

function inittiny2(){
	tinyMCE.init
		({
		theme : "advanced",
		mode : "specific_textareas",
		editor_selector : "hist_tiny_area",
		onchange_callback : "myCustomOnChangeHandler",
		plugins : "table,fullscreen,emotions,contextmenu",
		theme_advanced_buttons1 : "bold,italic,underline,format,separator,bullist,numlist,separator,link,unlink,separator,table,hr,charmap,h1,separator,code,fullscreen",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		valid_elements : "a[href],strong/b,em/i,br,p[*],table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],li,ol,ul,strike,img[src|height|width|style],h2[style],h3[style],input[*],form[*],div[*],button[*]",
		fullscreen_settings : {
			theme_advanced_buttons1 : "bold,italic,underline,format,bullist,numlist,link,unlink,tablecontrols,hr,charmap,emotions,code,fullscreen",
			//valid_elements : "a[href],strong/b,em/i,br,p,table,tr,td,li,ol,ul,strike,img[src|height|width]"
		paste_create_paragraphs : true,
		paste_create_linebreaks : true,
		paste_use_dialog : true,
		paste_auto_cleanup_on_paste : true,
		paste_convert_middot_lists : false,
		paste_unindented_list_class : "unindentedList",
		paste_convert_headers_to_strong : false,
		paste_remove_styles : true,
		paste_insert_word_content_callback : "convertWord",
		paste_strip_class_attributes: "all"
		}
		});
	
}

function toggle_admin_box(){
	$('#admin_tool_box').toggle();
}

function send_tooldisplay(toggle){
	okit = confirm('The page will need to be refreshed before the admin state may be changed. \nOk to refresh?');
	if(okit == true){
		document.cookie= 'loadadmin='+toggle+'; expires = 1/1/2038;';
		document.cookie= 'LOADADMIN='+toggle+'; expires = 1/1/2038;';
		location.reload(true);
	}else{
		if($('#changeadminload').attr("checked") == true){
			$('#changeadminload').attr("checked",'');	
		}else{
			$('#changeadminload').attr("checked",'checked');	
		}
	}
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Today's Date 
function todaydate(){
	var months=new Array(13);
	months[1]="January";
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";
	
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	
	if ((navigator.appName == "Microsoft Internet Explorer") && (year < 2000)){ 
		year="19" + year; 
	}
	if (navigator.appName == "Netscape"){
		year=1900 + year;
	}
	var d = lmonth + " " + date + ", " + year;
	return d;
}


function imageswap(img,id){
	var image = img.src;
	var image_name = image.substring(0,image.length-4);
	var image_ext = image.substring(image.length-4,image.length);
	if (id == 1){
		if (document.getElementById('bigimg').style.display=='none'){
			document.images.bigimg.src = image_name+'-b'+image_ext;
			document.getElementById('bigimg').style.display='block';
			document.getElementById('litimg').innerHTML='&laquo;click to hide big image&raquo;'
		}
		else {
			document.getElementById('bigimg').style.display='none';
			document.getElementById('litimg').innerHTML='&laquo;click image to enlarge&raquo;'
		}
	}
	else {
		if (image_name.substring(image_name.length-2,image_name.length)=='-b'){
			img.src = image_name.substring(0,image_name.length-2) + image_ext;
		}
		else {
			img.src = image_name + '-b' + image_ext;
		}
	}
}
//tab mouseovers**************************************************************************************
function tab_over(tab){
	for (i=1;i<10;i++){//tab_out any existing tabs.
		if(document.getElementById('tab'+ i) && document.getElementById('tab'+ i).style.height=='27px'){
			tab_out(document.getElementById('tab'+ i));
			break;
		}
	}
	tab.style.height='27px';
	tab.style.marginTop='0';
}
function tab_out(tab){
	tab.style.height='20px';
	tab.style.marginTop='7px';
}
function tabset(tab,act,num){
	switch (act){
		case "expand_all":
			for (x=1;x<=num;x++){
				if (document.getElementById('tab'+ x).style.color=='#999999' || document.getElementById('tab'+ x).style.color=='rgb(153, 153, 153)'){
					continue;
				}
				document.getElementById('tab_'+ x).style.display='block';
				document.getElementById('tab'+ x).style.visibility ='hidden';
			}
			document.getElementById('exp_id').style.display='none';
			document.getElementById('col_id').style.display='block';
			break;
		case "collapse_all":
			for (x=2;x<=num;x++){
				document.getElementById('tab_'+ x).style.display='none';
				document.getElementById('tab'+ x).style.visibility ='visible';			
			}
			document.getElementById('tab_1').style.display='block';
			document.getElementById('tab1').style.visibility ='visible';			
			document.getElementById('col_id').style.display='none';
			document.getElementById('exp_id').style.display='block';
			break;
		default://front
			if (document.getElementById('tab'+ tab).style.color=='#999999' || document.getElementById('tab'+ tab).style.color=='rgb(153, 153, 153)'){
				return false;
			}
			for (x=1;x<=num;x++){
				document.getElementById('tab_'+ x).style.display='none';
				//document.getElementById('tab'+ x).style.color='#000000';	
				document.getElementById('tab' + x).style.height='20px';
			}
			if (tab==5){
				document.getElementById('kbase').src='../kbase/knowbase2.cfm?term=' + prodid.split('-L')[0] + '&filter=all&sortbox=order by custom2 desc';
			}
			document.getElementById('tab_' + tab).style.display='block';
			document.getElementById('tab'+ tab).style.height='27px';
			document.getElementById('tab'+ tab).style.marginTop='0';
			//document.getElementById('tab'+ tab).style.color='#000066';	
		}
}

function elmLoop(formm,ajax_nme,showunchecked){
	var onname = '';
	valstring = ajax_nme;
	theForm = document[formm];
	
	if(theForm.elements == undefined){
		return false;	
	}
	for(i=0; i<theForm.elements.length; i++){
		var alertText = ""
		
		if(theForm.elements[i].type == "text" || theForm.elements[i].type == "textarea" || theForm.elements[i].type == "button"){
			if(theForm.elements[i].value != ''){
				valstring = valstring+'&'+theForm.elements[i].name+'='+ theForm.elements[i].value;	
			}else{
				if(theForm.elements[i].title.length > 0){
					alert(theForm.elements[i].title);
				}else{
					alert('Please provide the requested information');
				}
				theForm.elements[i].focus();
				return false;
			}
		}
		else if(theForm.elements[i].type == "password"){
			if(theForm.elements[i].value == ''){
				if(theForm.elements[i].title.length > 0){
					alert(theForm.elements[i].title);
				}else{
					alert('Please provide the requested information');
				}
				theForm.elements[i].focus();
				return false;
			}
			valstring = valstring+'&'+theForm.elements[i].name+'='+ theForm.elements[i].value;	
		}
		else if(theForm.elements[i].type == "hidden"){
		valstring = valstring+'&'+theForm.elements[i].name+'='+ theForm.elements[i].value;	
		}
		else if(theForm.elements[i].type == "checkbox" || theForm.elements[i].type == "radio"){
			if(showunchecked != 1){
				if(theForm.elements[i].checked == true){
					if(onname != theForm.elements[i].name){
						onname = theForm.elements[i].name;	
						valstring = valstring+'&'+theForm.elements[i].name+'='+ theForm.elements[i].value;	
					}else{
						valstring = valstring +','+ theForm.elements[i].value;
					}
				}
			}else{
				if(onname != theForm.elements[i].name){
					onname = theForm.elements[i].name;	
					valstring = valstring+'&'+theForm.elements[i].name+'='+ theForm.elements[i].checked;
				}else{
					valstring = valstring +','+ theForm.elements[i].checked;
				}
			}
		}else if(theForm.elements[i].type == "select-one"){
			valstring = valstring +'^'+ theForm.elements[i].options[theForm.elements[i].selectedIndex].text;
		}
	}
	return valstring;
} 

function preview_it(id){
	$('#blank_reciever').css({'position': 'absolute', 'top':'100','background':'#FFFFFF','display':'block'}).html('<div style="padding:20px; border:solid 1px; text-align:center;"><img src="indd/a-'+id+'.png" id="previmg" /><br /><a href="javascript:void(0);" onclick="close_it();">close</a></div>');
	move_it();
	$('#shell_fix_wide').fadeTo(1,0.2);
	$('#shell_bot_wide').fadeTo(1,0.2);
}

function position_pop(){
	divid = mdiv;
	divwidth = document.getElementById(divid).offsetWidth;
	windowwidth = window.innerWidth;
	leftit = windowwidth-divwidth;
	if(isNaN(leftit) == false){
		document.getElementById(divid).style.left=leftit*.5+'px';
		divheight = document.getElementById(divid).offsetHeight;
		windowheight = window.innerHeight;
		topit = windowheight-divheight;
		if(topit >= 0){
			document.getElementById(divid).style.top =topit*.5+window.pageYOffset+'px';
			//document.getElementById(divid).style.top ='90px';
		}else{
			document.getElementById(divid).style.top = '60px';
		}
	}else{
		windowwidth = $(window).width();
		leftit = windowwidth-divwidth;
		document.getElementById(divid).style.left=leftit*.5+'px';
		divheight = document.getElementById(divid).offsetHeight;
		windowheight = $(window).height();
		topit = windowheight-divheight;
		document.getElementById(divid).style.top = '60px';
	}
	document.getElementById(mdiv).style.visibility = 'visible';
}

function move_it(div,speed){
	if(speed == undefined){
		speed = 300;	
	}
	if(div == undefined){
		div = 'blank_reciever';	
	}
	mdiv = div;
	//document.getElementById(mdiv).style.visibility = 'hidden';
	setTimeout('position_pop();',speed);
}

function close_it(){
	displayit('blank_reciever');
	$('#shell_fix_wide').fadeTo(1,1);
	$('#shell_bot_wide').fadeTo(1,1);
}


function copy_date(valu,curfield,getfield){
	if(valu == ''){
		$(curfield).value = $(getfield).value;
	}
}

//sets the style of whatever div is passed to display or hide
function displayit(id,state){
	if(state == 1){//1 = display it
		document.getElementById(id).style.display = 'block';	
	}else{//else hide it
		document.getElementById(id).style.display = 'none';	
	}
}

function more_images(type,id){
	$.post("action.cfm", { vars: "more_images",type:type,id:id },
	function(data){
		$('body').prepend('<div id="popdiv"><div id="popclose" onclick="close_pop();"></div><div id="poptitle">Images</div><div id="popcontent">&nbsp;</div></div><div id="popback">&nbsp;</div>');
		if(jQuery.browser.version == 6.0 && jQuery.browser.msie == true){
			$('body').css({'width':'100%','height':'100%'});
			$('#popback').css({'position':'absolute'});
			$('#popdiv').css({'position':'absolute'});
		}
		move_it('popdiv',0);
		$("#popcontent").html(data);
		$('#popback').fadeTo(500,0.7,function(){$('#popdiv').fadeTo(250,1.0);});
	});
}

function more_chngimage(id,caption){
	$("#image").html('<img src="/images/b-'+id+'.png"><div class="img_caption">'+caption+'</div>');	
}

function close_pop(){
	$('#popdiv').fadeTo(100,0.1); 
	$('#popback').fadeTo(250,0.1,function(){
		if(jQuery.browser.version == 6.0 && jQuery.browser.msie == true){
			$('body').css({'width':'','height':''});
		}
		$('#popback').remove();
		$('#popdiv').remove();
	});
}

function default_prod_view(viewid,hideafter){
	$.post("/cc_action.cfm", { vars: "default_prod_view",viewid:viewid },
	function(data){
		$('#prod_defaultview').html('<img src="images/site/check.png" alt="Default Page View" align="absmiddle" id="prod_defaultview_img" /> Default view updated');
		if(hideafter){
			setTimeout('$("#prod_defaultview").empty()',3000);	
		}
	});
}

function add_quickquote(prodid){
	$.post("action.cfm", { vars: "add_quickquote",prodid:prodid },
	function(data){
		tmpvar = $('.prod_info_box').html();
		$('.quick_quote_links').attr({'href':'/quick-quote','onclick':''}).css('color','#000000');
		$('#add_quickquote_txt').html('View Quick Quote');
		$('#add_quickquote_img').attr('src','images/site/check.png');
		$('.prod_info_box').html(data);
	});
	return false;
}

//new product component display for case studies, rotates through them
function fade_cs(show,playcs){	
	if(show > maxcs){
		show = maxcs;
	}else if(show < 1){
		show = 1;
	}							
	if(show <= maxcs && show > 0){
		for(i=1;i<=maxcs+1;i=i+1){
			$('#cs_'+i).fadeOut(0);
		}
		fadenext = oncur+1;
		
		$('#cs_'+oncur).fadeOut(200);
		$('#cs_'+show).fadeIn(400);
		$('#cs_'+fadenext).fadeIn(400);
		oncur = show*1;
		change_cs_navbuttons(show);
		if(playcs == 1 && playcsvar == 1){
			setTimeout('cs_rotater()',10000);
		}else{
			playcsvar = 0;
		}
	}
}

//part of the rotation function
function cs_rotater(){
	if((oncur*1) +1 <= maxcs){
		oncur = oncur + 1;
	}else{
		oncur = 1*1;
	}
	if(playcsvar == 1){
		fade_cs(oncur,1);
	}
}

//more of the rotation function, modifies the navigation buttons
function change_cs_navbuttons(onnum){
	if(oncur ==1){
		//$('#cs_button_l').css('color','#CCCCCC');
		//$('#cs_button_1').css('background-image','url(/images/site/toolbar-back.png)');
		//$('#cs_button_2').css('background-image','url(/images/site/toolbar-back-dark.png)');
	//	$('#cs_button_3').css('background-image','url(/images/site/toolbar-back-dark.png)');
		$('#cs_button_1').html('1').css({'border':'solid 1px #d6d6d6','background-color':'#f3f3f3'});
		$('#cs_button_2').html(2).css({'border':'','background-color':''});
		$('#cs_button_3').html(3).css({'border':'','background-color':''});
	}else if(oncur != maxcs){
		//math = (oncur*1)-1+i;
		$('#cs_button_l').css('color','#000000');
		$('#cs_button_r').css('color','#000000');
		$('#cs_button_1').html(oncur*1-1).css({'border':'','background-color':''});
		$('#cs_button_2').html(oncur).css({'border':'solid 1px #d6d6d6','background-color':'#f3f3f3'});
	//	$('#cs_button_1').css('background-image','url(/images/site/toolbar-back-dark.png)');
	//	$('#cs_button_2').css('background-image','url(/images/site/toolbar-back.png)');
	//	$('#cs_button_3').css('background-image','url(/images/site/toolbar-back-dark.png)');
		$('#cs_button_3').html(oncur*1+1);
	}else{
		$('#cs_button_r').css('color','#CCCCCC');
		$('#cs_button_1').css({'border':'','background-color':''});
		$('#cs_button_2').css({'border':'','background-color':''});
		$('#cs_button_3').css({'border':'solid 1px #d6d6d6','background-color':'#f3f3f3'});
		$('#cs_button_'+i).attr('onclick','play=0;fade_cs('+i+',0);').html(i).css({'border':'solid 1px #d6d6d6','background-color':'#f3f3f3'});
	}
}

//oct 8th open user preferences window
function open_user_preferences(){
	$.post("cc_action.cfm", { vars: "user_preferences"},
	function(data){
		$('body').prepend('<div id="popdiv" style="width:400px;height:250px"><div id="popclose" onclick="close_pop();"></div><div id="poptitle">Your Preferences</div><div id="popcontent">&nbsp;</div></div><div id="popback">&nbsp;</div>');
		if(jQuery.browser.version == 6.0 && jQuery.browser.msie == true){
			$('body').css({'width':'100%','height':'100%'});
			$('#popback').css({'position':'absolute'});
			$('#popdiv').css({'position':'absolute'});
		}
		move_it('popdiv',0);
		$("#popcontent").html(data);
		$('#popback').fadeTo(500,0.7,function(){$('#popdiv').fadeTo(250,1.0);});
	});
}

// change any cookie oct 9th
function change_cookie(cookiename,newvalue){
	$.post("/cc_action.cfm", { vars: "change_cookie",cookie:cookiename,val:newvalue},
	function(data){
		
	});
}


// Nov 2 2009
function start_admin_interval(){
	setInterval('check_admin_change()',750);		
}

//Nov 2 2009 Admin navigation
//always put the case first
//comma delimeted list, only first in list matters for this statement
function check_admin_change(){
	if(location.hash != urlhash){
		urlhash = location.hash;
		urlvars = urlhash.replace('#','').split(',');
		switch(urlvars[0]){
			case 'cms':
				cms_navigation();
			break;
			case 'tradeshows':
				tradeshow_nav();
			break;
			
			case 'ibrary':
				ibrary_nav();
			break;
		}
	}
}