﻿// JScript File

function ValidateEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}

function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
	}


function swapImage(objTarget,objImage){

    var objImageSwap                        = document.getElementById(objTarget);
    objImageSwap.src                        = objImage;
}




function showHomepageFooter(){
    objHomepageFooter = document.getElementById('mainContentBg');
    objHomepageFooter.style.paddingBottom       = '5px';
}


var interval = 5; // delay between rotating images (in seconds)
var random_display = 0; // 0 = no, 1 = yes
interval *= 1000;

var image_index = 0;
image_list = new Array();

image_list[image_index++] = new imageItem('/images/homepage_image1.jpg');
image_list[image_index++] = new imageItem('/images/homepage_image2.jpg');
image_list[image_index++] = new imageItem('/images/homepage_image3.jpg');
image_list[image_index++] = new imageItem('/images/homepage_image4.jpg');
image_list[image_index++] = new imageItem('/images/homepage_image5.jpg');
image_list[image_index++] = new imageItem('/images/homepage_image6.jpg');


var number_of_image = image_list.length;

function imageItem(image_location) {

    this.image_item = new Image();
    this.image_item.src = image_location;
}

function get_ImageItemLocation(imageObj) {

    return(imageObj.image_item.src)
}

function generate(x, y) {

    var range = y - x + 1;
    return Math.floor(Math.random() * range) + x;
}

function getNextImage() {

    if (random_display) {
        image_index = generate(0, number_of_image-1);
    }
    else {
        image_index = (image_index+1) % number_of_image;
    }
    
    var new_image = get_ImageItemLocation(image_list[image_index]);
    return(new_image);
}

function rotateImage(place) {

    var new_image = getNextImage();
    document[place].src = new_image;
    var recur_call = "rotateImage('"+place+"')";
    setTimeout(recur_call, interval);
}


arrayTitle                                              = new Array();
arrayDescription                                        = new Array();

arrayTitle[0]                                           = 'What types of custom shirts are available?';
arrayDescription[0]                                     = 'We offer two levels of customization, Made-to-Measure and Bespoke.  Made-to-Measure allows you to choose from our most popular style and fit options, while Bespoke offers limitless options.';

arrayTitle[1]                                           = 'What is a “Bespoke Trial Shirt”?';
arrayDescription[1]                                     = 'On a first time bespoke order we construct a single shirt for your approval. After an initial fitting we will draft your paper pattern and construct a trial shirt in your selected fabric and style. The trial shirt is then delivered for a second fitting. After your second fitting, we will make any necessary adjustments and proceed with the balance of the order only upon your approval. We guarantee 100% satisfaction. If we are unable to provide a satisfactory trial shirt you may cancel your order.';

arrayTitle[2]                                           = 'What is a “Made-to-Measure Fit Shirt”?';
arrayDescription[2]                                     = 'Try-on shirts are available to help you determine collar or body size.';

arrayTitle[3]                                           = 'What is fusing, and why do most shirtmakers fuse collars and cuffs? Why does Hamilton not fuse collars and cuffs?';
arrayDescription[3]                                     = 'Collars and cuffs consist of an interlining sewn between two pieces of fabric. It’s this interlining that provides the necessary structure and weight. Most shirtmakers choose to glue, or fuse, the interlining to the fabric because it is an easy way to ensure the shirt looks crisp when new. The downside to fusing is that the shirt continues to shrink with each laundering as the glue contracts. It requires greater care and skill to construct an excellent non-fused collar. Non-fused shirts do not shrink after initial launderings.   ';

arrayTitle[4]                                           = 'Where will my shirts be made?';
arrayDescription[4]                                     = 'All Hamilton shirts are made in our Houston workshop. We invite you to visit our storefront and workshop where you can select fabrics from the bolt and observe the shirtmaking process.';

arrayTitle[5]                                           = 'How do I care for my shirts?';
arrayDescription[5]                                     = 'Most shirts can be sent to a commercial laundry. We recommend no starch. If dry cleaning is required, it will be indicated on a special care tag in the shirt. Your collar has been specially constructed to avoid excessive shrinkage after many launderings. We do not glue, or fuse, the interlining to the collar fabric. To avoid creasing, the collar should be pressed from the ends toward the center while slightly damp.';

arrayTitle[6]                                           = 'Do you make ladies shirts?';
arrayDescription[6]                                     = 'No.';

arrayTitle[7]                                           = 'Where are the fabrics from?';
arrayDescription[7]                                     = "We carry only the world's finest fabrics from exclusive European mills. Our suppliers are among the most sought after mills in Switzerland and Italy. They include Alumo, David John Anderson, Grandi and Rubinelli, Testa and Thomas Mason.";

arrayTitle[8]                                           = 'Do you send fabric samples?';
arrayDescription[8]                                     = 'Yes. To request a fabric sample, click on the provided link beneath the fabric image. See Fabrics';

arrayTitle[9]                                           = 'How often do you receive new fabrics?';
arrayDescription[9]                                     = 'Our Fall/Winter collection arrives in August and our Spring/Summer collection is available in February. We sometimes receive new fabrics mid-season and notify registered users upon arrival.';

arrayTitle[10]                                          = 'I saw a fabric on the web site a few months ago, but it is not there anymore, or it appears to be out of stock. Can I still order a shirt in this fabric?';
arrayDescription[10]                                    = 'Our inventory of available fabrics is constantly changing. Most fabrics are only available for a limited period of time. If a desired fabric is no longer available, please contact your local retailer or <a class="linkNormal" href="mailto:info@hamiltonshirts.com">info@hamiltonshirts.com</a> and we will be happy to help you locate a similar fabric if one is offered at that time.';

arrayTitle[11]                                          = 'Can I request different collars, cuffs, pockets etc. on each of my shirts?';
arrayDescription[11]                                    = 'Bespoke customers have the option to style your shirts however you like. Please <a class="linkNormal" href="/WebForms/Contact.aspx">contact us</a> for more information.<br><br>Made-to-measure customers have the option to select collar, cuff, pocket and monogram options.';

arrayTitle[12]                                          = 'Can you file my measurements for future orders? What if I need to make changes?';
arrayDescription[12]                                    = 'After your first order, all your measurements are kept on file. We will make any necessary changes to your measurements over time.';

arrayTitle[13]                                          = 'What about shrinkage?';
arrayDescription[13]                                    = 'To ensure consistent sizing over time and launderings we use only the finest fabrics and do not fuse collars or cuffs. Your shirts will arrive with a quarter inch allowance for shrinkage at the collar, cuffs and sleeves. After one or two launderings your shirt will arrive at its final predetermined size and should fit perfectly. ';

arrayTitle[14]                                          = 'How do I change or cancel my order?';
arrayDescription[14]                                    = 'Please call 713.264.8800 if you need to change your order. Please be advised that orders are put into production very soon after placement, and it will not always be possible to make changes.';

arrayTitle[15]                                          = 'Can I check the status of my order?';
arrayDescription[15]                                    = 'Your order status will be available 24 hours after your order has been placed. Email <a class="linkNormal" href="mailto:info@hamiltonshirts.com">info@hamiltonshirts.com</a> and include your first and last name and order date in the body of the email.';

arrayTitle[16]                                          = 'What is your procedure for shipping?';
arrayDescription[16]                                    = 'US Standard Delivery: +$7.95<br>5-9 Business Days<br><br>Expedited Delivery: +$19.95<br>2-4 Business Days<br><br>Express Delivery: +$39.95<br>1-3 Business Days';

arrayTitle[17]                                          = 'UPS Overnight Delivery: (Additional $30.00 charge)';
arrayDescription[17]                                    = 'In-stock items, ordered Monday through Friday by noon Eastern Time, excluding holidays, to arrive the next business day. Overnight delivery is an additional $22.50 for Alaska and Hawaii. Overnight delivery is currently not available for Puerto Rico and Canada. ';

arrayTitle[18]                                          = 'International Delivery: ($75.00 charge) ';
arrayDescription[18]                                    = 'Overnight delivery currently not available outside of the United States. All shipping & handling and applicable duties will be paid by the customer and will be billed by the delivery carrier. For more information email info@hamiltonshirts.com or call 713.264.8800.';

arrayTitle[19]                                          = 'How long will it take to receive my shirts?';
arrayDescription[19]                                    = 'Delivery is typically 2-3 weeks for existing customers. Of course, the process will be somewhat extended for first time Bespoke customers based upon your approval of a trial shirt.';

arrayTitle[20]                                          = 'Do you accept returns or exchanges?';
arrayDescription[20]                                    = '<u>Bespoke</u> <br>We do not refund payment on shirt returns without cause, as each shirt is made-to-order expressly for the customer. Any issues or concerns with an order should be addressed within 30 days of the shipping date. After 30 days, repair charges will apply to all returns.<br><br><u>Made-to-Measure</u><br>If you are not completely satisfied with your order we will gladly accept it for exchange or return within 30 days of the original purchase date.<ul><li>Please complete the Return Form below and enclose it in your package. </li><li>To request a Return Label email <a class="linkNormal" href="mailto:info@hamiltonshirts.com">info@hamiltonshirts.com</a> and include your full name and invoice number. Your invoice number can be found in the upper right corner of your invoice. We will email or fax a UPS Return Label for your convenience.</li><li>Apply the return label to the package and send it back within 30 days of the original purchase for a full refund. Please note this only applies to unwashed/unworn merchandise. If the item has been washed or worn it cannot be returned. </li><li>Enclose the completed Return form and the items you wish to return in a secure package. For your convenience you can re-use your original package.</li><li>Take the package to any location of The UPS Store, UPS Customer Center, or any UPS Authorized Shipping Outlet, or leave the package with any UPS driver. For the UPS location nearest you or to track your return package, go to UPS.com or call 1-800-PICK-UPS®<br>(1-800-742-8577).</li></ul><br>For use in the US and Puerto Rico only.';

arrayTitle[21]                                          = 'What are the fit differences between made-to-measure and bespoke?';
arrayDescription[21]                                    = 'Made-to-measure shirts are available in any combination of collar size, body size and sleeve length.  Bespoke shirts are cut according to your personal paper pattern.  We create your pattern after an in-store fitting.  ';

arrayTitle[22]                                          = 'Are try-on shirts available?';
arrayDescription[22]                                    = 'Yes.  To request a try-on shirt please Email or call us at 713.264.8800.  There is no charge for shipping.  We do require a $25 refundable deposit per shirt.';

arrayTitle[23]                                          = 'What is your return policy?';
arrayDescription[23]                                    = 'For online purchases, credit or exchange is accepted within 30 days of the original purchase date.  There is no re-stocking fee on exchanges. There is a $25 restocking fee on returns.  For in-store purchases, we do not offer credit or exchange.';

arrayTitle[24]                                          = 'What is your shipping policy?';
//arrayDescription[24]                                    = 'We ship in the continental US and Canada according to the below rates. Please e-mail <a class="linkNormal" href="mailto:info@hamiltonshirts.com">info@hamiltonshirts.com</a> for shipping costs to other locations.<br><br>Standard Domestic (5-9 business days) – Free<br>Standard Expedited (2-4 business days) – $19.95<br>Express Domestic (1-3 business days) – $39.95';
arrayDescription[24]                                    = 'We ship in the continental US and Canada according to the below rates. Please e-mail <a class="linkNormal" href="mailto:info@hamiltonshirts.com">info@hamiltonshirts.com</a> for shipping costs to other locations.<br><br>Standard Domestic (5-9 business days) – Free<br>Please allow an estimated 7 business days for production time.<br><br>Standard Expedited (2-4 business days) – $19.95<br>Please allow an estimated 5 business days for production time.<br><br>Express Domestic (1-3 business days) – $39.95<br>Please allow an estimated 3 business days for production time.'


function showAnswer(iNumber){

    objTitle                                            = document.getElementById('faq_title');
    objDescription                                      = document.getElementById('faq_description');
        
    if (document.all){
        objTitle.innerHTML                              = arrayTitle[iNumber];
        objDescription.innerHTML                        = arrayDescription[iNumber];
    } else {
        objTitle.innerHTML                              = arrayTitle[iNumber];
        objDescription.innerHTML                        = arrayDescription[iNumber];
    }
    
}


      
 
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["/images/homepage_image1.jpg", "", ""] //plain image syntax
fadeimages[1]=["/images/homepage_image2.jpg", "link here", ""] //image with link syntax
fadeimages[2]=["/images/homepage_image3.jpg", "link here", "_new"] //image with link and target syntax
 
var fadeimages2=new Array() //2nd array set example. Remove or add more sets as needed.
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages2[0]=["/images/homepage_image1.jpg", "/WebForms/OurStory.aspx", ""] //plain image syntax
fadeimages2[1]=["/images/homepage_image2.jpg", "http://www.hamilton1883.com/blog/2010/03/03/the-esquire-collection/", "_blank"] //image with link syntax
fadeimages2[2]=["/images/homepage_image3.jpg", "/WebForms/Fabric.aspx", ""] //image with link and target syntax
fadeimages2[3]=["/images/homepage_image4.jpg", "/WebForms/Retailers.aspx", ""] //image with link and target syntax
fadeimages2[4]=["/images/homepage_image5.jpg","/WebForms/Custom.aspx", ""]
fadeimages2[5]=["/images/homepage_image6.jpg","http://www.hamilton1883.com", "_blank"]
 
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);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;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);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;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 if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
obj.tempobj.style.opacity=obj.degree/101
}
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=this.degree/100
else if (crossobj.style.opacity&&!crossobj.filters)
crossobj.style.opacity=this.degree/101
}
 
 
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()
}





//-->