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_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_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 countdown_clock(year, month, day, hour, minute, format)
         {
         //I chose a div as the container for the timer, but
         //it can be an input tag inside a form, or anything
         //who's displayed content can be changed through
         //client-side scripting.
         html_code = '<div id="countdown"></div>';
         
         document.write(html_code);
         
         countdown(year, month, day, hour, minute, format);                
         }
         
function countdown(year, month, day, hour, minute, format)
         {
         Today = new Date();
         Todays_Year = Today.getFullYear() - 2000;
         Todays_Month = Today.getMonth() + 1;                  
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
         Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();                  
         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
         
         if(Time_Left < 0)
            Time_Left = 0;
         
         switch(format)
               {
               case 0:
                    //The simplest way to display the time left.
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
                    break;
               case 1:
                    //More datailed.
                    days = Math.floor(Time_Left / (60 * 60 * 24));
                    Time_Left %= (60 * 60 * 24);
                    hours = Math.floor(Time_Left / (60 * 60));
                    Time_Left %= (60 * 60);
                    minutes = Math.floor(Time_Left / 60);
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    dps = 's'; hps = 's'; mps = 's'; sps = 's';
                    //ps is short for plural suffix.
                    if(days == 1) dps ='';
                    if(hours == 1) hps ='';
                    if(minutes == 1) mps ='';
                    if(seconds == 1) sps ='';
                    
                    document.all.countdown.innerHTML = days + ' day' + dps + ' ';
                    document.all.countdown.innerHTML += hours + ' hour' + hps + ' ';
                    document.all.countdown.innerHTML += minutes + ' minute' + mps + ' and ';
                    document.all.countdown.innerHTML += seconds + ' second' + sps;
                    break;
               default: 
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
               }
               
         //Recursive call, keeps the clock ticking.
         setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
         }


function openAttributeWindow(theURL,winName,features) {
popup = window.open(theURL,winName,features);
popup.moveTo((screen.width-350)/2,(screen.height-340)/2);
}

function cmdEmailFriend(prodname, RURL) {
var URL = "emailafriend.aspx";
window.open(URL + "?PRODNAME=" + prodname + "&RURL=" + RURL, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=440,height=475,left=200,top=0');
}

function galleryPopupH(URL,IMG,IWIDTH,IHEIGHT) {
window.open(URL + "?IMAG=" + IMG + "&IWIDTH=" + IWIDTH + "&IHEIGHT=" + IHEIGHT, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=380,left=400,top=0');
}

function galleryPopupV(URL,IMG,IWIDTH,IHEIGHT) {
window.open(URL + "?IMAG=" + IMG + "&IWIDTH=" + IWIDTH + "&IHEIGHT=" + IHEIGHT, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=380,height=482,left=400,top=0');
}

function pagingcatalog(redirectpage)
	{
	
	var message=redirectpage;
	var word=message.split(',');
	window.location.href="catalog.aspx?categoryID=" + word[0] + "&subcategoryID=" + word[1] + "&page=" + word[2] + "&dtype=" + word[3];
	
	}
	
	
	function pagingsubcatalog(redirectpage)
	{
	
	var message=redirectpage;
	var word=message.split(',');
	window.location.href="subcatalog.aspx?categoryID=" + word[0] + "&subcategoryID=" + word[1] + "&page=" + word[2] + "&dtype=" + word[3];
	
	}
	
function pagingsearchresults(redirectpage)
	{
	
	var message=redirectpage;
	var word=message.split(',');
	window.location.href="searchresults.aspx?page=" + word[2] + "&sb=" + word[4] + "&dtype=" + word[3];
	
	}
	
function filter(redirectpage)
	{
	var message=redirectpage;
	var word=message.split('-');
	window.location.href="catalog.aspx?categoryID=" + word[0] + "&subcategoryID=" + word[1] + "&page=1&dtype=" + word[3];
	
	}
	
function filtersr(redirectpage)
	{
	
	var message=redirectpage;
	var word=message.split('-');
	window.location.href="searchresults.aspx?page=1" + "&sb=" + word[4] + " &dtype=" + word[3];
	
	}
	

function popup_author(redirectpage) 
{


	window.open("author.aspx?ID=" + redirectpage, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=380,left=400,top=0');
		
}

//function right(e) {
//if (navigator.appName == 'Netscape' && 
//(e.which == 3 || e.which == 2))
//return false;
//else if (navigator.appName == 'Microsoft Internet Explorer' && 
//(event.button == 2 || event.button == 3)) {
//alert("Copyright 2004 SabrinasBoutique \nALL RIGHTS RESERVED");
//return false;}
//return true;}
//document.onmousedown=right;
//if (document.layers) window.captureEvents(Event.MOUSEDOWN);
//window.onmousedown=right;



function cmdSearch()
{
	tvalue= document.all.bsearch.value
	if (tvalue.length >= 3)
	{
	window.location.href="searchresults.aspx?sb=" + tvalue
	}
	else
	{
		alert ("Sorry, we are unable to perform the search.  Please try using the advanced search.");
	}
}

function pchange(obj, myevent){

	if ( myevent == 1 ) {
		obj.style.background = '#FFFFFF'; //#339933
	}
	if ( myevent == 0 ) {
		obj.style.background = '#FFFFFF';
		prevVal = obj.value;
	}
	
}
function dosubmit()
{
	
	var x=0;
	for(x=0;x<addtocart.txtQty.length;x++)
	{
		if (isNaN(addtocart.txtQty[x].value))
		{
			alert("Quantity must be numeric");
			addtocart.txtQty[x].focus();
			return false;			
		}
		else
		{
			if(addtocart.txtQty[x].value<0)
			{
				alert("Quantity can't be less then zero ");
				addtocart.txtQty[x].focus();
				return false;
			}
		}
	}
	if(x==0)
	{
		if (isNaN(addtocart.txtQty.value))
		{
			alert("Quantity must be numeric");
			addtocart.txtQty.focus();
			return false;			
		}
		else
		{
			if(addtocart.txtQty.value<0)
			{
				alert("Quantity can't be less then zero ");
				addtocart.txtQty.focus();
				return false;
			}
		}
	}
	addtocart.submit();	
}

function selectall()
{
var chk=addtocart.chkSelectAll.checked;
var i=0;
	for(i=0;i<addtocart.chkproductid.length;i++)
	{
		addtocart.chkproductid[i].checked=chk;
	}
	if(i==0)
	{
		addtocart.chkproductid.checked=chk;
	}
}

function chkisSelected()
{
var chk=addtocart.chkSelectAll.checked;
var i=0;
	for(i=0;i<addtocart.chkproductid.length;i++)
	{
		if(addtocart.chkproductid[i].checked)
		{
			return true;
		}
		
	}
	if(i==0)
	{
		if(addtocart.chkproductid.checked)
			return true;
	}
	return false;
}

function cmdDelClick()
{
	if(chkisSelected())
	{
		addtocart.submit();
	}
	else
	{
		alert('Please select at least one item form the cart to delete');		
	}
}

function same()
{
	if (checkout.chkSame.checked==true)
	{
		checkout.txtShippingAddress.value=checkout.txtBillingAddress.value;
		checkout.txtShippingCity.value=checkout.txtBillingCity.value;
		checkout.txtShippingState.value=checkout.txtBillingState.value;
		checkout.txtShippingCountry.value=checkout.txtBillingCountry.value;
		checkout.txtShippingPostalcode.value=checkout.txtBillingPostalcode.value;
		checkout.txtShippingPhone.value=checkout.txtBillingPhone.value;
	}
	else
	{
		checkout.txtShippingAddress.value="";
		checkout.txtShippingCity.value="";
		checkout.txtShippingState.value="";
		checkout.txtShippingCountry.value="";
		checkout.txtShippingPostalcode.value="";
		checkout.txtShippingPhone.value=""
	}
}
		
function toggle( targetId ){
		target1 = targetId + 'IMG'
  		target = document.all( targetId );
  		//targetImg = document.all( target1 );
  		
  		  		if (target.style.display == "none"){
  				target.style.display = "";
   				//targetImg.value = "-"
  			} else {
  				target.style.display = "none";
  				//targetImg.value = "+"
  			}
}

function ToggleDisplay(id)
  {
    var elem = document.getElementById('d' + id);
    if (elem) 
    {
      if (elem.style.display != 'block') 
      {
        elem.style.display = 'block';
        elem.style.visibility = 'visible';
      } 
      else
      {
        elem.style.display = 'none';
        elem.style.visibility = 'hidden';
      }
    }
  }

function toggleeffect( targetId ){
		target1 = targetId + 'IMG'
  		target = document.all( targetId );
  		alert('ok');
  		 		alert(target.style.display);
  		  		if (target.style.display == "none"){
  				target.style.display = "";
   		
  			} else {
  				target.style.display = "none";
  		
  			}
}

function cmdVideo()
{
winURL = "popup.aspx" 
features = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=357,height=300" 
mwidth = "screen.width-357" 
mheight = "screen.height-300" 
popup = window.open(winURL,'',features);
popup.moveTo((mwidth)/2,(mheight)/2);
}

function popup_supersize(ID, iWIDTH, iHEIGHT, strFile)
{
iWIDTH = iWIDTH
iHEIGHT = iHEIGHT
winURL = "supersize.aspx?productid=" + ID + "&photoid=" + strFile
features = "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + iWIDTH + ",height=" + iHEIGHT 

popup = window.open(winURL,'',features);

}

function swapLargePhoto(intSubID)
{
if (intSubID != "0")
{
var LargeImgName="";
var LargeImgValue="";
var DisplayName="";
var DisplayValue="";

DisplayName = "bname" + intSubID
LargeImgName = "GetLargeImg" + intSubID
LargeImgValue = document.all[LargeImgName].value
DisplayValue = document.all[DisplayName].value

if (LargeImgValue != "NONE")
{

document.all.imglarge.src = "library/" + LargeImgValue
document.all.CustomImage.value = intSubID

document.all.attribute0.value = intSubID
//document.all.lblbeaddesc.value = DisplayValue;
}
else
{
document.all.imglarge.src = "images/spacer.gif";
}

}
}

//function swapLargePhoto1(intSubID)
//{
//	if (intSubID != "0")
//	{
//		var LargeImgName="";
//		var LargeImgValue="";
//
//		LargeImgName = "GetLargeImg" + intSubID
//		LargeImgValue = document.all[LargeImgName].value
//		//alert(document.all.NewImage.value);
//		if (LargeImgValue != "NONE") //&& (document.all.OrgLrgImage.value != document.all.NewImage.value))
//		{
//		document.all.imgProductLarge.src = "../library/uw/" + LargeImgValue
//		document.all.NewImage.value = "../library/uw/" + LargeImgValue
//		document.all.CustomImage.value = intSubID
//		}
//		//alert(document.all.NewImage.value)
//		//if (document.all.NewImage.value != "undefined" && (document.all.NewImage.value != "NONE"))
//		//{ 
//		//	
//		//}
//		//else
//		//{
//		//   document.all.CustomImage.value = 0
//		//}
//	
//	}
//	else
//	{
//		//alert("else");
//		//alert(document.all.NewImage.value);
//		//if (document.all.OrgLrgImage.value == document.all.NewImage.value)
//		//{
//		document.all.imgProductLarge.src = "../uw/" + document.all.OrgLrgImage.value
//		document.all.NewImage.value = document.all.OrgLrgImage.value
//		//}
//		//else
//		//{
//		//if (intSubID != "0" && (document.all.NewImage.value != "NONE"))
//		//	{
//		   document.all.CustomImage.value = 0
//		//	}
//		//}
//	}
//}

function AddToBag(SSLROOT)
{
var productid = addtocart.productid.value;
var attributename="";
var i=0;
var strAttributes="";
var bIsValid = true;
	for(i=0;i<addtocart.counter.value;i++)
	{
		
		if(i==0)
		{
		attributename = "attribute" + i 
		strAttributes = addtocart[attributename].value;
		if (addtocart[attributename].value == "0") {bIsValid = false;}
		}
		else
		{
		attributename = "attribute" + i 
		strAttributes = strAttributes + "," + addtocart[attributename].value;
		if (addtocart[attributename].value == "0") {bIsValid = false;}
		}
	}
	if (bIsValid)
	{
		if (strAttributes != "0,0")
		{
			window.location.href=SSLROOT + "/shoppingcart.aspx?productid=" + productid + "&att=" + strAttributes
		}
		else
		{
			window.location.href=SSLROOT + "/shoppingcart.aspx?productid=" + productid 
		}
	}
	else
	{
		alert("please choose your options");	
	}
	
}


