function confirm_prompt(text,loc) {
    if (confirm(text)) {
         window.location = loc;
    }
  }

  function changeImg(ImgId, newScr) {
//  	alert(ImgId);
//  	alert(newScr);
  	imgObj = findObj(ImgId);
  //	alert(newScr);
  	imgObj.src = newScr;
  }
function changeFont(value, id1) {
	obj = findObj(id1);
	obj.style.fontFamily = value;
	obj.style.fontSize = 14;
}
function findObj(theObj, theDoc)
{

  var p, i, foundObj;

  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++)
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  return foundObj;
}

function hasASelection(groupName) {
	var elms = document.getElementsByName(groupName);
	/* or use the old-style:     document._form_name_.elements[groupName];*/
	for(var k=0, elm;elm=elms[k];k++)
	if(elm.checked)
	 return elm.value;
	 return false;
}
function reset(groupName) {
		var elms = document.getElementsByName(groupName);
	 for(var k=0, elm; elm=elms[k]; k++)
		if(elm.checked)
		 return elm.checked = false;
		 return false;
}
function reset2(groupName, product, size) {

	var elms = document.getElementsByName(groupName);
	var el = document.getElementById('color_'+product+'_'+size+'_1')
	if(el){
	return  el.checked = "checked";
	 for(var k=1, elm; elm=elms[k]; k++)
		if(elm.checked)
		 return elm.checked = false;
		 return false;
	}
}
function round(number,X) {
// rounds number to X decimal places, defaults to 2
    X = (!X ? 2 : X);
    return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}
function outputMoney(number) {
	number = round(number,2);

    return outputDollars(Math.floor(number-0) + '') + outputCents(number - 0);
}

function outputDollars(number) {
    if (number.length <= 3)
        return (number == '' ? '0' : number);
    else {
        var mod = number.length%3;
        var output = (mod == 0 ? '' : (number.substring(0,mod)));
        for (i=0 ; i < Math.floor(number.length/3) ; i++) {
            if ((mod ==0) && (i ==0))
                output+= number.substring(mod+3*i,mod+3*i+3);
            else
                output+= '.' + number.substring(mod+3*i,mod+3*i+3);
        }
        return (output);
    }
}

function outputCents(amount) {
    amount = Math.round( ( (amount) - Math.floor(amount) ) *100);
    return (amount < 10 ? ',0' + amount : ',' + amount);
}



// setStyleById: given an element id, style property and
// value, apply the style.
// args:
//  i - element id
//  p - property
//  v - value
//
function setStyleById(i, p, v) {
	var n = findObj(i);
	n.style[p] = v;
}
// this function gets the cookie, if it exists
// don't use this, it's weak and does not handle some cases
// correctly, this is just to maintain legacy information
function Get_Cookie( name ) {

var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function preview(id1, id2){
	  		var NewText = document.getElementById(id1).value;
	  		splitText = NewText.split(/\n/).join("<br />");
	  		var DivElement = document.getElementById(id2);
	  		DivElement.innerHTML = '<p>'+ splitText+'</p>';
}


