function goCL(code, line, cpc_value)
{
	if (code == "") {
	} else {
		var nvl = '(nodeCode,'+code+'),(catalogCode,'+catalogCode+'),(lineCode,'+line+')';
		if (typeof cpc_value != "undefined" && cpc_value != null && cpc_value != "") {
			nvl = nvl + ',(cpc,'+cpc_value+')';
		}
		// jump to page...
		window.location.href = hostPages+'/navigation/browse/index.cfm?cc_nvl=('+nvl+')';
	}
}
function goECL(entry, code, line)
{
	if (code == "") {
	} else {
		var nvl = '(entryid,'+entry+'),(nodeCode,'+code+'),(catalogCode,'+catalogCode+'),(lineCode,'+line+')';
		// jump to page...
		window.location.href = hostPages+'/navigation/browse/index.cfm?cc_nvl=('+nvl+')';
	}
}
function addToCart()
{
	document.add_cart_form.submit();
}
function addFavorite()
{
	document.add_fav.submit();
}

function displayImage(pid)
{
	var url_string = 'display_image.cfm?prodTreeID='+pid;
	
	popWindow(url_string, 'popup_image', 450, 450);
}

var window_handle= null;
function popWindow(url_string, name, wid, ht)
{
	// close window if already open
	if (window_handle != null) {
		window_handle.close();
	}
	if (typeof name == 'undefined') {
		name = 'poptWin';
	}
	window_handle = window.open(
		url_string,name,
	'width='+wid+',height='+ht+',toolbar=0,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1');
	setTimeout('window_handle.focus()',200);
}

function tabForward( indx ) {
	for (var i=0; i<maxtabcnt; i++) {
		otab = document.getElementById("tab_b_"+i);
		otab.src = 'images/tab_b_s.gif';
		otab = document.getElementById("tab_m_"+i);
		otab.style.backgroundImage = 'url(images/tab_b_m.gif)';
		otab = document.getElementById("tab_e_"+i);
		otab.src = 'images/tab_b_e.gif';
	}
	otab = document.getElementById("tab_b_"+indx);
	otab.src = 'images/tab_f_s.gif';
	otab = document.getElementById("tab_m_"+indx);
	otab.style.backgroundImage = 'url(images/tab_f_m.gif)';
	otab = document.getElementById("tab_e_"+indx);
	otab.src = 'images/tab_f_e.gif';
}
function checkEnter(e, formname) { //e is event object passed from function invocation
	var characterCode;

	if ( e && e.which) { //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	} else {
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	} 
	if(characterCode == 13) { 
		//if generated character code is equal to ascii 13 (if enter key)
		document.getElementById(formname).submit() //submit the form
		return false;
	}
}
var editorWindow = null;
function popEditor(wid, ht, eid)
{
	// close window if already open
	if (editorWindow != null) {
		editorWindow.close();
	}
	editorWindow = window.open(
		'photo_editor.cfm?entryid='+eid,'editor_window',
	'width='+wid+',height='+ht+',toolbar=1,location=1,directories=0,status=1,menuBar=1,scrollBars=1,resizable=1');
	setTimeout('editorWindow.focus()',200);
}
var editFavWindow = null;
var favwincnt = 1;
function popFavWindow(url_string, wid, ht)
{
	// close window if already open
	if (editFavWindow != null) {
		//editFavWindow.close();
	}
	favwincnt++;
	editFavWindow = window.open(
		url_string,'pdfWin',
	'width='+wid+',height='+ht+',toolbar=0,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1');
	//setTimeout('editFavWindow.focus()',200);
}

function waitScreen(bTF, message)
{
	// tell user to wait for a long action...
	window.status = message;
	waitMessage.innerHTML = message;
	isIE5 = (document.all && document.getElementById)
	if (isIE5) {
		waitMessage.style.filter = baseFilter+"alpha(opacity=10)";
		waitMessage.style.display = '';
		setTimeout("fadeInOutObject(5, 10, 20, 'waitMessage');",100);
	} else {
		waitMessage.style.display = '';
	}
}
var baseFilter = "progid:DXImageTransform.Microsoft.dropshadow(OffX=1, OffY=1, Color='##ff666666', Positive='true')progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='##bb999999', Positive='true')progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='##AABBBBBB', Positive='true')";
function fadeInOutObject(fade, change, time, divename)
{
	newfade = fade + change;
	fadeObj = document.getElementById(divename);
	if (newfade >= 100) {
		fadeObj.style.display = '';
		fadeObj.style.filter = baseFilter;
	} else if (newfade <= 0) {
		fadeObj.style.display='none';
		fadeObj.style.filter = '';
		// restore selects
		for (i=0; i<balloonHelpSelectList.length; i++) {
			balloonHelpSelectList[i].style.visibility = "";
		}
	} else {
		fadeObj.style.filter = baseFilter+"alpha(opacity=" + newfade + ")";
		setTimeout("fadeInOutObject("+newfade+", "+change+", "+time+", '"+divename+"')",time);
	}
}

/*========================Custom Alerts ========================================*/
/* @@
	customAlerts 
*/
//Settings
	var customAlert_button_class = "";
	var customAlert_text_class = "med";
	var customAlert_icon_src = "images/warning_diamond32.gif";

//Generic dialogs: customAlert and customConfirm
var customAlertDiv = document.createElement("div");

/*	@@
	Work like JS alert. 
*/
function customNotify (txt){				
	customAlertDiv.setAttribute("id","customAlertDiv");
	customAlertDiv.innerHTML = 
	/*
	'<div id="customAlert" class="alpha-shadow" style="z-index:9999999; position:absolute; width:400px;">' + 
		'<div class="alpha-shadow2">' + 
			'<div class="alpha-shadow3">' + 
	*/
	'<div id="customAlert" style="z-index:9999999;position:absolute;;background-color:#cccccc; width:400px; overflow: visible;">' + 
		'<div style="position: relative; bottom: 2px; right: 2px; background-color: #666666; overflow: visible;">' + 
			'<div style="position:relative; bottom: 2px; right: 2px; background-color: #FFFFBB;border: 1px solid #000000;padding: 4px 4px; overflow: visible;">' + 
				'<div style="float:left;margin-top:9px;"><img src="' + customAlert_icon_src + '"></div>' + 
				'<div id="customAlertText" class="' + customAlert_text_class + '" style="margin:15px 0 25px 35px;position:relative; overflow: visible;">' + txt + '</div>' + 
			'</div>'+
		'</div>'+
	'</div>';
	document.body.appendChild(customAlertDiv);	
	var obj = document.getElementById("customAlert");
	//document.getElementById("customAlertText").innerHTML = txt;	
	position();		
	//Resizing.
	//window.onresize = function () {	position();};
	//window.onscroll = function () {	position();};
	//Reposition on scroll
	function position(){			
		/*	If the app expands 100% 
		 		var body_w = document.body.clientWidth;
		*/	
		var body_w = 950;
		var scroll_top = Math.max(document.documentElement.scrollTop, document.body.scrollTop);		
		var scroll_left = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);		
		var top = parseInt(document.body.clientHeight/5)+scroll_top;
		var left = parseInt(body_w/2)-(obj.clientWidth/2)+scroll_left;					
		obj.style.top = top+"px";
		obj.style.left = (left < 0 ? 0 : left)+"px";
		return false;
	}
	changeOpac( 0, 'customAlert');
	setTimeout("opacity('customAlert', 0, 100, 1000)",10);
	setTimeout("opacity('customAlert', 100, 0, 1000)",3000);
	setTimeout("document.body.removeChild(customAlertDiv);",6000);
	return true;
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i-=5) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i+=5) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function customAlert (txt){				
	customAlertDiv.setAttribute("id","customAlertDiv");
	customAlertDiv.innerHTML = 
	/*
	'<div id="customAlert" class="alpha-shadow" style="z-index:9999999; position:absolute; width:400px;">' + 
		'<div class="alpha-shadow2">' + 
			'<div class="alpha-shadow3">' + 
	*/
	'<div id="customAlert" style="z-index:9999999;position:absolute;;background-color:#cccccc; width:400px; overflow: visible;">' + 
		'<div style="position: relative; bottom: 2px; right: 2px; background-color: #666666; overflow: visible;">' + 
			'<div style="position:relative; bottom: 2px; right: 2px; background-color: #FFFFBB;border: 1px solid #000000;padding: 4px 4px; overflow: visible;">' + 
				'<div style="float:left;margin-top:9px;"><img src="' + customAlert_icon_src + '"></div>' + 
				'<div id="customAlertText" class="' + customAlert_text_class + '" style="margin-top:15px;margin-left:35px;position:relative; overflow: visible;">' + txt + '</div>' + 
				'<div id="customAlertButtons" align="center" style="margin-top:20px;width:100%;">' + 
					'<input type="button" value="Close" onclick="document.body.removeChild(customAlertDiv);">' + 
				'</div>'+
			'</div>'+
		'</div>'+
	'</div>';
	document.body.appendChild(customAlertDiv);	
	var obj = document.getElementById("customAlert");
	//document.getElementById("customAlertText").innerHTML = txt;	
	position();		
	//Resizing.
	//window.onresize = function () {	position();};
	//window.onscroll = function () {	position();};
	//Reposition on scroll
	function position(){			
		/*	If the app expands 100% 
		 		var body_w = document.body.clientWidth;
		*/	
		var body_w = 950;
		var scroll_top = Math.max(document.documentElement.scrollTop, document.body.scrollTop);		
		var scroll_left = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);		
		var top = parseInt(document.body.clientHeight/5)+scroll_top;
		var left = parseInt(body_w/2)-(obj.clientWidth/2)+scroll_left;					
		obj.style.top = top+"px";
		obj.style.left = (left < 0 ? 0 : left)+"px";
		return false;
	}
	return true;
}
/*	@@
	customConfirm (txt, ok call [,cancel call]) 
	
	It will work a little bit different than the regular JS confirm. 
	The action to be executed if Ok is clicked will need to be passed like using setTimeout (strings);
	ej.  javascript:customConfirm('Text to be displayed' , 'OKcall()', 'Cancelcall(\'txt\')'); 
*/	
function customConfirm (txt, ok_call){	
	var obj = customAlert(txt);
	var cancel_call;
	if (arguments.length == 3) {		
		cancel_call = arguments[2];
	} else {
		cancel_call = false;
	}	
	var btn_OK = '<input type="button" class="'+customAlert_button_class+ '" value="OK" style="width:70px" onclick="customAlertAction('+ok_call+');">';  
	var btn_cancel = '<input type="button" class="'+customAlert_button_class+ '" value="Cancel" style="width:70px"  onclick="customAlertAction('+cancel_call+');">';  
	var btn_area = document.getElementById("customAlertButtons");	
	btn_area.innerHTML = btn_OK + "&nbsp;&nbsp;&nbsp;&nbsp;" + btn_cancel;	
}
//action for confirm
function customAlertAction(act){	
	document.body.removeChild(customAlertDiv);
	if (act == false){		
		return false;
	} else {	
		act;
		return true;
	}		
}
/* End ========================Custom Alerts =============================================*/


