//===========================================================================================
//toggle visibility on ID based on field value
//===========================================================================================
function check_value(IDa,IDb,field_value)
{
  var e = document.getElementById(IDb);
  if ((field_value.indexOf('^'+e.value+'^',0) > -1)||(e.checked == true))
  {
	toggle_display(IDa,'show');  	
  }
  else
  {
	toggle_display(IDa,'hide');
  }
  
  
 // if (field_value.indexOf(',',0) == -1)
//  {
//	if ((e.value == field_value)||(e.checked == true))
//	{
//	  toggle_display(IDa,'show');  	
//	}
//	else
//	{
//	  toggle_display(IDa,'hide');
//	}
//  }
//  else
//  {
//	  field_value_array = field_value.split(",");
//	  for (x=0; x<field_value_array.length; x++)
//      {
//		  var found_instance = false;
//		  alert(field_value_array[x]);
//		  if ((e.value == field_value_array[x])||(e.checked == true))
//	  	  {
//			  found_instance = true;
//		  }
//	  }	 
//	  
//	  if (found_instance == true)
//	  {
//		toggle_display(IDa,'show');  	
//	  }
//	  else
//	  {
//		toggle_display(IDa,'hide');
//	  }
//  }
}

function check_value_off(IDa,IDb,field_value)
{
  var e = document.getElementById(IDb);
  if ((e.value == field_value)||(e.checked == true))
  {
  	toggle_display(IDa,'hide');	
  }
  else
  {
    toggle_display(IDa,'show');
  }
}

function toggle_display(IDa,show_hide)
{
  //if (IDa == "first_only_table") {alert(IDa + ' - ' + show_hide);}
  var browser = navigator.appName;
  var el = document.getElementById(IDa);
  if(browser.indexOf("Netscape")>=0) show_value = 'table-row';
  if(browser.indexOf("Microsoft")>=0) show_value = 'inline';
  if ((show_hide == 'hide')||((show_hide == 'toggle') && (el.style.display==show_value)))
  {
	el.style.display = 'none';
  }
  else
  {
	el.style.display=show_value;
  }
}
//===========================================================================================
//set/unset tr bgcolor when checkbox is set
//===========================================================================================
function change_accordion(accordian_type)
{
	//alert(accordian_type);
	
	if (accordian_type=='Category')
	{
		$("#accordion").accordion("enable");
		$('#accordion').accordion('activate', 0);
	}
	else if (accordian_type=='Product')
	{
		$("#accordion").accordion("enable");
		$('#accordion').accordion('activate', 1);
	}
	else
	{
		$('#accordion').accordion('activate', false);
		$("#accordion").accordion("disable");
	}
}
/***********************************************
* Ultimate Fade-In Slideshow (v1.5): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
 
var fadeimages=new Array()
 
var fadebgcolor="white"
 
////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=obj.degree/100
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}
 
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var allowpop=1;
function popWin(){
var ppl="popLayer";var objppl=findObj(ppl);
if (objppl==null){return;}// if the layer does not exist, do nothing.
var args=arguments,movetoX=parseInt(args[0]),movetoY=parseInt(args[1]),movespeed=parseInt(args[2]);
var cycle=10,pxl="";
if(!document.layers){objppl=objppl.style;}
if(objppl.tmofn!=null){clearTimeout(objppl.tmofn);}
var pplcoordX=parseInt(objppl.left),pplcoordY=parseInt(objppl.top);
var xX=movetoX,yY=movetoY;if((pplcoordX!=movetoX)||(pplcoordY!=movetoY)){
   var moveX=((movetoX-pplcoordX)/movespeed),moveY=((movetoY-pplcoordY)/movespeed);
   moveX=(moveX>0)?Math.ceil(moveX):Math.floor(moveX);movetoX=pplcoordX+moveX;
   moveY=(moveY>0)?Math.ceil(moveY):Math.floor(moveY);movetoY=pplcoordY+moveY;
   if((parseInt(navigator.appVersion)>4||navigator.userAgent.indexOf("MSIE")>-1) && (!window.opera)) {pxl="px";}
   if (moveX!=0){eval("objppl.left='" + movetoX + pxl + "'");}
   if (moveY != 0) {eval("objppl.top = '" + movetoY + pxl + "'");}
   var sFunction = "popWin(" + xX + "," + yY + "," + movespeed+ ")";
   objppl.tmofn = setTimeout(sFunction,cycle);
   }
}
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 hideLayer(layername){
layer=findObj(layername);
if(layer.style){layer=layer.style;}
layer.visibility='hidden'; }
//====================================
var timerID = null
var delay = 1000
var breakout_ctr = 200

function count_down_run(time_in_sec)
{
	var session_ctr = get_cookie ("session_ctr");
	if ((session_ctr == "")||(session_ctr == null))
	{
		var session_ctr = new Date();
		session_ctr.setSeconds(session_ctr.getSeconds() + time_in_sec);
		document.cookie = "session_ctr="+session_ctr.toGMTString();
		//document.cookie = "session_enabled=true";
	}
	
	//var now = new Date();
	//var nowa = new Date(session_ctr);
	//alert(nowa - now);
	StartTheTimer();
}
	
function StartTheTimer()
{
	var session_enabled = get_cookie ("session_enabled");
	//alert(session_enabled);
	//if ((breakout_ctr > 0)&&(session_enabled == "true"))
	if (breakout_ctr > 0)
	{
		var now = new Date();
		var session_ctr = new Date(get_cookie ("session_ctr"));
		//alert(session_ctr - now);
		if (session_ctr <= now)
		{
			popWin(300,200,20);
			//document.cookie = "session_enabled=false";
		}
		else
		{
			breakout_ctr--;
			timerID = self.setTimeout("StartTheTimer()", delay);
		}
	}
}
	


function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results )
    return ( unescape ( results[1] ) );
  else
    return null;
}

function dealoftheweek(Products_ProdoftheWeek,Products_Name_Prev_DealoftheWeek)
{
	var a = document.getElementById(Products_ProdoftheWeek);
	var b = document.getElementById(Products_Name_Prev_DealoftheWeek);
	s = a.checked;
	//alert(s);
	if (s == true)
	{
		if (b.value.length > 0)
		{
			alert('Are you sure you want to make this product the Deal of the week.\n Previous product will be removed ['+b.value+']');
		}
	}
}
function product_price_validation(ElementId)
{
	var oDiv = document.getElementById(ElementId);
	s = oDiv.value;
	var v = "0123456789.";
	for (i=0; i < s.length; i++) 
	{
		x = oDiv.value.charAt(i);
		if (v.indexOf(x,0) == -1)
		{
			oDiv.value = oDiv.value.replace(x,"");
		}
	}
	
	d=oDiv.value.indexOf('.',0);  
	if (d>0)
	{
		if (d<(oDiv.value.length-3))
		{
			l = oDiv.value.length-1;
			oDiv.value = s.substring(0,l);
		}
		p=oDiv.value.indexOf('.',d+1);
		if (p > d)
		{
			l = oDiv.value.length-1;
			oDiv.value = s.substring(0,l);
		}
	}
}

function swap_images(image_name,swap_type)
{
	if (swap_type == "out")
	{
		document.getElementById("temp_area").value = document.getElementById("content").innerHTML;
		document.getElementById("content").innerHTML = "<img src=\""+ image_name + "\" width=\"250\" height=\"330\" border=\"0\">";
	}
	else
	{
		 document.getElementById("content").innerHTML = document.getElementById("temp_area").value;
	}
}

//<img src="<%=ProductsAlt_Pic_Link%>" height="75" border="0" class="border_light" id="ALT_<%=main_ctr%>" onmouseover="document.getElementById('main_image_temp').value=document.getElementsByName('main_img').src;document.getElementsByName('main_img').src=document.getElementById('ALT_<%=main_ctr%>').src" onmouseout="document.getElementsByName('main_img').src=document.getElementById('main_image_temp').value;">


//===========================================================================================
//pause execution
//===========================================================================================
function pausecomp(Amount)
    {
    d = new Date() //today's date
    while (1)
        {
        mill=new Date() // Date Now
        diff = mill-d //difference in milliseconds
        if( diff > Amount ) {break;}
        }
    }
//===========================================================================================
//drag and drop code
//===========================================================================================
function updatecoords(evt){
if(document.all){
evt = event;
}
positionX = evt.x ? evt.x : evt.clientX;
positionY = evt.y ? evt.y : evt.clientY;
changepos(positionX, positionY);
}
function changepos(x, y){
var box = document.getElementById(boxid);
x = (isNaN(x - 2) || ((x - 2) < 1)) ? 1 : (x - 2);
y = (isNaN(y - 15) || ((y - 15) < 1)) ? 1 : (y - 15);
box.style.left = x + "px";
box.style.top = y + "px";
}
function stop(){
setTimeout("document.body.onclick = null;", 20);
document.onmousemove = null;
document.body.style.cursor = null;
var box = document.getElementById(boxid);
setTimeout("box.onclick = function(){begin_move(this)}", 20);
box.style.borderWidth = "0px";
boxid = "";
}
function begin_move(box){
boxid = box.id;
box.style.position = "absolute";
box.style.borderColor = "#000000";
box.style.borderWidth = "1px";
box.style.borderStyle = "solid";
document.onmousemove = updatecoords;
setTimeout("document.body.onclick = stop;", 20);
setTimeout("box.onclick = stop;", 20);
}
//===========================================================================================
//does check for enter key and does form submit when enter key is hit
//===========================================================================================
function checkEnter(e)
{ 
	var characterCode
	
	if(e && e.which)
	{ 
		e = e;
		characterCode = e.which; 
	}
	else
	{
		e = event;
		characterCode = e.keyCode; 
	}
	
	if(characterCode == 13)
	{
		//document.form[0].submit(); //submit the form
		a = eval('document.' + e)
 	    a.submit();
		return false;
	}
	else
	{
		return true;
	}

}
//===========================================================================================
//Form Validation Functions
//===========================================================================================
var ElementCnt = new Array();
var ElementNames = new Array();
var ElementIds = new Array();
function field_init(ElementId)
{
    var oDiv = document.getElementById(ElementId);
    if(oDiv.value == '')
    {
        oDiv.style.border="2px solid red";
    }
}

function validate_form()
{
	var Field_Cnt = document.getElementById('Field_Cnt');
    var form_valid = 1;
	
	var array_values = document.getElementById('array_values');
    var array_id = document.getElementById('array_id');	
	var array_names = document.getElementById('array_names');
	
	ElementIds_Str = array_id.value;
	ElementIds = ElementIds_Str.split(",");
	ElementNames_Str = array_names.value;	
	ElementNames = ElementNames_Str.split(",");
	ElementValues_Str = array_values.value;	
	ElementValues = ElementValues_Str.split(",");
	
	for (x=0; x<ElementIds.length; x++)
    {    
		ElementId = ElementIds[x];	
		var oDiv = document.getElementById(ElementId);
		
		field_check(ElementId)
		ElementValues_Str = array_values.value;	
		ElementValues = ElementValues_Str.split(",");
		if (ElementValues[x] != '1')
		{
			form_valid = 0;
		}
    }
    
    // - check validation
    if (form_valid != 1)
    {
        alert("There are some errors in your submital.");
        return false;
    }
    else
    {
        //alert("Looks Good!")
        return true;
    }
}

function field_check(ElementId)
{
    var oDiv = document.getElementById(ElementId);
    var Field_Cnt = document.getElementById('Field_Cnt');
    var x=0;
    var y;
    var field_valid = 1;
	
	var array_values = document.getElementById('array_values');
    var array_id = document.getElementById('array_id');	
	var array_names = document.getElementById('array_names');
	
	ElementIds_Str = array_id.value;
	ElementIds = ElementIds_Str.split(",");
	ElementNames_Str = array_names.value;	
	ElementNames = ElementNames_Str.split(",");
	
	for (x=0; x<ElementIds.length; x++)
    {
		if (ElementIds[x] == ElementId)
		{
			FieldType = ElementNames[x];
			//alert(FieldType);
			var FieldLocation = x;
		}
    }
     
    // - name has to be at least 2 characters
    if (FieldType == 'name')
    {
        x = ElementId-1;
        if(oDiv.value.length < 3)
        {
           field_valid = 0;
        }
    }  
	// - name has to be at least 2 characters
    if (FieldType == 'cvv')
    {
        //alert('['+ElementId+'] ,'+FieldType);
		x = ElementId-1;
        if(oDiv.value.length < 2)
        {
           field_valid = 0;
        }
		
		s = oDiv.value;
		var v = "0123456789-";
		for (i=0; i < s.length; i++) {
		x = s.charAt(i);
		if (v.indexOf(x,0) == -1)
			field_valid = 0;
		}
    } 
    // - Zip needs 5 characters
    if (FieldType == 'zip')
    {
        if((oDiv.value.length < 5)||(oDiv.value.length > 10))
        {
            field_valid = 0;
        }
        
        s = oDiv.value;
		var v = "0123456789-";
		for (i=0; i < s.length; i++) {
		x = s.charAt(i);
		if (v.indexOf(x,0) == -1)
			field_valid = 0;
		}
    }
	// - State needs 2 characters
    if (FieldType == 'state')
    {
        x = ElementId-1;
        if(oDiv.value.length < 2)
        {
           field_valid = 0;
        }
		calculate_taxes();
    }
    // - phone no less than 9, no greater than 17, with character validation
    if (FieldType == 'phone')
    {
        if((oDiv.value.length < 10)||(oDiv.value.length > 17))
        {
            field_valid = 0;
        }
        
        s = oDiv.value;
		var v = "0123456789-() ";
		for (i=0; i < s.length; i++) {
		x = s.charAt(i);
		if (v.indexOf(x,0) == -1)
			field_valid = 0;
		}
    }
	
	// - date with xx/xx/xx validation where x is a number
    if (FieldType == 'date_field')
    {
        // - check length
		if((oDiv.value.length < 8)||(oDiv.value.length > 10))
        {
            field_valid = 0;
        }	
        // - validate character and replace invalid separators
        s = oDiv.value;
		var v = "0123456789/";
		var w = "-.:";
		for (i=0; i < s.length; i++) 
		{
			x = s.charAt(i);
			if (v.indexOf(x,0) == -1)
			{
				field_valid = 0;
				if (w.indexOf(x,0) == -1)
				{
					oDiv.value = oDiv.value.replace(x,"");
				}
				else
				{
					oDiv.value = oDiv.value.replace(x,"/");
				}
			}
		}		
		// - check first slash location 
		p=oDiv.value.indexOf('/');
		if (p<1 || p>2)
		{
		    field_valid = 0;
		}
		// - check 2nd slash location
		q=oDiv.value.indexOf('/',p+1);
		if (q<p || q>(oDiv.value.length-5))
		{
		    field_valid = 0;
		}
		// - check to see if there are two numbers in the last section
		if (oDiv.value.length - q >5)
		{
		    field_valid = 0;
		}
		// - validate date is greater than today
		var a = new Date();
        var m = a.getMonth();
        var y = a.getFullYear();
        var d = a.getDate();
        m = m + 1;
		//if (y > 100) y= y-100;
		// - parse out the day month year
		date_elements = oDiv.value.split("/");
        // - check the year       
		if (date_elements[2] < y) field_valid = 0;
		if ((date_elements[2] == y)&&(date_elements[0] < m)) field_valid = 0;
        if ((date_elements[2] == y)&&(date_elements[0] == m)&&(date_elements[1] < d)) field_valid = 0;
    }
	
    // - email no less than 5, with character validation for '@' and '.'
    if (FieldType == 'email')
    {
        if(oDiv.value.length < 5)
        {
            field_valid = 0;
        }
        // - check where '@' is at
        p=oDiv.value.indexOf('@');
        d=oDiv.value.indexOf('.',p);
		if (p<1 || p==(oDiv.value.length-2))
		{
		    field_valid = 0;
		}
		// - check where '.' is at        
		if (d<1 || d>(oDiv.value.length-3))
		{
		    field_valid = 0;
		}
		// - make sure '@' is before '.'
		if (d<p)
		{
		    field_valid = 0;
		}
    }
    // - currency
    if (FieldType == 'currency')
    {
        // - check size
        if(oDiv.value.length < 1)
        {
            field_valid = 0;
        }
        // - check where '$' is at
        p=oDiv.value.indexOf('$');
        d=oDiv.value.indexOf('.');
		if ((p > 0)||(p==oDiv.value.length-1))
		{
		    field_valid = 0;
		}
		// - check where '.' is at        
		if ((d!=oDiv.value.length-3)&&(d!=-1))
		{
		    field_valid = 0;
		}
		// - make sure '$' is before '.',ignor if '.' not exist
		if ((d<p)&&(d!=-1))
		{
		    field_valid = 0;
		}
		// - validate characters
		s = oDiv.value;
		var v = "0123456789$.";
		for (i=0; i < s.length; i++) {
		x = s.charAt(i);
		if (v.indexOf(x,0) == -1)
			field_valid = 0;
		}
    }
    // - qty
    if (FieldType == 'qty')
    {
        var base_price = document.getElementById('base_price');
        var oDivPrev = document.getElementById(ElementId-1);
        var multiplier = 0;
        // - validate characters
		s = oDivPrev.value;
		var v = "0123456789";
		for (i=0; i < s.length; i++) {
		x = s.charAt(i);
		if (v.indexOf(x,0) == -1)
			//field_valid = 0;
			oDivPrev.value = oDivPrev.value.replace(x,"");
		}
        // - check qty type
        if ((oDivPrev.value == "")||(oDivPrev.value == "0"))
        {
            field_valid = 0;            
        }
        else
        {
            multiplier = oDivPrev.value;
            var base_price = parseFloat(base_price.value);
            var multiplier = parseFloat(multiplier);
            var total_cost = base_price;
            change_array(oDivPrev,ElementId-1,field_valid);
            oDiv.value = '$'+base_price*multiplier+'.00';    
        }    
    }
    // - creditcard
    if (FieldType == 'creditcard')
    {
		loop_ctr = 0;
		for (var i=0; i < document.reservation_form.Transactions_PaymentType.length; i++)
		{
		 	//alert(i+':'+document.reservation_form.Transactions_PaymentType[i].checked);
			if (document.reservation_form.Transactions_PaymentType[i].checked == true)
			{
			  	loop_ctr += 1;
				if (loop_ctr >30) return;
				var oDivPrev = document.reservation_form.Transactions_PaymentType[i];	
				
				// - check cc type
				if (oDivPrev.value == null)
				{
					field_valid = 0;
				}
				change_array(ElementId-1,field_valid,FieldType,FieldLocation);
				//check the cc number
				//field_valid = 1;
				// - if dash or space remove it
				p=oDiv.value.indexOf('-');
				d=oDiv.value.indexOf(' ');
				if ((p>0)||(d>0))
				{
					//alert("Please do not use '-', Thank you.");
					oDiv.value = oDiv.value.replace('-',"");
					oDiv.value = oDiv.value.replace(' ',"");
				}
				// - validate characters
				s = oDiv.value;
				if (s.length > 0)
				{
				  var v = "0123456789";
				  for (i=0; i < s.length; i++) 
				  {
				    x = s.charAt(i);
				    if (v.indexOf(x,0) == -1) {field_valid = 0;}
				  }
				}
				// - check first value and match with cc type
				f = oDiv.value.substring(0,1);
				//alert(f+':'+oDivPrev.value);
				if (((oDivPrev.value == 'Mastercard')&&(f != 5))||((oDivPrev.value == 'Visa')&&(f != 4))||((oDivPrev.value == 'Discover Card')&&(f != 6))||	((oDivPrev.value == 'American Express')&&(f != 3)))
				{
					field_valid = 0;
				}
				
				// - between 13 and 16 characters
				if((oDiv.value.length < 13)||(oDiv.value.length > 16))
				{
					field_valid = 0;
				}
			}
		 }
    }
    // - date
    if (FieldType == 'date')
    {
        var d = new Date();
        var m = d.getMonth();
        var y = d.getFullYear();
        var oDivPrev = document.getElementById(ElementId-1);
        m = m + 1;
        // - check the year
        if ((oDiv.value == "")||(oDivPrev.value == ""))
        {
            field_valid = 0;
        }       
        if (((oDiv.value == y)&&(oDivPrev.value < m))||(oDiv.value < y))
        {
            field_valid = 0;
        }
		change_array(ElementId-1,field_valid,FieldType,FieldLocation-1); 
    }

    change_array(ElementId,field_valid,FieldType,FieldLocation);
    
}

function shipping_is_billing(ElementId,Process_Fields)
{
	var oDiv = document.getElementById(ElementId);

	a = document.getElementById(9);
	b = document.getElementById(10);
	c = document.getElementById(11);
	d = document.getElementById(12);
	e = document.getElementById(13);
	if (oDiv.checked == true)
	{
		a.value = document.getElementById(1).value;
		a.readOnly = true;
		field_check(9)
		b.value = document.getElementById(2).value;
		b.readOnly = true;
		field_check(10)
		c.value = document.getElementById(3).value;
		c.readOnly = true;
		field_check(11)
		d.value = document.getElementById(4).value;
		d.readOnly = true;
		field_check(12)
		e.value = document.getElementById(5).value;
		e.readOnly = true;
		field_check(13)
	}
	else
	{
		a.value = "";
		a.readOnly = false;
		if (Process_Fields == 1) a.style.border="2px solid red";
		b.value = "";
		b.readOnly = false;
		if (Process_Fields == 1) b.style.border="2px solid red";
		c.value = "";
		c.readOnly = false;
		if (Process_Fields == 1) c.style.border="2px solid red";
		d.value = "";
		d.readOnly = false;
		if (Process_Fields == 1) d.style.border="2px solid red";
		e.value = "";
		e.readOnly = false;
		if (Process_Fields == 1) e.style.border="2px solid red";
	}

}

function check_shipping()
{
	for (var i=0; i < document.reservation_form.Transactions_ShippingMethod.length; i++)
	{
		if (document.reservation_form.Transactions_ShippingMethod[i].checked)
		{
			add_in_shipping(i+1);
		}
	 }
}

function calculate_shipping()
{
	Total_Qty = document.getElementById('Total_Qty'); 
	a = document.getElementById('ship_a');
	b = document.getElementById('ship_b');
	c = document.getElementById('ship_c');
	ShipValue = new Array();
	//alert(Total_Qty.value);
	if (Total_Qty.value == 0) 
	{
		a.innerHTML = "0.00";
		b.innerHTML = "0.00";
		c.innerHTML = "0.00";
		ShipValue[0] = "0.00";
		ShipValue[1] = "0.00";
		ShipValue[2] = "0.00";
	}
	if ((Total_Qty.value >= 1) && (Total_Qty.value <= 5)) 
	{
		a.innerHTML = "6.00";
		b.innerHTML = "12.00";
		c.innerHTML = "30.00";
		ShipValue[0] = "6.00";
		ShipValue[1] = "12.00";
		ShipValue[2] = "30.00";
	}
	if ((Total_Qty.value >= 6) && (Total_Qty.value <= 10)) 
	{
		a.innerHTML = "7.00";
		b.innerHTML = "14.00";
		c.innerHTML = "34.00";
		ShipValue[0] = "7.00";
		ShipValue[1] = "14.00";
		ShipValue[2] = "34.00";
	}
	if ((Total_Qty.value >= 11) && (Total_Qty.value <= 15)) 
	{
		a.innerHTML = "8.00";
		b.innerHTML = "16.00";
		c.innerHTML = "37.00";
		ShipValue[0] = "8.00";
		ShipValue[1] = "16.00";
		ShipValue[2] = "37.00";
	}
	if (Total_Qty.value >= 16) 
	{
		a.innerHTML = "9.00";
		b.innerHTML = "18.00";
		c.innerHTML = "40.00";
		ShipValue[0] = "9.00";
		ShipValue[1] = "18.00";
		ShipValue[2] = "40.00";
	}
	return ShipValue;
}

function calculate_taxes()
{
	var Tax_Rate = document.getElementById('Tax_Rate');
	var a = document.getElementById('Transactions_Taxes');
	var b = document.getElementById('Transactions_ShippingCost');
	var c = document.getElementById('Transactions_SubTotal');
	var d = document.getElementById('Transactions_Amount');
	var Transactions_Amount_Out = document.getElementById('Transactions_Amount_Out');
	var Transactions_Taxes_Out = document.getElementById('Transactions_Taxes_Out');
	var States_val = document.getElementById('4');
	if ((States_val.value == "ca")||(States_val.value == "Ca")||(States_val.value == "cA")||(States_val.value == "CA"))
	{
		Tax_Value = (Tax_Rate.value * c.value)/100;
		//alert(Tax_Value);
	}
	else
	{
		Tax_Value = 0;
	}
	
	a.value = Tax_Value;
	Transactions_Taxes_Out.innerHTML = '$'+formatCurrency(Tax_Value);
	calc_total = (parseFloat(c.value) + parseFloat(b.value) + parseFloat(a.value));
	d.value = calc_total;
	Transactions_Amount_Out.innerHTML = '$'+formatCurrency(calc_total);
	
}

function formatCurrency(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

function add_in_shipping(shipping_type)
{
	var a = document.getElementById('Transactions_Taxes');
	var b = document.getElementById('Transactions_ShippingCost');
	var c = document.getElementById('Transactions_SubTotal');
	var d = document.getElementById('Transactions_Amount');
	var Transactions_Amount_Out = document.getElementById('Transactions_Amount_Out');
	ShipValue = calculate_shipping();
	if (shipping_type == 1) ShippingValue = ShipValue[0];
	if (shipping_type == 2) ShippingValue = ShipValue[1];
	if (shipping_type == 3) ShippingValue = ShipValue[2];
	b.value = ShippingValue;
	if (a.value <= 0) a.value =0;
	calc_total = (parseFloat(c.value) + parseFloat(ShippingValue) + parseFloat(a.value));	
	d.value = calc_total;
	Transactions_Amount_Out.innerHTML = '$'+formatCurrency(calc_total);	
}

function change_array(ElementId,field_valid,FieldType,FieldLocation)
{
    var oDiv = document.getElementById(ElementId);
	var array_values = document.getElementById('array_values');
	
    // - set the array
    if(field_valid == 1)
    {
       oDiv.style.border="2px solid lightgreen"; 
       ElementCnt[FieldLocation] = 1;
    }
    else
    {
       oDiv.style.border="2px solid red";
       ElementCnt[FieldLocation] = 0;
    }

// - set hidden field to the array
    array_values.value = ElementCnt;
}
//===========================================================================================
//submitting form functions
//===========================================================================================
function submitform(formName) 
{
  a = eval('document.' + formName)
  a.submit();
}

function ConfirmChoiceUrl(alertmsg, url) 
{ 
	if (confirm(alertmsg)) 
	{
		document.location.href = url;
	}	 
	else 
	{
		return false;
	}
}

function ConfirmChoice(alertmsg) 
{ 
	if (confirm(alertmsg)) 
	{
		return true;
	}	 
	else 
	{
		return false;
	}
}
//===========================================================================================
// list functions
//===========================================================================================
// select the items in list for submital
function selectlist(formName, formfield) 
{
	a = eval('document.'+formName+'.'+formfield)
	for (var i=0; i<a.options.length; i++) 
	{
		a.options[i].selected = true;
	}
}
// -------------------------------------------------------------------
// selectMatchingOptions(select_object,regex)
//  This function selects all options that match the regular expression
//  passed in. Currently-selected options will not be changed.
// -------------------------------------------------------------------
function selectMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"select",false);
	}
// -------------------------------------------------------------------
// selectOnlyMatchingOptions(select_object,regex)
//  This function selects all options that match the regular expression
//  passed in. Selected options that don't match will be un-selected.
// -------------------------------------------------------------------
function selectOnlyMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"select",true);
	}
// -------------------------------------------------------------------
// unSelectMatchingOptions(select_object,regex)
//  This function Unselects all options that match the regular expression
//  passed in. 
// -------------------------------------------------------------------
function unSelectMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"unselect",false);
	}
	
// -------------------------------------------------------------------
// sortSelect(select_object)
//   Pass this function a SELECT object and the options will be sorted
//   by their text (display) values
// -------------------------------------------------------------------
function sortSelect(obj) {
	var o = new Array();
	if (obj.options==null) { return; }
	for (var i=0; i<obj.options.length; i++) {
		o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
		}
	if (o.length==0) { return; }
	o = o.sort( 
		function(a,b) { 
			if ((a.text+"") < (b.text+"")) { return -1; }
			if ((a.text+"") > (b.text+"")) { return 1; }
			return 0;
			} 
		);

	for (var i=0; i<o.length; i++) {
		obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
		}
	}

// -------------------------------------------------------------------
// selectAllOptions(select_object)
//  This function takes a select box and selects all options (in a 
//  multiple select object). This is used when passing values between
//  two select boxes. Select all options in the right box before 
//  submitting the form so the values will be sent to the server.
// -------------------------------------------------------------------
function selectAllOptions(obj) {
	for (var i=0; i<obj.options.length; i++) {
		obj.options[i].selected = true;
		}
	}
	
// -------------------------------------------------------------------
// moveSelectedOptions(select_object,select_object[,autosort(true/false)[,regex]])
//  This function moves options between select boxes. Works best with
//  multi-select boxes to create the common Windows control effect.
//  Passes all selected values from the first object to the second
//  object and re-sorts each box.
//  If a third argument of 'false' is passed, then the lists are not
//  sorted after the move.
//  If a fourth string argument is passed, this will function as a
//  Regular Expression to match against the TEXT or the options. If 
//  the text of an option matches the pattern, it will NOT be moved.
//  It will be treated as an unmoveable option.
//  You can also put this into the <SELECT> object as follows:
//    onDblClick="moveSelectedOptions(this,this.form.target)
//  This way, when the user double-clicks on a value in one box, it
//  will be transferred to the other (in browsers that support the 
//  onDblClick() event handler).
// -------------------------------------------------------------------
function moveSelectedOptions(from,to) {
	// Unselect matching options, if required
	if (arguments.length>3) {
		var regex = arguments[3];
		if (regex != "") {
			unSelectMatchingOptions(from,regex);
			}
		}
	// Move them over
	for (var i=0; i<from.options.length; i++) {
		var o = from.options[i];
		if (o.selected) {
			to.options[to.options.length] = new Option( o.text, o.value, false, false);
			}
		}
	// Delete them from original
	for (var i=(from.options.length-1); i>=0; i--) {
		var o = from.options[i];
		if (o.selected) {
			from.options[i] = null;
			}
		}
	if ((arguments.length<3) || (arguments[2]==true)) {
		//sortSelect(from);
		//sortSelect(to);
		}
	from.selectedIndex = -1;
	to.selectedIndex = -1;
	}

// -------------------------------------------------------------------
// copySelectedOptions(select_object,select_object[,autosort(true/false)])
//  This function copies options between select boxes instead of 
//  moving items. Duplicates in the target list are not allowed.
// -------------------------------------------------------------------
function copySelectedOptions(from,to) 
{
	var options = new Object();
	for (var i=0; i<to.options.length; i++) 
	{
		options[to.options[i].value] = to.options[i].text;
	}
	for (var i=0; i<from.options.length; i++) 
	{
		var o = from.options[i];
		if (o.selected) 
		{
			if (options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text) 
			{
				to.options[to.options.length] = new Option( o.text, o.value, false, false);
			}
		}
	}
	
	//if ((arguments.length<3) || (arguments[2]==true)) 
	//{
	//	sortSelect(to);
	//}
	from.selectedIndex = -1;
	to.selectedIndex = -1;
	}

// -------------------------------------------------------------------
// moveAllOptions(select_object,select_object[,autosort(true/false)[,regex]])
//  Move all options from one select box to another.
// -------------------------------------------------------------------
function moveAllOptions(from,to) {
	selectAllOptions(from);
	if (arguments.length==2) {
		moveSelectedOptions(from,to);
		}
	else if (arguments.length==3) {
		moveSelectedOptions(from,to,arguments[2]);
		}
	else if (arguments.length==4) {
		moveSelectedOptions(from,to,arguments[2],arguments[3]);
		}
	}

// -------------------------------------------------------------------
// copyAllOptions(select_object,select_object[,autosort(true/false)])
//  Copy all options from one select box to another, instead of
//  removing items. Duplicates in the target list are not allowed.
// -------------------------------------------------------------------
function copyAllOptions(from,to) {
	selectAllOptions(from);
	if (arguments.length==2) {
		copySelectedOptions(from,to);
		}
	else if (arguments.length==3) {
		copySelectedOptions(from,to,arguments[2]);
		}
	}

// -------------------------------------------------------------------
// swapOptions(select_object,option1,option2)
//  Swap positions of two options in a select list
// -------------------------------------------------------------------
function swapOptions(obj,i,j) {
	var o = obj.options;
	var i_selected = o[i].selected;
	var j_selected = o[j].selected;
	var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
	var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
	o[i] = temp2;
	o[j] = temp;
	o[i].selected = j_selected;
	o[j].selected = i_selected;
	}
	
// -------------------------------------------------------------------
// moveOptionUp(select_object)
//  Move selected option in a select list up one
// -------------------------------------------------------------------
function moveOptionUp(obj) {
	for (i=0; i<obj.options.length; i++) {
		if (obj.options[i].selected) {
			if (i != 0 && !obj.options[i-1].selected) {
				swapOptions(obj,i,i-1);
				obj.options[i-1].selected = true;
				}
			}
		}
	}

// -------------------------------------------------------------------
// moveOptionDown(select_object)
//  Move selected option in a select list down one
// -------------------------------------------------------------------
function moveOptionDown(obj) {
	for (i=obj.options.length-1; i>=0; i--) {
		if (obj.options[i].selected) {
			if (i != (obj.options.length-1) && ! obj.options[i+1].selected) {
				swapOptions(obj,i,i+1);
				obj.options[i+1].selected = true;
				}
			}
		}
	}

// -------------------------------------------------------------------
// removeSelectedOptions(select_object)
//  Remove all selected options from a list
//  (Thanks to Gene Ninestein)
// -------------------------------------------------------------------
function removeSelectedOptions(from) { 
	for (var i=(from.options.length-1); i>=0; i--) { 
		var o=from.options[i]; 
		if (o.selected) { 
			from.options[i] = null; 
			} 
		} 
	from.selectedIndex = -1; 
	} 

// -------------------------------------------------------------------
// removeAllOptions(select_object)
//  Remove all options from a list
// -------------------------------------------------------------------
function removeAllOptions(from) { 
	for (var i=(from.options.length-1); i>=0; i--) { 
		from.options[i] = null; 
		} 
	from.selectedIndex = -1; 
	} 

// -------------------------------------------------------------------
// addOption(select_object,display_text,value,selected)
//  Add an option to a list
// -------------------------------------------------------------------
function addOption(obj,text,value,selected) {
	if (obj!=null && obj.options!=null) {
		obj.options[obj.options.length] = new Option(text, value, false, selected);
		}
	}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function mvOption(selectObj, dir)
{
//var selectObj = document.getElementById(target_obj);
if(selectObj.length==-1) {
	alert("There are no values which can be moved!");
	}
else {
	var selected = selectObj.selectedIndex;
	if(selected==-1) {
		alert("You must select an entry to be moved!");
		}
	else {
		if(selectObj.length==0) { 
			alert("There is only one entry!\nThe one entry will remain in place.");
			}
		else {
			//Configure variables
			if(dir==1) {
				condition = 0;
				msg = "The first entry in the list cannot be moved up.";
				index = selected-1;
				}
			else {
				msg = "The last entry in the list cannot be moved down.";
				index = selected+1;
				condition = selectObj.length-1;
				}
			if(selected==condition) {
				alert(msg);
				}
			else {
				var moveText1 = selectObj.options[index].text;
				var moveText2 = selectObj.options[selected].text;
				var moveValue1 = selectObj.options[index].value;
				var moveValue2 = selectObj.options[selected].value;
				selectObj.options[selected].text = moveText1;
				selectObj.options[selected].value = moveValue1;
				selectObj.options[index].text = moveText2;
				selectObj.options[index].value = moveValue2;
				selectObj.selectedIndex = index;
				//alert(selectObj.scrollTop);
				//selectObj.options[selected].selected = true;
				//selectObj.options[selected].selected = false;
				//selectObj.options[selected].focus();
				//selectObj.scrollBy(10,0);
				}
			}
		}
	}
}

function show_preview_image(image_location)
{
	blendimage('prev_img_div', 'preview_image', image_location, 600);
}
function show_preview_imageA(image_location)
{
	blendimage('prev_img_divA', 'preview_imageA', image_location, 600);
}
function show_preview_imageB(image_location,image_location_save)
{
	blendimage('prev_img_div', 'preview_image', image_location, 600);
	document.getElementById('Pics_Link').value = image_location_save;
	document.getElementById('Pics_Link_Alt').value = image_location_save;
}
function show_preview_imageC(image_location)
{
	blendimage('prev_img_div', 'preview_image', image_location, 600);
}
function show_preview_imageD(image_location,image_location_save,Products_ID,Products_Name,Products_Description,Products_SKU,Products_Price,Products_PriceDiscount)
{

	blendimage('prev_img_div', 'preview_image', image_location, 600);
	document.getElementById('Pics_Link').value = image_location_save;
	document.getElementById('Pics_Link_Alt').value = image_location_save;
	document.getElementById('ProductsAlt_ID').value = Products_ID;
	//alert(Products_Description);
    if (Products_PriceDiscount.length > 0)
	{
		Products_Price = "<strike><font color='red'>$" + formatCurrency(Products_Price) + "</font></strike> $" + formatCurrency(Products_PriceDiscount) 
	}
	else
	{
		Products_Price = "$" + formatCurrency(Products_Price)
	}

	try
	{
	  if(Products_ID.length > 0)
	  {
		  document.getElementById('product_info').innerHTML="<table><tr><td nowrap><h3>"+Products_Name+"["+Products_SKU+"]</h3></td></tr><tr><td>"+Products_Description+"</td></tr><tr><td nowrap>"+Products_Price+"</td></tr></table>";
	  }
	  else
	  {
		  document.getElementById('product_info').innerHTML="";
	  }
	}
	catch (err)
	{
		document.getElementById('product_info').innerHTML="";	
	}
}

function validate_alt_products()
{
	if (document.getElementById('ProductsAlt_ID').value == "") 
	{
		alert("Selected image needs to be linked to a product.\nMake sure it has product info listed.");
		return false;
	}
	return true;
}

function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    //make image transparent
    changeOpac(0, imageid);
    
    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for(i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
}
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--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            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 + ")";
} 