if(typeof(isK)=='undefined')var isK=0;// this version is used in all site manager templates only
if(typeof(w3ajx)=='undefined')var w3ajx=0;// (sitemanager change)from existing cute_kart_net.js (tells us we can run the ajax commands from here because this srv page is on the same domain as the main site
var w3scIsSecure=(location.href.substring(0,5)=="https"); 
if(typeof(w3url)!='string'||typeof(w3url)=='undefined'||!w3url.substring(0,4)=='http'){// (sitemanager changed, all templates now put in w3url from the template)
	var w3url;// this should come in from user web page but if not, set it to default w3now
	(location.href.substring(0,5)=="https")?w3url="https://www.w3now.com":w3url="http://www.w3now.com";	 
}
var w3scNRand=Math.floor(Math.random()* 9999999); 
function cute_kart_net(){return;}// just the presence of this function tells other JS that this is arelady loaded,  in srv.head.js which is used in /cart/ 
function donothing(){return;}
// INIT SITE MANAGER CALLED FROM ALL SITE MANAGER TEMPLATES //  IS NOW IN USE
function initSiteManager(){
	initForms2014();// this is in addingajax.js for site manager web forms 
	console.log("At initSiteManager()");
	initElevateZoom();// this function is below here  
}
// FOR CART IMAGES THAT NEED ZOOM, only the site manager sites will call this function  
function initElevateZoom(idname){
	// Just put class="elevateZoom" on any image that we want to zoom like; 
	// <img id="zoom_02" class="elevateZoom" src='images/small/image1.png' data-zoom-image="images/large/image1.jpg"/> 
	if(idname){
			console.log("initializing image: #"+idname+" with elevateZoom");
			$('#'+idname).elevateZoom({
				zoomType: "inner",
				cursor: "crosshair",
				zoomWindowFadeIn: 500,
				zoomWindowFadeOut: 750
		});
	}
	else {// all images with this class elevateZoomImg are initiated upon page loads in site manager
			console.log("setting all images elevateZoomImg");
			$('.elevateZoomImg').elevateZoom({// init all zooms upon site manager template page loads 
				zoomType: "inner",
				cursor: "crosshair",
				zoomWindowFadeIn: 500,
				zoomWindowFadeOut: 750
		});
}
}
// preload images from /srv/images
var myimages=[];
function preload(){	 
	for(var i=0;i<preload.arguments.length;i++){
		myimages[i]=new Image();
		myimages[i].src=w3url+"/srv/"+preload.arguments[i]; 
	}
}
// preloaded from brand/srv/ above
preload("images/ajax-loader.gif","images/ajax-loader-bar.gif", "images/deleteIcon2.png", "images/comment_icon.png"); 
 
// preload images from full src urls
function preloadNorm(){
	var preimg=[];
	for(var i=0;i<preloadNorm.arguments.length;i++){
		preimg[i]=new Image();
		preimg[i].src=preloadNorm.arguments[i]; 
	}
} 
function setReturnToShop(theForm){
	if(theForm &&theForm.returnToShop)theForm.returnToShop.value=unescape(location.href);
}
function getElemOffset(what, offsettype){
	return (what.offsetParent)? what[offsettype]+getElemOffset(what.offsetParent, offsettype): what[offsettype];
}
function getElementTopPosition(id){
	if(id&&getContainer(id))return getContainer(id).offsetTop; 
   /* the below returns the offset from the entire document, not the offset from the TD parent */
	//if(getContainer(id))return getElemOffset(getContainer(id), "offsetTop");//+"px";    
    return -1;
}
function getElementLeftPosition(id){
	if(id&&getContainer(id))return getContainer(id).offsetLeft; 
	/* the below returns the offset from the entire document, not the offset from the TD parent */
	//if(getContainer(id))return getElemOffset(getContainer(id), "offsetLeft");//+"px";//getContainer()is in master.js  
	return -1;
}
function positionTopMenuSubs(){
	donothing();// leave forever - needed for sites that were published previously with "positionTopMenuSubs()" called in the templates
} 
// include anylinks for drop down menus on top
 document.write('<sc');document.write('ript src="'+w3url+'/srv/js/anylinkcssmenu.js?cbk='+w3scNRand+'"></s');document.write('cript>'); 
//for conveyor belt images
 document.write('<sc');document.write('ript src="'+w3url+'/srv/js/ConveyorBeltImages.js?cbk='+w3scNRand+'"></s');document.write('cript>');
// for new popup images in css / js
document.write('<slink rel="stylesheet" type="text/css" href="'+w3url+'/srv/css/preview_templates.css">');
 document.write('<sc');document.write('ript src="'+w3url+'/srv/js/loader.js?cbk='+w3scNRand+'"></s');document.write('cript>');
 document.write('<sc');document.write('ript src="'+w3url+'/srv/js/preview_templates.js?cbk='+w3scNRand+'"></s');document.write('cript>');

// vars for create target js vars
var myHeight=self.screen.height-25;
var myWidth=660;
var isResizable=true;    
function sForm(theForm){// pop
	if(!formValidate(theForm))return false;
	createTarget(theForm);
	return true; 
}
function sFormFull(theForm){// full and frame-in
	if(!formValidate(theForm))return false; 
	return true; 
}
function createTarget(form){
	form.target="foobar";// change the target of the form
	var attribs="height="+myHeight+",width="+myWidth+",left=0,top=0,scrollbars=1,menu=0,location=0,toolbar=1,resizable=1,status=1";
	var zwin=window.open("",form.target,attribs);  
	if(typeof(focus)=="function")zwin.focus();
}
function popUpImage(sImgPath, iImgW, iImgH, windo, idescr){
	if(!windo)windo='wr'+Math.floor(Math.random()*10001);// random number 0 - 10000
	var zPopWidth=iImgW+20;
	var zPopHeight=iImgH+75; 
	var hasDescription=(idescr &&idescr.length>0);
	if(hasDescription)zPopHeight=zPopHeight+35;
	 
	// align center screen
	var pTop=(screen.height - (zPopHeight+50))/ 2;// wTop=document.body.scrollTop+50;  
	var pLeft=(screen.width - (zPopWidth+50))/ 2;    
	var sHeader="<!DOCTYPE HTML>\n<html>\n<head>\n<title>Enlarged Image</title>\n<script>window.focus();</script></head>\n<body>\n"; 
	var sFooter="</body></html>";
	var oWin=window.open(windo, null, "width="+zPopWidth+",height="+zPopHeight+",left="+pLeft+",top="+pTop+",directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0"); 
	oWin.document.open();
	oWin.document.write(sHeader);
	if(hasDescription)oWin.document.write("<div align=left style=\"font-family:arial,helvetica,sans-serif;font-size:12px;color:black;margin-bottom:2px;\">"+idescr+"</div>\n");  
	oWin.document.write("<div align=center><IMG SRC=\""+sImgPath+"\" width="+iImgW+" height="+iImgH+" />\n"); 
	oWin.document.write("<div style=\"margin:3px;\"><a href=\"javascript:window.close();\" style=\"font-size:10px;font-weight:normal;font-family:arial,helvetica,sans-serif;color:blue\">CLOSE WINDOW</a></div></div>");
	oWin.document.write(sFooter);
	oWin.document.close(); 
}
function switchCatGroup(group){
	var c=getContainer("navDiv"+group);
	if(!c)return; 
	getContainer("navDivTop").innerHTML=c.innerHTML;
	getContainer("navDivBottom").innerHTML=c.innerHTML;
	getContainer("prodDiv").innerHTML=getContainer("group"+group).innerHTML;
	$('html, body').animate({scrollTop: $('#W3ShoppingCartTop').offset().top}, 400);// scrolls to top on site manager sites 
}
// for site builders with top menu icons "over"
function w3scTopMenuMouseOver(n,url){
	if(!n||!url)return;
	var c=getContainer("TopMenuIcon"+n);
	if(c)c.src=url;
}
// for site managers to change the top menu page we are "on" to class name TopMenuOn 
var topMenuOnTdElemX=null;//global element of the page we are on
var g_currURL=null;
var g_currURL2=null;
var g_onHomepage=false; 
var g_app_URL=null;
var g_app_secureURL=null;
function w3scMarkCurrentPageOnTopMenu(app_URL, app_secureURL){
	if(app_URL)g_app_URL=app_URL.toLowerCase();// set global	
	if(app_secureURL)g_app_secureURL=app_secureURL.toLowerCase();// set global	 
	g_currURL=window.location.href.toLowerCase();// global
	if(g_currURL){
		g_onHomepage=(
			g_currURL==g_app_URL || g_currURL==g_app_URL+"/" || g_currURL==g_app_URL+"/index.cfm" ||
			g_currURL==g_app_secureURL || g_currURL==g_app_secureURL+"/" || g_currURL==g_app_secureURL+"/index.cfm"			
		)
		if(g_currURL.indexOf("blog.cfm")>0)g_currURL2='blog.cfm'; 
		else {
			var urlArr=g_currURL.split("/");
			var last=urlArr.length-1;
			if(urlArr[last].indexOf("index.cfm")==0)g_currURL2=g_currURL.replace("/index.cfm","/");//  if http://www.cutedemo.com/about-us/index.cfm, then make it http://www.cutedemo.com/about-us/ 
		}
	}
	if(isRespSite &&isPho)findMobileTopMenuPlace();// do this when mobile menu is showing
	else  findTopMenuPlace();// no need to go thru all of this if we are on a phone because normal top menu isn't showing anyway	 
}	
function findTopMenuPlace(){
	var arr=document.getElementsByClassName("w3scTopMenu");// gets all top menu td elements 
	if(arr.length==0)return; 
	$(".w3scTopMenu").mouseover(function(){$(this).addClass("TopMenuOver");}); 
	$(".w3scTopMenu").mouseleave(function(){$(this).removeClass("TopMenuOver");});   
	if(g_currURL &&g_app_URL)setTopMenuArr(arr,true);// sets TopMenuOn class to the proper top menu item 		
	// now see if we have any anylinks sub-menu items. If so, add TopMenuOver to them also, and if we did not find the page we are on within the top meny items, then see if we can find it on a submenu item
	arr=document.getElementsByClassName("anylinkSubMenuItem");// gets all mobile menu <li class="anylinkSubMenuItem"" - sub menu drop-down item in anylinks
	if(arr.length==0)return;
	//their site has a mobile menu   
	$(".anylinkSubMenuItem").mouseover(function(){$(this).addClass("TopMenuOver");}); 
	$(".anylinkSubMenuItem").mouseleave(function(){$(this).removeClass("TopMenuOver");});			 
	if(g_currURL&& g_app_URL)setTopMenuArr(arr,false);// &&!topMenuOnTdElemX  we did not find the page we are on within the top menu so let's see if it is on a sub-menu (drop-down)item 
}
function findMobileTopMenuPlace(){// now do mobile menu, if it exists	
	var arr=document.getElementsByClassName("mobilew3scTopMenu");// gets all mobile menu <li class="mobilew3scTopMenu"" - whether sub menu or main menu: both
	if(arr.length==0)return;
	//their site has a mobile menu 		  
	$(".mobilew3scTopMenu").mouseover(function(){$(this).addClass("TopMenuOver");});// add TopMenuOver class to proper Mobile menu item (in case theyare using a tiny device with a mouse that can go "over")
	$(".mobilew3scTopMenu").mouseleave(function(){$(this).removeClass("TopMenuOver");}); 		 
	if(g_currURL)setTopMenuArr(arr,false);// add TopMenuOn class to proper Mobile menu item 
}
function setTopMenuArr(arr, doingTopMenu){
	for(var x=0; x<arr.length; x++){
			if(g_onHomepage){
				if(arr[x].innerHTML.toLowerCase().indexOf(' class="hp"')>0){
						$(arr[x]).addClass("TopMenuOn"); 
						if(doingTopMenu)topMenuOnTdElemX=x; /* mark the global element which page we are ON */ 
						break;
				}
			}
			else if(arr[x].innerHTML.toLowerCase().indexOf(g_currURL)>0 || (g_currURL2 &&arr[x].innerHTML.toLowerCase().indexOf(g_currURL2)>0)){// if one of the urls are found inside the SPAN container, then hightlight it with class TopMenuOn								
					$(arr[x]).addClass("TopMenuOn");  
					//if(!doingTopMenu)alert("setting TopMenuOn class to sub link: '"+arr[x].innerHTML+"'");
					if(doingTopMenu)topMenuOnTdElemX=x; /* mark the global element which page we are ON */
					break;					 
			}//else
	}//for
}
function checkSitemapColumnHeights(){
	var c1=getContainer("sitemapColumn1"); 
	var c2=getContainer("sitemapColumn2");
	var c3=getContainer("sitemapColumn3"); 
	if(c1){var c1Height=$("#sitemapColumn1").height();}
	if(c2){var c2Height=$("#sitemapColumn2").height();}
	if(c3){var c3Height=$("#sitemapColumn3").height();}
	if(c1){
		if(c2&&c3){
				//alert("3 cols: c1 height is " +c1Height+"\nand c2 height is "+c2Height+"\n and c3Height is "+c3Height); 
				if(c1Height >=c2Height &&c1Height >=c3Height){
						c2.style.minHeight=c1Height+"px";
						c3.style.minHeight=c1Height+"px";
				}
				else if(c2Height >=c1Height &&c2Height >=c3Height){
						c1.style.minHeight=c2Height+"px";
						c3.style.minHeight=c2Height+"px";
				}
				else if(c3Height >=c1Height &&c3Height >=c2Height){
						c1.style.minHeight=c3Height+"px";
						c2.style.minHeight=c3Height+"px";
				}
		}
		else if(c2){
			//alert("2 cols: c1 height is " +c1Height+"\n and c2 height is "+c2Height);
			if(c1Height >=c2Height)c2.style.minHeight=c1Height+"px";
			else c1.style.minHeight=c2Height+"px";  
		}
	}
}
function checkPhoStyles(dt,oid){// check global isPhone
	if(typeof(isPho)=='undefined' || typeof(isRespSite)=='undefined' || typeof(isInsiteCart)=='undefined')return; 
	if(typeof(doAjaxCall)!='function')return;  
	if(isInsiteCart &&insiteCartOrderID &&typeof(fillNumberInCart)=='function'){fillNumberInCart(dt,oid);}// this function is in icart/cart.js which ALSO does cookie.scrw 
}
function goTo(url){
	if(!url)return;
	document.location.href=url;
}
var w3sc_smoke;
var w3sc_wheel;
function initSmokeAndWheel(){// runs on every smokeEmOut()
	if(!w3sc_smoke)w3sc_smoke=getContainer("loader-smoke");// global var
	if(!w3sc_wheel){
		w3sc_wheel=getContainer("loader-wheel");// global var
		if(w3sc_wheel){// main body div, need to center on page    
			var L=(screen.width-60)/ 2;
			w3sc_wheel.style.left=L+"px";
		}
	}
}
function w3sc_scrollToTop(speed){
	if(!speed)speed="fast";
	$('html, body').animate({scrollTop: 0}, speed);
}
function smokeEmOut(GoToTop,doWheel,useWheelTop){
	if(GoToTop){$('html, body').animate({scrollTop: 0}, 'fast');}
	initSmokeAndWheel();
	if(w3sc_smoke){
		w3sc_smoke.style.display="block";
		if(doWheel&&w3sc_wheel){
				var wheeltop=190;
				if(useWheelTop)wheeltop=useWheelTop;// use whatever is given
				else if(typeof(isPho)!='undefined'&&isPho)wheeltop=50;// isPhone put wheel 50 from top otherwise it's 190px from top 
				w3sc_wheel.style.top=wheeltop+"px";// usually 190, but for mobile sites, is less
				w3sc_wheel.style.display="block";
		}	 
	}
}
function unSmokeEm(){
	if(w3sc_wheel)w3sc_wheel.style.display="none";  
	if(w3sc_smoke)w3sc_smoke.style.display="none";   
}
/* for sliding and fading divs */
function fadeInDiv(id,delaymill,speed){
	if(!delaymill)delaymill=0;
	if(!speed)speed=800;	
	var idDo="#"+id;
	var c=getContainer(id);
	if(c){
		var idDo="#"+id;  
		$(idDo).delay(delaymill).fadeIn(speed, function(){
		    // Animation complete. 
		}); 
	}
}
function fadeOutDiv(id,delaymill,speed){
	if(!delaymill)delaymill=0;
	if(!speed)speed=800;	
	var idDo="#"+id;
	var c=getContainer(id);
	if(c){
		var idDo="#"+id;  
		$(idDo).delay(delaymill).fadeOut(speed, function(){
		    // Animation complete. 
		});
	}
}
function slideDownDiv(id,delaymill,speed){// $( "#foo").slideUp( 300).delay( 800).fadeIn( 400); When this statement is executed, the element slides up for 300 milliseconds and then pauses for 800 milliseconds before fading in for 400 milliseconds. 
	if(!delaymill)delaymill=0;
	if(!speed)speed=300;	
	var speedPlus10=speed+10;// speed plus 10 miliseconds
	var idDo="#"+id;
	var c=getContainer(id);
	var done=0;
	if(c){
		$(idDo).delay(delaymill).slideDown(speed, "linear", function(){
		    // Animation complete. 
			done=1;
		});
	}
}
function slideUpDiv(id,delaymill,speed){
	if(!delaymill)delaymill=0;
	if(!speed)speed=300;	
	var speedPlus10=speed+10;// speed plus 10 miliseconds
	var idDo="#"+id;
	var c=getContainer(id);
	if(c){
		$(idDo).delay(delaymill).slideUp(speed, "linear", function(){
		    // Animation complete.
			//alert("slide up done");    
			//c.style.display="none";
		}).delay(speedPlus10);// this causes this function to not return to the calling function until it's done, plus 10 miliseconds; 
	}
}
function slideSpace(show, space, delaymill){
	if(!delaymill)delaymill=0;
	if(!space)return; 
	var c=getContainer(space);
	if(c){
		if(show)slideDownDiv(space, delaymill);// bring in the space box with 0 delay		
		else  slideUpDiv(space,delaymill);// hide the div box with 0 delay 
	}
}
function fadeSpace(show, div, delaymill){
	if(!delaymill)delaymill=0;
	if(!div)return; 
	var c=getContainer(div);
	if(c){
		if(show)fadeInDiv(div,delaymill);// bring in the div box with 0 delay
		else  fadeOutDiv(div,delaymill);// hide the div box with 0 delay 
	}
}
function toggleQuickInfo(elem, space){
		if(getContainer(space).style.display=="none"){
			slideSpace(1,space); 
		}
		else {
			//getContainer(space).style.display="none"; 	
			slideSpace(0,space); 
		}	 
}
function isAllNumbers(str){
	if(str.length==0)return false;
	var validNbrs="0123456789";
	var Nbrs=0;
	for(var z=0; z<str.length; z++){
		for(var i=0; i<validNbrs.length; i++){
			if(str.charAt(z)==validNbrs.charAt(i)){
				Nbrs++; 
				break;
			}
		}
	}
	if(Nbrs==str.length)return true;
	return false;
}
//keeps field characters from overflowing : onKeyUp="chkCharsLen(this,#app_nbrBannerTextChars#,fieldtokeepcount,countfieldtype);"
function chkCharsLen(field,desiredNbr,countfield,countfieldtype){
	if(!field)return false; 
	if(field.value.length>desiredNbr)field.value=field.value.substring(0,desiredNbr);
	if(countfield)chrCount(field,countfield,countfieldtype);	 
}
//keeps count of number characters in given field2, shows to user the count
function chrCount(field,field2,countfieldtype){
	if(countfieldtype=="html"){// div or span innerHTML - given: html div or span space ID
		var container=getContainer(field2);
		if(container)container.innerHTML=field.value.length;
	}
	else field2.value=field.value.length;// form field - given: actual form.field	 
}
function showSpace(space){
 	var c=getContainer(space);
	if(c)c.style.display="block"; 
}
function hideSpace(space){
 	var c=getContainer(space);
	if(c)c.style.display="none"; 
}
function checkUncheckField(field,which){// toggle checkboxes or radio button fields
	if(!field)return; 
	if(field[which]){
		if(field[which].checked)field[which].checked=false;
		else field[which].checked=true;
	}
	else if(isK){
		 alert("no field["+which+"]");
	}		 
}
function unzero(field,nbr){
	if(!field)return; 
	if(!nbr)nbr=0;
	if(field.value==nbr)field.value='';
}
function dozero(field,nbr){
	if(!field)return; 
	if(!nbr)nbr=0;
	if(field.value=='')field.value=nbr;
}