/* brand-specific common library */
function elcSendURL( url ) {
    location.replace(wsmlMakeWebServiceHref(url));
}
function sendURL(targetURI) {
    window.location = wsmlMakeWebServiceHref(targetURI);
}
function elcGotoURL( url ) {
    if (url != null && url != '') {
        self.location.href = wsmlMakeWebServiceHref(url);
    }
}

/* popup window */
function popWin(url, winName, popWidth, popHeight, popTop, popLeft, popScroll){
    var top = (popTop == "undefined" || popTop < 0) ? 20 : popTop;
    var left = (popLeft == "undefined" || popLeft < 0) ? 20 : popLeft;
    var options = 'width='+popWidth+',height='+popHeight+',scrollbars='+popScroll+',top='+top+',left='+left+',location=no,toolbar=0,menubar=0,resizable=0,directories=0';
    var myWin = window.open(url, winName, options);
    myWin.focus();
}
      
function properWindowOpener(url, w, h){
    var windowWidth  = w;
    var windowHeight = h;

    //find out how big the screen is
    var screenWidth  = screen.availWidth;
    var screenHeight = screen.availHeight;

    //get the left position - which is half the screen width minus half the window width
    var leftPoint = parseInt(screenWidth/2) - parseInt(windowWidth/2);
    //get the top position - which is half the screen height minus half the window height
    var topPoint  = parseInt(screenHeight/2) - parseInt(windowHeight/2);
  
    var winprops = 'height='+h+', left='+leftPoint+', top='+topPoint+', width='+w+', resizable=1'
    var win = window.open( url, "win", winprops);

    if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/* cookies */
function doNothing(){
	
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function isdefined(object, variable)
{
	return (typeof(eval(object)[variable]) != 'undefined');
}



if (!Effect){ var Effect = '';} // for Macy's

Effect.Center = function(element,xoffsetIE,yoffsetIE,xoffsetFF,yoffsetFF,xoffsetOP,yoffsetOP)
{
    if (!xoffsetIE){ xoffsetIE = 0; }
    if (!yoffsetIE){ yoffsetIE = 0; }
    if (!xoffsetFF){ xoffsetFF = 0; }
    if (!yoffsetFF){ yoffsetFF = 0; }
    if (!xoffsetOP){ xoffsetOP = 0; }
    if (!yoffsetOP){ yoffsetOP = 0; }
    
    var xoffset = (Prototype.Browser.IE)    ? xoffsetIE
                : (Prototype.Browser.Opera) ? xoffsetOP
                :                             xoffsetFF
                ;
    var yoffset = (Prototype.Browser.IE)    ? yoffsetIE
                : (Prototype.Browser.Opera) ? yoffsetOP
                :                             yoffsetFF
                ;

    try
    {
        element = $(element);
    }
    catch(e)
    {
        return;
    }

    var my_width  = 0;
    var my_height = 0;

    if ( typeof( window.innerWidth ) == 'number' )
    {

        my_width  = window.innerWidth;
        my_height = window.innerHeight;
    }
    else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {

        my_width  = document.documentElement.clientWidth;
        my_height = document.documentElement.clientHeight;
    }
    else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    {

        my_width  = document.body.clientWidth;
        my_height = document.body.clientHeight;
    }

    element.style.position = 'absolute';
    element.style.zIndex   = 10001;

    var scrollY = 0;

    if ( document.documentElement && document.documentElement.scrollTop )
    {
        scrollY = document.documentElement.scrollTop;
    }
    else if ( document.body && document.body.scrollTop )
    {
        scrollY = document.body.scrollTop;
    }
    else if ( window.pageYOffset )
    {
        scrollY = window.pageYOffset;
    }
    else if ( window.scrollY )
    {
        scrollY = window.scrollY;
    }

    var elementDimensions = Element.getDimensions(element);

    var setX = (( my_width  - elementDimensions.width  ) / 2) + xoffset;
    var setY = (( my_height - elementDimensions.height ) / 2 + scrollY) + yoffset;
    
    setX = ( setX < 0 ) ? 0 : setX;
    setY = ( setY < 0 ) ? 0 : setY;

    element.style.left = setX + "px";
    element.style.top  = setY + "px";

}


/* quantity box populator */
function check_for_quantity(qbox_name){
    var qval = $(qbox_name).value;
    if (!qval){
        $(qbox_name).value = 1;
    }
    return true;
}

function check_for_ww_main_prod_quantity(){
    var thisForm = $('prodform');
    
    var qval = $(thisForm.qty).value;
    if (!qval){
        $(thisForm.qty).value = 1;
    }
    return true;
}

function check_for_ww_quantity(ww_form){
	var thisForm = $('ww'+ww_form+'form');
	
	var qval = $(thisForm.qty).value;
    
    if (!qval){
        $(thisForm.qty).value = 1;
        setWwFormVals( $(thisForm.qty) );
    }
	return true;
}
