var currentParentMenuContainer;
var currentJsDropdown=null;
var itemCode="";

currentParentMenuContainer=new Array();
/*
currentParentMenuContainer should contain expanded menu IDs when it loads:
currentParentMenuContainer[0] - level 1 expanded menu ID
currentParentMenuContainer[1] - level 2 expanded menu ID
currentParentMenuContainer[2] - level 3 expanded menu ID

This will not automatically expand the menus. This is done in the leftnavbar using stylesheets.
The IDs are used to collapse the menus when the user clicks on other menus
*/
var _fctReturnFalse=new Function ("e", "return false;");
var _fctReturnTrue=new Function ("e", "return true;");

function expandLeftMenu(parentMenuId, level) {
	var style, parentMenuContainer, submenuContainer, prevMenuContainer, expand, classFirstListItem;

	parentMenuContainer=document.getElementById(parentMenuId);
	submenuContainer=document.getElementById(parentMenuId+"_submenu");

	style=getElementCurrentStyle(submenuContainer);
	expand = !(style.display=="block");

	if (expand) //collapse current menu (if any)
	{
		prevMenuContainer=document.getElementById(currentParentMenuContainer[level-1]);
		if (prevMenuContainer && prevMenuContainer!=parentMenuContainer) {
			classFirstListItem=(prevMenuContainer.className.indexOf(new String("first_list_item").toLowerCase())>-1)?"first_list_item":"";
			prevMenuContainer.className=classFirstListItem?classFirstListItem:"";
		}
	}

	classFirstListItem=(parentMenuContainer.className.indexOf(new String("first_list_item").toLowerCase())>-1)?"first_list_item":""
	parentMenuContainer.className=(expand?"expanded":"")+(classFirstListItem?" "+classFirstListItem:"");

	currentParentMenuContainer[level-1]=parentMenuId;
}

function getElementCurrentStyle(element) {
	if (element && element.currentStyle) {
		return element.currentStyle;
	} else {
		if (document.defaultView && document.defaultView.getComputedStyle) {
			return document.defaultView.getComputedStyle(element, null);
		}
	}
}

function domAddEventListener(element, eventName, eventHandler) {
	if (element.attachEvent) {
		element.attachEvent("on"+eventName, eventHandler);
	} else if (element.addEventListener) {
		element.addEventListener(eventName, eventHandler, false);
	}
}

function domRemoveEventListener(element, eventName) {
	if (element.detachEvent) {
		element.detachEvent(eventName);
	} else if (element.removeEventListener) {
		element.removeEventListener(eventName)
	}
}

function showWhereToBuyContainer(a, hideEStoreButton) {
	var arrowImg, containerVisible;

	containerVisible=switchElementVisibility("where_to_buy");
	if (hideEStoreButton) {
		switchElementVisibility("buy_now_estore");
	}

	/*
	INet Change just change the class of <a> element
	Arrow image will take care of itself
	arrowImg=document.getElementById("arrowWhereToBuy");
	arrowImg.src="images/utility_navbar/arrow_"+(containerVisible?"close":"open")+".gif";
	*/

	a.className=containerVisible?"close":"open";
}

function switchElementVisibility(elementId) {
	var element, style;

	element=document.getElementById(elementId);
	// returning for the null element when the element does not exists for buy_noew_estore case.
	if(element==null) {
		return false;
	}
	style=getElementCurrentStyle(element);

	element.style.display=style.display=="none"?"block":"none";

	if (style.display!="none") {
		element.style.zIndex=1000;
	}

	return !(element.style.display=="none");
}

function showOtherProductsList() {
	var otherProductsListContainer, style;

	otherProductsListContainer=document.getElementById("other_products_listing");

	style=getElementCurrentStyle(otherProductsListContainer);

	otherProductsListContainer.style.display=style.display=="block"?"none":"block";
	if (otherProductsListContainer.style.display=="block") {
		otherProductsListContainer.style.zIndex=1100;
		otherProductsListContainer.parentNode.parentNode.style.zIndex=1100;
	}
}

function showJsDropdown(jsDropdownId) {
	var style;
	var dropdown, dropdownContainer;

	dropdown=document.getElementById(jsDropdownId+"_Dropdown");
	style=getElementCurrentStyle(dropdown);

	if (style.display=="block") {
		dropdown.style.display="none";
		currentJsDropdown=null;
	} else {
		if (currentJsDropdown && currentJsDropdown!=dropdown) {
			currentJsDropdown.style.display="none";
			currentJsDropdown.style.zIndex=-1;
		}

		currentJsDropdown=dropdown;
		currentJsDropdown.style.zIndex=1000;
		currentJsDropdown.style.display="block";
		currentJsDropdown.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.zIndex=1000;
		currentJsDropdown.scrollTop=0;
	}
}

function setJsDropdownValue(jsDropdownId, value, text) {
	setJsDropdownDefaultValue(jsDropdownId, value, text);
	showJsDropdown(jsDropdownId)
}

/*INet change just added another function to change default value on load of dropdowm*/

function setJsDropdownDefaultValue(jsDropdownId, value, text) {
	var input, element;

	input=document.getElementById(jsDropdownId);//may be a div or text input
	if (input != null)
		input.value=value;

	element=document.getElementById(jsDropdownId+"_text")
	if (element == null) return;
	switch(element.nodeName.toLowerCase()) {
		case "div":
			element.innerHTML = text;
			element.title=text;
			break;
		case "input":
			element.value=text;
			break;
	}

}

/*INet change just added another function to change default value on load of dropdowm and text*/

function setStateJsDropdownValue(jsDropdownId, jsDropdownIdNew, value, text) {
	var input, element, inputNew;

	input=document.getElementById(jsDropdownId);//may be a div or text input
	if (input != null)
		input.value=value;
	//input.value=text;

	inputNew=document.getElementById(jsDropdownIdNew);//may be a div or text input
	if (inputNew != null)
		inputNew.value=text;

	element=document.getElementById(jsDropdownId+"_text")
	if (element == null) return;
	switch(element.nodeName.toLowerCase()) {
		case "div":
			element.innerHTML = text;
			element.title=text;
			break;
		case "input":
			element.value=text;
			break;
	}

	showJsDropdown(jsDropdownId)
}

function onFocusZipCode(input) {
	if (input.value=="Enter Zip Code") {
		input.value="";
	}
}

function onBlurZipCode(input) {
	if (input.value=="") {
		input.value="Enter Zip Code";
	}
}

function checkProduct(element) {
	var inputId;
	var input, a;

	if (element.nodeName.toLowerCase()=="input")//checkbox clicked
	{
		input=element;
		inputId=element.id;

		a=document.getElementById(inputId+"_Compare");
	}
	else //"Compare" link clicked
	{
		a=element;

		inputId=element.id.replace("_Compare", "");
		input=document.getElementById(inputId);
		input.checked=!input.checked;

	}

	var checkboxesList, hotCompareLinks, numChecked;

	hotCompareLinks=false;
	numChecked=0
	checkboxesList=document.getElementsByTagName("input");

	if(checkboxesList)
	{
		for (var i=0; i<checkboxesList.length; i ++) {
			var input=checkboxesList[i];
			if(input.type!="checkbox") {
				continue;
			}
			if (input.checked) {
				numChecked++;
			}
			if (numChecked>1) {
				hotCompareLinks=true;
			}
		}

		for (var i=0; i<checkboxesList.length; i ++) {
			var input=checkboxesList[i];

			if(input.type!="checkbox") {
				continue;
			}

			inputId=input.id;
			a=document.getElementById(inputId+"_Compare");

			if (!hotCompareLinks) {
				a.className="";
				a.onclick=_fctReturnFalse;
			} else {
				a.className=input.checked?"selected":"activated"
				a.onclick=input.checked?_fctCompareFormSubmit:_fctReturnFalse;
			}
		}

	}
}

/* functions submits the compare_products_form */
var _fctCompareFormSubmit=new Function ("e", "document.compare_products_form.submit(); return false;");

/*advanced search*/
var currentProductCategoryLink=null;
var currentProductCategoryId="testProductCategoryId1";
var currentProductTypeLink=null;
var currentProductTypeId="testProductTypeId1";
var currentProductModelLink=null;
var currentProductModelId="testProductModelId1";
var currentProductFamilyLink=null;
var currentProductFamilyId="testProductFamilyId2";
var currentProductSerieLink=null;
var currentProductSerieId="testProductSerieId2";
function onClickAdvancedSearchCriteria(link, currentLink)
{
	if (currentLink) {
		currentLink.className="";
	}

	link.className="selected";


}
function onClickProductCategory(link)
{
	if (!currentProductCategoryLink && currentProductCategoryId) {
		currentProductCategoryLink=document.getElementById(currentProductCategoryId);
	}
	onClickAdvancedSearchCriteria(link, currentProductCategoryLink);
	currentProductCategoryLink=link;
}
function onClickProductType(link)
{
	if (!currentProductTypeLink && currentProductTypeId) {
		currentProductTypeLink=document.getElementById(currentProductTypeId);
	}
	onClickAdvancedSearchCriteria(link, currentProductTypeLink);
	currentProductTypeLink=link;
}
function onClickProductModel(link)
{
	if (!currentProductModelLink && currentProductModelId) {
		currentProductModelLink=document.getElementById(currentProductModelId);
	}
	onClickAdvancedSearchCriteria(link, currentProductModelLink);
	currentProductModelLink=link;
}
function onClickProductFamily(link)
{
	if (!currentProductFamilyLink && currentProductFamilyId)
	{
		currentProductFamilyLink=document.getElementById(currentProductFamilyId);
	}
	onClickAdvancedSearchCriteria(link, currentProductFamilyLink);
	currentProductFamilyLink=link;
}
function onClickProductSerie(link)
{
	if (!currentProductSerieLink && currentProductSerieId) {
		currentProductSerieLink=document.getElementById(currentProductSerieId);
	}
	onClickAdvancedSearchCriteria(link, currentProductSerieLink);
	currentProductSerieLink=link;
}
function onClickProdAdvCategory(elementId)
{
	var td;
	td=document.getElementById(elementId);
	td.className=(td.className.indexOf(new String("expanded").toLowerCase())>-1)?"":"expanded"

}
var currentRSSCategoryLink;
var currentRSSCategoryLinkId="press_releases";

function onClickRSSCategory(elementId)
{
	var li;
	li=document.getElementById(elementId);

	li.className=(li.className.indexOf(new String("expanded").toLowerCase())>-1)?"":"expanded";

	if (!currentRSSCategoryLink && currentRSSCategoryLinkId) {
		currentRSSCategoryLink=document.getElementById(currentRSSCategoryLinkId);
	}
	if (currentRSSCategoryLink && currentRSSCategoryLink!=li) {
		currentRSSCategoryLink.className="";
	}
	currentRSSCategoryLink=li;
}
var currentEventsColumnLink;
var currentEventsColumnLinkId='date_column_link';
var eventColumnLinks, eventColumnLinkIds;
eventColumnLinkIds = new Array("date_column_link", "events_column_link", "location_column_link", "type_column_link");
function sortEvents(link)
{
	var linkClassName;

	if (link.className.indexOf(new String("selected").toLowerCase())==-1) {
		linkClassName = link.className.indexOf(new String("asc").toLowerCase())>-1 ? "asc":"desc";
		link.className=linkClassName+"_selected";
	} else {
		linkClassName = link.className.indexOf(new String("asc").toLowerCase())>-1 ? "desc":"asc";
		link.className=linkClassName+"_selected";
	}

	if (!currentEventsColumnLink && currentEventsColumnLinkId) {
		currentEventsColumnLink=document.getElementById(currentEventsColumnLinkId);
	}

	if (currentEventsColumnLink && currentEventsColumnLink!=link) {
		currentEventsColumnLink.className=currentEventsColumnLink.className.replace("selected ", "");
	}

	var defaultClassName, link2;

	defaultClassName=link.className.indexOf(new String("asc").toLowerCase())>-1?"asc":"desc";

	if (!eventColumnLinks) {
		eventColumnLinks = new Array();
		for (var i=0; i<eventColumnLinkIds.length; i++) {
			eventColumnLinks[i]=document.getElementById(eventColumnLinkIds[i]);
		}
	}

	for (var i=0; i<eventColumnLinks.length; i++) {
		if (eventColumnLinks[i]!=link) {
			eventColumnLinks[i].className=defaultClassName;
		}
	}

	currentEventsColumnLink=link;
}


var currentProductCategoryImg, changeImgTimerId, changeImgTimerDelay;
changeImgTimerDelay=200;
function changeProductCategoryImg(src, description) {
	if(changeImgTimerId) {
		clearTimeout(changeImgTimerId);
	}
	if (!currentProductCategoryImg) {
		currentProductCategoryImg=document.getElementById("producCategoryImg");
		currentProductCategoryImgDesc=document.getElementById("image_description");
	}
	currentProductCategoryImg.src=src;
	currentProductCategoryImgDesc.innerHTML=description;
}

function setDefaultProductCategoryImg(src) {
	changeImgTimerId=setTimeout("changeProductCategoryImg('"+src+"', '')", changeImgTimerDelay);
}

function onClickBuyerGuideAnswer(answerId) {
	var radio;
	radio=document.getElementById(answerId);
	radio.checked=true;
}

/*INet change*/
/*provide javascript that can be used on page load using this object*/

function INetPage() {
 	this.toExecute = new Array();

}
INetPage.prototype.constructor=INetPage;

INetPage.prototype.addOnLoad=function (/*string*/ code) {
	this.toExecute.push(code);
}

INetPage.prototype.clear=function () {
	var numberOfElements = this.toExecute.length;
	if (numberOfElements>0){
		this.toExecute.splice(0,numberOfElements);
	}
}

INetPage.prototype.execute=function () {
	for (var i =0; i<this.toExecute.length;i++){
		var code = this.toExecute[i];
		eval(code);
	}
}

iNetPage = new INetPage();

function _bodyOnLoad() {
	if (document.body.addEventListener) {
		document.body.addEventListener("click", onClickBody, false);
	} else {
		document.body.attachEvent("onclick", onClickBody);
	}

	iNetPage.execute();
	// expand left navigation here
	// TODO: should we just catch the exception if any
	try {
		expandLeftNavigation();
		highLightTopNavigation();
	} catch(e) {
		alert("Exception while loading navigation "+e);
	}


}

function onClickBody(e) {
	var parentElement=null;
	var hide=true;

	if (currentJsDropdown) {
		if (window.event) {
			parentElement=window.event.srcElement;
		} else {
			parentElement=e.target;
		}

		do {
			if (parentElement.className=="js_dropdown") {
				//alert(parentElement.id+":"+currentJsDropdown.id+":"+parentElement.id.indexOf(currentJsDropdown.id));
				if(parentElement.id.indexOf(currentJsDropdown.id)==0) {
					hide=false;
				}
				break;
			}
		} while (parentElement=parentElement.parentNode);

		if (hide) {
			currentJsDropdown.style.display="none";
		}

	}
}

/*INet : methods to expand left navigation depending on the url */
function expandLeftNavigation() {
	// get the url
	var url= window.location.href;
	// remove bookmark info
	url = getUrlWithOutHost(url);
	url = url.split("#")[0];
	var urlParts = url.split("?");
	var hasQueryParameters = urlParts.length>1;

	if (hasQueryParameters) {
		expandLeftNavigationForUrl(url);
	} else if (isDivisionUrl(url)) {
		// if its division url we need to expand corresponding products
		expandLeftNavigationForUrl(url+"/products");
	} else {
		// Products tree url for models won't be available so we need
		// to repeat the process few times.
		// TODO: needs some more conditions maybe or need to reduce
		// number of retries.
		url = urlParts[0];
		if (!expandLeftNavigationForUrl(url) && url.indexOf(".action")==-1) {
			for (var i = 0; i < 3 ; i++) {
				url = reduceUrlLevel(url);
				if (expandLeftNavigationForUrl(url)) {
					return true;
				}
			}
		}
	}

}

function isDivisionUrl (url) {
	var rgx = new RegExp('^/cusa/[a-zA-Z]+$','i');
	return rgx.test(url);
}


function highLightTopNavigation() {
	// get the url
	var url= window.location.href;
	hightLightTopNavigationForUrl(url);
}

function hightLightTopNavigationForUrl(url) {
	var topNavUl = document.getElementById("top_nav_dropdown_list");
	if (!topNavUl) {
		return;
	}

	var childListElements = topNavUl.getElementsByTagName("a");
	for (var i = 0; i < childListElements.length; i++) {
		var topNavigationUrl = childListElements[i].href;
		var index = topNavigationUrl.lastIndexOf("/");
		if (index!=-1) {
			topNavigationUrl=topNavigationUrl.substring(index,topNavigationUrl.length);
		}
		if (url.search(topNavigationUrl+"(/|\\?|#|$)")!=-1) {
			liElement = childListElements[i].parentNode;
			if (liElement){
				liElement.className ="selected current";
			}
			break;
		}
	}
}

function expandLeftNavigationForUrl(url) {
	var leftNavDiv = document.getElementById("left_navbar");
	if (!leftNavDiv) {
		return false;
	}
	var childAnchorElements = leftNavDiv.getElementsByTagName("a");
	var anchorElement = null ;

	// first find the <a> element that has the matching url.
	for (var i = 0; i < childAnchorElements.length; i++) {
		var hrefLink = childAnchorElements[i].href ;
		// remove hash from there
		var urlParts = hrefLink.split("#");
		if (urlParts.length==2) {
			hrefLink = urlParts[0];
		}
		// included the url != "" condition so that there will not be defult expanded for the left nav. (ref QC960)
		if (url!="" && (url==hrefLink || stringEndsWith(hrefLink,url))) {
			anchorElement=childAnchorElements[i];
			break;
		}
	}

	// loop through the parents and make all list holders expanded
	if (anchorElement) {
		return expandLeftNavigationForAnchorTag(anchorElement);
	}
	return false;
}

function expandLeftNavigationForAnchorTag(/*DOM object*/anchorElement) {
	if (anchorElement){
		var targetLiElement = anchorElement.parentNode;
		var liElement = targetLiElement;
		var isPartOfList=false;
		var loop = true;
		while (loop) {
			var ulElement = liElement.parentNode;

			if (ulElement && ulElement.tagName=="UL" && ulElement.id) {
				liElement = ulElement.parentNode;
				previousClass = liElement.className;
				liElement.className = previousClass+" expanded";
			} else {
				loop = false;
			}
		}
		// if it is item in list then it has to be "selected" and if its a list holder
		// it has to be "expanded"

		var hasChildLinks = targetLiElement.getElementsByTagName("UL").length != 0;
		var previousClass = targetLiElement.className;
		targetLiElement.className = previousClass+((hasChildLinks)?" expanded":" selected");
		return true;
	}
	return false;

 }


function getUrlWithOutHost(url) {
	var urlParts = url.split("//");
	if (urlParts.length==1) {
		return url;
	}
	url=urlParts[1];
	var index = url.indexOf("/");
	if (index!=-1) {
		return url.substring(index,url.length);
	}

}

function reduceUrlLevel(url) {
	var index = url.lastIndexOf("/");
	if (index != -1) {
		return url.substring(0,index);
	}
	return url;
}


function stringEndsWith(str,txt) {
	txt = escapeSpecialCharacters(txt);
	var rgx= new RegExp(txt+"$");
	return str.match(rgx)!=null;
}

function escapeSpecialCharacters(txt) {
	var specials = [
		'/', '.', '*', '+', '?', '|',
		'(', ')', '[', ']', '{', '}', '\\'
	];
	var rgx = new RegExp(
		'(\\' + specials.join('|\\') + ')', 'g'
	);
	return txt.replace(rgx, '\\$1');
}




/*START  Used by Promotions and ProdAdvisoures for popup*/
	var htmlString = "";

	function openPopup(str, width, height) {
		htmlString = str;
		NewWindow('/sys/html/popup.html','popup', width, height, 'no', 'no');
	}

	var win = null;
	function NewWindow(mypage,myname,w,h,scroll,resize,toolbar,location,menubar){
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize
		if (toolbar == "yes") {
			settings +=",toolbar=yes";
		}
		if(location == "yes") {
			settings +=",location=yes";
		}
		if(menubar == "yes") {
			settings +=",menubar=yes";
		}
		win = window.open(mypage,myname,settings)
		if (win != null) {
			if (win.opener == null) {
				win.opener = self;
			} else {
				win.focus();
			}
		}
	}

/* END  Used by Promotions and ProdAdvisoures for popup*/


/* START More Photos JS*/

	var morePhotos_slideIndex = 1;
	var morePhotos_total_slides = 1;

	function morePhotosOnload(totalSlides) {
		if (morePhotos_slideIndex > 1){
			dojo.byId('slideShowDiv_'+morePhotos_slideIndex).style.display = 'none';
			dojo.byId('previousImg').style.display = 'none';
		}
		morePhotos_slideIndex = 1;
		dojo.byId('slideShowDiv_'+morePhotos_slideIndex).style.display = 'inline';
		morePhotos_total_slides = totalSlides;
		if (morePhotos_total_slides > 1) {
			dojo.byId('nextImg').style.display = 'inline';
		}
	}

	function loadLargeImage(largeImage, phototitle, photodesc) {
		dojo.byId('large_image_id').src= largeImage;
		dojo.byId('photo_title').innerHTML= phototitle;
		dojo.byId('photo_desc').innerHTML= photodesc;
	}

	function morePhotosNext(){

		dojo.byId('slideShowDiv_'+morePhotos_slideIndex).style.display = 'none';
		if(morePhotos_slideIndex < morePhotos_total_slides){
			morePhotos_slideIndex = morePhotos_slideIndex + 1;
		}

		if(morePhotos_slideIndex < morePhotos_total_slides){
			dojo.byId('nextImg').style.display = 'inline';
		}else if (morePhotos_slideIndex == morePhotos_total_slides){
			dojo.byId('nextImg').style.display = 'none';
		}

		if(morePhotos_slideIndex > 1){
			dojo.byId('previousImg').style.display = 'inline';
		}

		dojo.byId('slideShowDiv_'+morePhotos_slideIndex).style.display = 'inline';
	}

	function morePhotosPrevious(){
		dojo.byId('slideShowDiv_'+morePhotos_slideIndex).style.display = 'none';
		if(morePhotos_slideIndex > 1){
			morePhotos_slideIndex = morePhotos_slideIndex - 1;
		}

		if(morePhotos_slideIndex > 1){
			dojo.byId('previousImg').style.display = 'inline';
		}else if (morePhotos_slideIndex == 1){
			dojo.byId('previousImg').style.display = 'none';
		}

		if(morePhotos_slideIndex < morePhotos_total_slides){
			dojo.byId('nextImg').style.display = 'inline';
		}

		dojo.byId('slideShowDiv_'+morePhotos_slideIndex).style.display = 'inline';

	}


/* END More Photos JS*/

/* START Photo Kit / More Photos JS */

var photoKit_slideIndex = 1;
var photoKit_total_slides = 1;

function photoKitOnload(totalSlides) {
	photoKit_total_slides = totalSlides;

	//QC887 : q04000
	//find the image, turn to the slide and call PhotoKitLoadLargeImage()
	if( dojo.byId('clickedImageSrc') != null ){
		var clickedImgSrc = dojo.byId('clickedImageSrc').value;
		if( clickedImgSrc != '' ){
			for( var k = 1; k <= photoKit_total_slides; k ++ ){
				var parentCtrl = dojo.byId('slideShowDiv_' + k);
				var imgCtrlArray = parentCtrl.getElementsByTagName('img');

				for(var i=0; i<imgCtrlArray.length; i++){
					if( imgCtrlArray[i].src.indexOf( clickedImgSrc ) != -1 ){
						//found the image on this slide

						//move to the slide K
						if( k > 1 ){
							//slideShowDiv_1 is showing by default, so hide it first
							dojo.byId('slideShowDiv_1').style.display = 'none';
						}
						photoKitShowSlide( k );

						var parentLink = imgCtrlArray[i].parentNode;
						parentLink.onclick();

						return;
					}
				}
			}
		}
	}

	//otherwise, show the first slide
	photoKitShowSlide( 1 );
}

function photoKitLoadLargeImage(largeImage, phototitle, photodesc) {
	dojo.byId('mainView').src= largeImage;

	if (phototitle != "") {
		dojo.byId('modelName').innerHTML= '<h1>'+phototitle+'</h1>';
	} else {
		dojo.byId('modelName').innerHTML= '<h1>&nbsp;</h1>';
	}

	dojo.byId('modelDescript').innerHTML= photodesc;
}

//QC887: by q04000
//Don't want to change documentum, so can not reuse photoKitNext()
function photoKitShowSlide( newSlideIndex ){
	//hide the current slide
	if ( newSlideIndex != photoKit_slideIndex ) {
		if( photoKit_slideIndex <= photoKit_total_slides ){
			dojo.byId('slideShowDiv_'+photoKit_slideIndex).style.display = 'none';
		}
	}

	photoKit_slideIndex = newSlideIndex;

	if (photoKit_slideIndex < photoKit_total_slides) {
		dojo.byId('nextImg').style.display = 'block';
	}else if (photoKit_slideIndex == photoKit_total_slides){
		dojo.byId('nextImg').style.display = 'none';
	}

	if (photoKit_slideIndex > 1) {
		dojo.byId('previousImg').style.display = 'block';
	} else {
		dojo.byId('previousImg').style.display = 'none';
	}

	dojo.byId('slideShowDiv_'+photoKit_slideIndex).style.display = 'block';
}

function photoKitNext() {
	dojo.byId('slideShowDiv_'+photoKit_slideIndex).style.display = 'none';
	if (photoKit_slideIndex < photoKit_total_slides) {
		photoKit_slideIndex = photoKit_slideIndex + 1;
	}

	if (photoKit_slideIndex < photoKit_total_slides) {
		dojo.byId('nextImg').style.display = 'block';
	} else if (photoKit_slideIndex == photoKit_total_slides) {
		dojo.byId('nextImg').style.display = 'none';
	}

	if (photoKit_slideIndex > 1) {
		dojo.byId('previousImg').style.display = 'block';
	}

	dojo.byId('slideShowDiv_'+photoKit_slideIndex).style.display = 'block';
}

function photoKitPrevious() {
	dojo.byId('slideShowDiv_'+photoKit_slideIndex).style.display = 'none';
	if (photoKit_slideIndex > 1) {
		photoKit_slideIndex = photoKit_slideIndex - 1;
	}

	if (photoKit_slideIndex > 1) {
		dojo.byId('previousImg').style.display = 'block';
	} else if (photoKit_slideIndex == 1) {
		dojo.byId('previousImg').style.display = 'none';
	}

	if (photoKit_slideIndex < photoKit_total_slides) {
		dojo.byId('nextImg').style.display = 'block';
	}

	dojo.byId('slideShowDiv_'+photoKit_slideIndex).style.display = 'block';

}
/* END Photo Kit / More Photos JS*/

function eliminateDuplicates(arr) {
	  var i,
	      len=arr.length,
	      out=[],
	      obj={};

	  for (i=0;i<len;i++) {
	    obj[arr[i]]=0;
	  }
	  for (i in obj) {
	    out.push(i);
	  }
	  return out;
}

// Start of R5 - QC - 802 , 1357
function addToCartWithTrack(eStoreUrl) {
	NewWindow(addCookie(eStoreUrl), "buyNow", "600", "550", "yes", "yes","yes","yes","yes");
	var value = GetCookie("WT.mc_id");
	if (value != null && value.length > 0)
		value = escape(value);
	else
		value = "";
	//dcsMultiTrack('WT.ti',document.title ,'WT.tx_e','A','WT.tx_u','1','WT.si_p','CartAdd','WT.si_n','ShoppingCart','WT.mc_id',value,'WT.ac','clicked iNET add to cart button','WT.pn_sku',itemCode);
	//'WT.pc','???',
	dcsMultiTrack('WT.ti',document.title + ' - Add To Cart Click' ,'WT.ac','clicked iNET add to cart button','DCS.dcsuri',window.location.pathname + '_atc.onclick');
}

function enlargeImage(n,z,srno) {
	var PROD_lrgImgElement = document.getElementById("acc_lrgImg"); 
	document.body.appendChild(PROD_lrgImgElement);
	var enlargeElement = document.getElementById("acc_enlarge_img_"+srno);
	if(PROD_lrgImgElement) {
		PROD_lrgImgElement.innerHTML = '<table cellpadding="0" cellspacing="0" border="0" style="border-width:1px; border-color:#000000; border-style:solid;"><tr><td><a href="javascript:void(0);" onclick="enlargeImage_hide();"><img border="1" name="ib" alt="large image view" src='+z+' height="201" width="201"></a></td></tr></table>';
		PROD_lrgImgElement.style.top=findPosY(enlargeElement)- 196 + "px";
		PROD_lrgImgElement.style.left=findPosX(enlargeElement)- 196 + "px";
	}
}

function enlargeImage_hide() {
	var PROD_lrgImgElement = document.getElementById("acc_lrgImg");
	if(PROD_lrgImgElement) {
		PROD_lrgImgElement.innerHTML = "";
	}
}

// ENd of R5
// Added below function for QC#1433
function createDownload(downloadid,id) {
	var url=document.URL;
	var myArray=url.split("?");
	myArray=myArray[0].split("#");

	var download_url = myArray[0] + '?id='+ downloadid+'_'+id+'&inTabView=false&pageKeyCode=downloadLicense';
//	if (formFlg == 'Y')
//		download_url = download_url + "&Keycode=Download";
	NewWindow(download_url,'Download_Popup','1012','800','yes','no');
	return false;
}


