
// function for email validation
function ValidateEmail(str1) {
    var RegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

    if (RegExp.test(str1.value)) {
        str1.style.border = 'solid 1px black';
        return true;
    }
    else {
        str1.style.border = 'solid 1px red';
        return false;
    }


} //end of function emailCheck

function clearEmailForm(frmEle){
//Clear the email form if customer clicks in the box
	if (frmEle.value == "Enter E-mail Here"){
		frmEle.value = "";
	}
}
function GiftCardCounter()
{
	var today = new Date();
	var hours = parseInt(today.getHours());
	// Have the starting point actually be at 5am not midnight.
	hours = hours - 4;
	if (hours < 0) hours = 23 + hours;
	var mins = parseInt(today.getMinutes());
	var totalMinutes = 999 - Math.round((((hours * 60) + mins) / 1.4));
	// Make sure there is a positive number of minutes.
	if (totalMinutes <= 0) totalMinutes = 20;
	if (document.getElementById('giftCardCounter')) document.getElementById('giftCardCounter').innerHTML = totalMinutes;
	setTimeout("GiftCardCounter()",60000); 
}
function Pricing(width,height,price,dualBlinds){
		this.width = width;
		this.height = height;
		this.price = price;
		this.dualBlinds = dualBlinds;
	}
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}
function tmt_findObj(n){
	var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
	x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	}else{x=document.getElementById(n)}return x;
}
function MM_showHideLayers() {
    var i, p, d, v, obj, args = MM_showHideLayers.arguments;
    if (document.getElementById) {
        for (i = 0; i < (args.length - 2); i += 3) {
            obj = tmt_findObj(args[i]); v = args[i + 2]; d = args[i + 2];
            v = (v == 'show') ? 'visible' : (v = 'hide') ? 'hidden' : v;
            d = (d == 'show') ? 'block' : (d = 'hide') ? 'none' : d;
            if (obj) { obj.style.visibility = v; obj.style.display = d; }
        }
    } else {
        for (i = 0; i < (args.length - 2); i += 3) if ((obj = MM_findObj(args[i])) != null) {
            v = args[i + 2]; d = args[i + 2]; if (obj.style) {
                obj = obj.style; v = (v == 'show') ? 'visible' : (v = 'hide') ? 'hidden' : v;
                d = (d == 'show') ? 'block' : (d = 'hide') ? 'none' : d;
            } obj.visibility = v; obj.display = d;
        }
    }
}


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 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;
}

var nPlus = 5   //the % of fading for each step
var speed = 100  //the speed
function FadeLayer(){
	var ie5=(document.getElementById && document.all);
	var ns6=(document.getElementById && !document.all);
    if(document.getElementById){
        var objLayer = document.getElementById('WelcomeDiv');
        if(iOpacity == 0 && isShow == 1){
			MM_showHideLayers('WelcomeDiv','','show');
		}		
        if(isShow == 1){//Add to opacity
			iOpacity+=nPlus;
		}
		else{//Remove from opacity
			iOpacity-=nPlus;
		}
		if(ie5){
			objLayer.style.filter="alpha(iOpacity = 0)";
			objLayer.filters.alpha.opacity = iOpacity;
		}
		if(ns6){
			objLayer.style.MozOpacity = 0 + '%';
			objLayer.style.MozOpacity = iOpacity + '%';
		}
		if(iOpacity < 100 && iOpacity > 0){
			setTimeout('FadeLayer();',speed);
		}
		if(iOpacity == 0 && isShow == 0){
			MM_showHideLayers('WelcomeDiv','','hide');
		}
		if(iOpacity == 100){
			isShow = 0 
		}
	}
}
function validKey(theEle,typeHex){ //1 Nav(Tab, enter, arrows, etc.), 2 Numbers, 4 decimal, 8 hypen, 16 letters, 32 space
	if((typeHex & 1) == 1){ //9-8,13,37-40,45-46,112-123
		if(
			(
				(event.keyCode >= 8 && event.keyCode <= 9) || //  and Tab
				(event.keyCode == 13) || //Return
				(event.keyCode == 16) || //Shift
				(event.keyCode >= 37 && event.keyCode <= 40) || //arrows
				(event.keyCode >= 45 && event.keyCode <= 46) ||
				(event.keyCode >= 112 && event.keyCode <= 123) //Function Keys
			)
		  ) return true
	}
	if((typeHex & 2) == 2){ //Numbers
		if(
			(
				(event.keyCode >= 48 && event.keyCode <= 57) ||
				(event.keyCode >= 96 && event.keyCode <= 105)
			) && !event.shiftKey
		  ) return true
	}
	if((typeHex & 4) == 4){ //Decimal
		if((event.keyCode == 110 || event.keyCode === 190) && theEle.value.search(/\./) < 0) return true 
	}
	if((typeHex & 8) == 8){  //Hypen
		if(event.keyCode == 109 || event.keyCode === 189) return true
	}
	if((typeHex & 16) == 16){  //Letters
		if(event.keyCode >= 65 && event.keyCode <= 90) return true
	}
	if((typeHex & 32) == 32){
		if(event.keyCode >= 32) return true
	}
	return false;
}
function isDate(formEle,page) {
    var pg = page;
    var mf = "";               // Month Formatted
    var df = "";               // Date Formatted
    var ds = formEle.value;    // Date Value
	var nd = new Date(ds);
	var td = 0;
	var i = 0;
	var ID = 0;
	//alert(ds);
  if(formEle.value.length > 0){
	if(pg == 1){NotNewCompany(ds);}		
			
	if (ds == ""){return true;}
	  	
	if(!isNaN(nd.getDate())) {
			
	for(i=0;i<12;i++)
		{
			td = nd.getMonth();
			if (i == td)
			{mf = m[i];} 
		}	
	      
		if (formEle.value.length <= 8){
		var SplitWak = formEle.value.split('/');
		var SplitDash = formEle.value.split('-');
		if ((SplitWak[2] != null && SplitWak[2].length == 2) || (SplitDash[2] != null && SplitDash[2].length == 2)){
			if(SplitWak[2] == null && SplitDash[2] != null){YearVal = SplitDash[2];}
			else if(SplitDash[2] == null && SplitWak[2] != null){YearVal = SplitWak[2];}
			else {YearVal = nd.getFullYear;}
   			if (YearVal <= 50){nd.setFullYear(eval("20" + YearVal));}
   		} 
		}  
			
		if (nd.getDate() < 10){
		df = mf + "  " + nd.getDate() + " " + nd.getFullYear(); formEle.value = df;}
		else{
		df = mf + " " + nd.getDate() + " " + nd.getFullYear(); formEle.value = df;}
		   
		if(pg > 0){
		////////////////////////////
		// Start Date vs. End Date   
		////////////////////////////
		var StartDate = new Array();
		var EndDate = new Array();
		var LHID = new Array();
		var msg = "";
		var err = 0;
		var count = 0;
		var max = 1;
		

	}
		if (err > 0){
		formEle.value = "";
		msg = "The End Date cannot be earlier then the Start Date!";
		alert(msg);
		return false;
		}
		else{      
		formEle.value = df;
		formEle.focus();
		return true; // date is valid
		}
		}else{
			formEle.value = "";
			alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
			return true;
		}	
  }
}
// Format Masked field
function formatValue(formEle, sMask){
	//date(mm/dd/yyyy), Alpha, Numeric, %,$
	var k = event.keyCode;
	switch (sMask){
		case "Alpha":
			break
		case "$":
		    //CHECKING FOR $-SIGN AND ADDING IT IF IT DOESN'T EXIST
		    var re = /\$/g;
		    var dollarKiller = formEle.value.replace(re,'');
		  if(formEle.value.indexOf("$") > 0 || (dollarKiller.length > 0 && formEle.value.indexOf("$") != 0)){
		    if (formEle.value == "$" || formEle.value == "" || dollarKiller == "")
		       {formEle.value = "" ;}
		    else {formEle.value = "$" + dollarKiller ;}
		  }  
		case "%":
		case "Numeric":
			if((k>= 48 && 57 >= k) || (k>= 96 && 105 >= k) || k==8 || k==109 || k==189){
				var sn = new String(formEle.value.replace(/,/ig,""));
				var y = 0;
				var cn = new String("");
				var dec = (sn.indexOf("."));
				var usecomma = true;
					if(dec > -1) usecomma=false ;
				for(x=sn.length-1;x>=0;x--){
					if ( x == dec){
						usecomma=true;
						y = -1;
					}	
					if(y%3 == 0 && y!=0 && usecomma && sn.charAt(x)!="-" && sn.charAt(x)!="$" ) cn = "," + cn;
					if(sn.charAt(x)!="-" || x==0 || sn.charAt(x)!="$"){
						cn = sn.charAt(x) + cn;
						y++;
					}
				}
				formEle.value = (cn);
				y=null;
			}	
			break;
		case "MM/DD/YYYY":
			if(formEle.value.length > 9){
				if(!checkDate(formEle)){
					alert("Invalid Date:\nPlease use (MM/DD/YYYY) ");
				}
			}
			break
		default:
	}		
}
function showWelcome(sMethod){
	var bVisible = 'show';
	var ie5=(document.getElementById && document.all);
	var ns6=(document.getElementById && !document.all);
	
	MM_showHideLayers('WelcomeDiv','',sMethod);
	if (sMethod == 'show'){
		bVisible = 'none';
		var objLayer = document.getElementById('WelcomeDiv');
		if(ie5){
			objLayer.style.filter="alpha(iOpacity = 0)";
			objLayer.filters.alpha.opacity = 100;
		}
		if(ns6){
			objLayer.style.MozOpacity = 100 + '%';
		}
	}
	else
	{
	}
	MM_showHideLayers('theDrops','',bVisible);
}
function popUpWin(url, h, w){
	var scroll = "yes";
	if(popUpWin.arguments[3] != null){
		scroll = popUpWin.arguments[3]
	}
	newWindow = window.open(url,"pop","resizable=yes,toolbar=no,scrollbars=" + scroll + ",width="+w+",height="+h);
	newWindow.focus();
}
function showMenu(DivID){
	hideMenu();
	MM_showHideLayers(DivID,'','show');
}
function hideMenu(){
	MM_showHideLayers('woodblinds_nav','','hide');
	MM_showHideLayers('fauxwoodblinds_nav','','hide');
	MM_showHideLayers('honeycombshades_nav','','hide');
	MM_showHideLayers('miniblinds_nav','','hide');
	MM_showHideLayers('verticalblinds_nav','','hide');
	MM_showHideLayers('bambooshades_nav','','hide');
	MM_showHideLayers('rollershades_nav','','hide');
	MM_showHideLayers('romanshades_nav','','hide');
	MM_showHideLayers('suncontrolshades_nav','','hide');
	MM_showHideLayers('brand_nav','','hide');
}
function submit_helpfullink(obj,selected) {

	if(selected == 1)
	{ var y = parseInt(document.getElementById(obj).helpful.value);
	  document.getElementById(obj).helpful.value = y+1;
	}	
	if(selected == 0)
	{ var y = parseInt(document.getElementById(obj).nothelpful.value);
	  document.getElementById(obj).nothelpful.value =  y+1;
	}
	document.getElementById(obj).submit();
}
function submit_revpaging(selected) {
	var y = parseInt(document.getElementsByName('listpage')[0].value);
	if(selected == 'next')
		{document.getElementsByName('listpage')[0].value = y + 1;}
	if(selected == 'prev')
		{document.getElementsByName('listpage')[0].value = y - 1;}
	document.reviewpaging.submit();
	
}
function change_class(obj,className) {
	//alert(obj + " " + className);
	obj.className = className;
}
function showShippingEstimate(shipFrom, leadTime, nextDayRate, currentShippingCost) {
    
	// Update the fee if there is one.
    if (currentShippingCost > 0) {
        document.getElementById('shippingEstimatorGround').innerHTML = " FedEx / UPS Ground ($" + currentShippingCost + ")";
        document.getElementById('CurrentShippingCharge').value = currentShippingCost;
        // Show all the fees.
        document.getElementById('NextDayDeliveryRate').innerHTML = document.getElementById(nextDayRate).value + " + $" + currentShippingCost;
    }
    // Free shipping.
    else {
        document.getElementById('shippingEstimatorGround').innerHTML = " FedEx / UPS Ground (free)";
        document.getElementById('CurrentShippingCharge').value = 0;
        document.getElementById('NextDayDeliveryRate').innerHTML = document.getElementById(nextDayRate).value;
    }
	document.getElementById('ShipFromZip').value = document.getElementById(shipFrom).value;
	document.getElementById('leadtime').value = document.getElementById(leadTime).value;	
	document.getElementById('ShippingEstimateRate').value = document.getElementById(nextDayRate).value;
	document.getElementById('divEstimates').style.display = 'block';
}
function hideShippingEstimate()
{
	document.getElementById('divEstimates').style.display = 'none';
}
function hideShippingEstimateShown()
{
	document.getElementById('divEstimatsShown').style.display = 'none';
}
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

function showAvailableColors(productColorSwatchId, showingElementId, productId) {
    // Write html for popup.
    if (productId) {
        var showingSpanElement = $('#spanColors_' + productId);
        var hiddenElement = $('#inputColors_' + productId);
        var colorIds = hiddenElement.val().split("|");
        var showingColorsHtml = "";
        var imageCount = 0;
        jQuery.each(colorIds, function () {
            if (this && this != "") {
                showingColorsHtml += "<span><img class='cursor' style='width: 25px; padding: 2px; border: 1px solid #E8E8E8;' src='/images/blinds/thumbnail/blindcolor_" + this + ".jpg' /></span>";
                imageCount++;
            }
        });
        showingSpanElement.html(showingColorsHtml);        
        var loadedImageCnt = 0;
        $('#spanColors_' + productId + " img").hide().each(function () {
            var imgs = $('img');
            var loadingImage = $('#loadingColors_' + productId);
            $(this).bind('load', function () {
                loadedImageCnt++;
                if (loadedImageCnt >= imageCount) {
                    loadingImage.fadeOut("fast");
                    imgs.fadeIn("slow");
                } else {
                    //show images are still downloading
                }
            });
        });                
    }
    document.getElementById(productColorSwatchId).style.display = 'block';
    // Set the color swatch location based on the element if one is passed in.
    if (showingElementId) {
        var showingElement = $('#' + showingElementId);
        var colorHoverElement = $('#' + productColorSwatchId);
        var pos = showingElement.position(); 
        // Position relative to arrow on callout so subtract 22px;
        var top = pos.top-22 + "px";
        colorHoverElement.css( { "top": top } );
    }
}
function hideAvailableColors(productColorSwatchId) {
    document.getElementById(productColorSwatchId).style.display = 'none';
}

function playVid(vidId, noBlackout) {

////////////////////////////////////////////////////////////////////////////////
// Test to see if our video and blackout divisions have been set up.
// If no division was declared in the HTML then we'll go ahead and automatically
// create and style the necessary division.
////////////////////////////////////////////////////////////////////////////////

if (_vidPane==null) {
    ////////////////////////////////////////////////////////////////////////////////
    /// Video Pane wasn't set up so see if it's declared in the HTML
    ////////////////////////////////////////////////////////////////////////////////
    _vidPane=document.getElementById('vidPane');
    if (!_vidPane) {
        // user didn't create the division so create it for him.
        // also asume no styleSheet and set basic styles.
        var tbody = document.getElementsByTagName("body")[0];
        tnode = document.createElement('div');
        tnode.id='vidPane';
        tnode.className='vidFrame';
        tbody.appendChild(tnode);
        _vidPane=document.getElementById('vidPane');
        _vidPane.style.position='absolute';
        _vidPane.style.display='none';
        _vidPane.style.backgroundColor='#ffffff';
        _vidPane.style.border='0px solid #000000';
        _vidPane.style.width='460px';
        _vidPane.style.height='400px';
        _vidPane.style.cursor='move';
        _vidPane.style.fontFamily='verdana';
        _vidPane.style.fontSize='9pt';
        _vidPane.style.zIndex='100';
        _vidPane.style.MozBorderRadius='3';
    }

    // If _vidPane wasn't defined then for sure _blackout wasn't
    // so see if it was defined in the HTML
    _blackout=document.getElementById('blackout');

    if (!_blackout) {
        // user didn't create the division so create it for him.
        // also asume no styleSheet and set basic styles.
        tnode = document.createElement('div');
        tnode.id='blackout';
        tbody.appendChild(tnode);
        _blackout=document.getElementById('blackout');
        _blackout.style.position='absolute';
        _blackout.style.display='none';
        _blackout.style.left='0px';
        _blackout.style.top='0px';
        _blackout.style.backgroundColor='#555555';
        _blackout.style.opacity='.9';
        _blackout.style.filter='alpha(opacity=90)';
        _blackout.style.zIndex='50';
    }
    // Initialize the starting location of the video.
    _vidPane.style.top='240px';    // Starting location horozontal
    _vidPane.style.left='75px';   // Starting location verticle
}

// Shows (or hides) the vidPane layer.   Accepts 2 parameteres.
// vidId is null (close window) or an anchor object (contains HREF value)
// vidId is mandatory example: <a href="someservice.com/somevideo.swf" onClick='return playVid(this);'></a>
// noBlackout is optional. If you pass true, the background will not be "greyed out".

if (vidId==null) { 
    // Null is passed by the "close" link, so we'll hide the layer.
    _vidPane.style.display='none';         // Hide the division.
    _vidPane.innerHTML='';                 // purge it's html (kill video)
    _blackout.style.display='none';        // Hide the blackout layer.
} else {
    // Snag the url from the passed object
    vidId=vidId.href;

    // Next three lines make the blackout layer visible
    // and makes sure it covers the entire page.
    if (!noBlackout) {
        _blackout.style.width='100%';
        _blackout.style.height=(document.body.offsetHeight<screen.height) ? screen.height+'px' : document.body.offsetHeight+20+'px'; 
        _blackout.style.display='block';
    } else {
        _blackout.style.display='none';        // Hide the blackout layer.
    }
    // Break out the URL passed to this function (so vidInfo[0]=http, [1]=domain, etc
    var vidInfo = vidId.split('/');

    // We're building a temporary string called vidstring. 
    // vidstring will hold the HTML as we build it based on the service
    // being used.  The next few lines contains items which are common
    // to all the services, or at least ignored if not directly used.
    
    var vidstring ='&nbsp;<A HREF="'+vidId+'"></A>';
    vidstring+='&nbsp;<A HREF="#" onClick="return(playVid())">close</A><BR>';
    vidstring+='<center><embed style="margin-top: 5px;"';  
    vidstring+=' enableJavascript="false" allowScriptAccess="never"';
    vidstring+=' allownetworking="internal" type="application/x-shockwave-flash"';
    vidstring+=' wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" ';

    if (vidInfo[2].indexOf('youtube.com')>=0) {
        ////////////////////////////////////////////////////////////////////////////////
        // YouTube (Use browser URL, autoplays)
        ////////////////////////////////////////////////////////////////////////////////
        vidInfo=vidId.match(/v=.+$/);
        vidInfo=String(vidInfo).replace(/v=/g,'');
        vidstring+=' src="http://www.youtube.com/v/'+vidInfo+'&autoplay=1" ';
        vidstring+=' height="350" width="425"></embed></center>';
    } else if (vidInfo[2].indexOf('video.google.com')>=0) {
        ////////////////////////////////////////////////////////////////////////////////
        // Google (Use browser URL, autoplays)
        ////////////////////////////////////////////////////////////////////////////////
        vidInfo=vidId.match(/docid=.+$/);
        vidInfo=String(vidInfo).replace(/docid=/g,'');
        vidstring+='  src="http://video.google.com/googleplayer.swf?docId='+vidInfo+'&autoplay=1" ';
        vidstring+=' height="350" width=425"></embed></center>';
    } else if (vidInfo[2].indexOf('metacafe.com')>0) {
        ////////////////////////////////////////////////////////////////////////////////
        // MetaCafe (Use browser URL, autoplays)
        ////////////////////////////////////////////////////////////////////////////////
        vidInfo=vidId.match(/watch.+$/);
        vidInfo=String(vidInfo).replace(/watch./,'');
        vidInfo=String(vidInfo).replace(/.$/,'');
        vidstring+=' flashVars="playerVars=autoPlay=yes" ';
        vidstring+=' src="http://www.metacafe.com/fplayer/'+vidInfo+'.swf" ';
        vidstring+=' width="400" height="345">';  
        vidstring+='</embed></center>';
    } else if (vidInfo[2].indexOf('ifilm.com')>=0) {
        ////////////////////////////////////////////////////////////////////////////////
        // iFilm (Use browser URL, autoplays)
        ////////////////////////////////////////////////////////////////////////////////
        vidInfo=vidId.match(/video.+$/);
        vidInfo=String(vidInfo).replace(/video./,'');
        vidstring+=' flashVars="flvbaseclip='+vidInfo+'&ip=true" ';
        vidstring+=' src="http://ifilm.com/efp" quality="high" name="efp" align="middle" ';
        vidstring+=' width="425" height="350">';  
        vidstring+='</embed></center>';
    } else if (vidInfo[2].indexOf('dailymotion.com')>=0) {
        ////////////////////////////////////////////////////////////////////////////////
        // Daily Motion (Use EMBED URL, autoplays)
        ////////////////////////////////////////////////////////////////////////////////
        vidstring+=' src="'+vidId+'" flashVars="autoStart=1" ';
        vidstring+=' width="425" height="334">';
        vidstring+='</embed></center>';
    } else if (vidInfo[2].indexOf('break.com')>=0) {
        ////////////////////////////////////////////////////////////////////////////////
        // Break (use EMBED URL, autostarts)
        ////////////////////////////////////////////////////////////////////////////////
        vidstring+=' src="'+vidId+'&autoplay=1" ';
        vidstring+=' width="425" height="350">';
        vidstring+='</embed></center>';
    } else if (vidInfo[2].indexOf('shoutfile.com')>=0) {
        ////////////////////////////////////////////////////////////////////////////////
        // Shoutfile (use EMBED URL, does not autostart)
        ////////////////////////////////////////////////////////////////////////////////
        vidstring+=' src="'+vidId+'"';
        vidstring+=' width="400" height="300">';
        vidstring+='</embed></center>';
    } else if (vidInfo[2].indexOf('soapbox.msn.com')>=0) {
        ////////////////////////////////////////////////////////////////////////////////
        // MSN Soapbox (use the LINK, autostarts)
        ////////////////////////////////////////////////////////////////////////////////
        vidInfo=vidId.match(/vid=.+$/);
        vidInfo=String(vidInfo).replace(/vid=/g,'');
        vidstring+=' src="http://images.soapbox.msn.com/flash/soapbox1_1.swf" ';
        vidstring+=' flashvars="c=v&ap=true&v='+vidInfo+'" ';
        vidstring+=' height="360" width="412"></embed></center>';
    } else if (vidInfo[2].indexOf('atomfilms.com')>=0) {
        ////////////////////////////////////////////////////////////////////////////////
        // AtomFilms (use URL, does not autostart), pretty lame embed service IMHO
        ////////////////////////////////////////////////////////////////////////////////
        vidInfo=vidId.match(/film\/.+(\.jsp)/);
        vidInfo=String(vidInfo[0]).replace(/film\//g,'');
        vidInfo=String(vidInfo).replace(/\.jsp/g,'');
        vidstring+=' src="http://www.atomfilms.com:80/a/autoplayer/shareEmbed.swf?keyword='+vidInfo+'" ';
        vidstring+=' height="350" width="425" autostart="true"></embed></center>';
    } else {
        ////////////////////////////////////////////////////////////////////////////////
        // Failed.
        ////////////////////////////////////////////////////////////////////////////////
        vidstring += '></embed><BR><BR><BR>Unknown video service.</center>';
    } 
    // Insert our HTML and display the video window.
    _vidPane.innerHTML=vidstring;
    // Set the Y position of the video window so it's in the visible clip
    var scrollTop = 0;
    if (document.documentElement && document.documentElement.scrollTop)
	    scrollTop = document.documentElement.scrollTop;
    else if (document.body)
	    scrollTop = document.body.scrollTop
    _vidPane.style.top=scrollTop+50+'px';
    // Video window was hidden so we'll make it visible
    _vidPane.style.display='block'; 
}
// return false so the browser won't follow through with A HREF clicks.
return(false);
}

////////////////////////////////////////////////////////////////////////////////
// Drag and Grab handlers
////////////////////////////////////////////////////////////////////////////////

function moveHandler(e){
// Called automatically whenever the mouse is moved after a drag event starts
if (e == null) { e = window.event }  // Get event data, if it wasn't passed, get it IE style.
if ( _dragOK ){                      // is our global var set to true? is it ok to move the object?
    _savedTarget.style.left=e.clientX-_dragXoffset+'px';  //OK to move, calculate the offset and move it
    _savedTarget.style.top=e.clientY-_dragYoffset+'px';   // calculate the y offset and move it.
    return false;                                         // return false so browser doesn't try to do anything else.
}                                   // End _dragOK check
}                                      // End moveHandler

function cleanup(e) {
// Called whenever user lets up off a mouse button after a drag event starts
document.onmousemove=null;                     // Turn off the mousemove event (won't call moveHandler() now).
document.onmouseup=null;                       // Turn off the mouseup event (won't call cleanup() now).                     
_savedTarget.style.cursor=_orgCursor;          // Restore original mouse shape
_dragOK=false;                                 // Turn off the global constant we look for before moving stuff.
}

function dragHandler(e){
// Called automatically when user holds down the mouse button
var cursorType='-moz-grabbing';                               // Set mouse type to grabbing hand
if (e == null) { e = window.event; cursorType='move';}        // This is IE so get event info IE style
var target = e.target != null ? e.target : e.srcElement;      // Save object of the event
if (target.className=="vidFrame") {                           // Did mouse go down over our dragable object?
    _orgCursor=target.style.cursor;                            // Remember the current mouse shape
    _savedTarget=target;                                       // Remember the object we're working with
    target.style.cursor=cursorType;                            // change mouse to "grab" icon                             
    _dragOK=true;                                              // When true, movehandler will move the window
    _dragXoffset=e.clientX-parseInt(_savedTarget.style.left);  // Remember current X offset
    _dragYoffset=e.clientY-parseInt(_savedTarget.style.top);   // Remember current Y offset
    document.onmousemove=moveHandler;                          // Call moveHandler() when mouse moves
    document.onmouseup=cleanup;                                // Call cleanup() when user lets go of mouse btn
    return false;                                              // IMPORTANT return false so browser doesn't do anything else.
}                                                             // End Click on classname = object check
}                                                                // End function dragHandler

// Start the event handler. When mouse is clicked, call dragHandler()	 
document.onmousedown=dragHandler;

// Initialize global variables.
var _savedTarget=null;        // The target layer (effectively vidPane)
var _orgCursor=null;          // The original Cursor (mouse) Style so we can restore it
var _dragOK=false;            // True if we're allowed to move the element under mouse
var _dragXoffset=0;           // How much we've moved the element on the horozontal
var _dragYoffset=0;           // How much we've moved the element on the verticle
var _vidPane = null;          // Video Layer -- won't be defined until a video is called
var _blackout= null;          // blackout Layer. -- won't be defined until a video is called.


//************* start floating image preview ************************//
var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;

var origWidth, origHeight;

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip 
// Do you want tip to move when mouse moves over link?
var tipFollowMouse= true;	
// Be sure to set tipWidth wide enough for widest image
var tipWidth= 200;
var offX= 20;	// how far from mouse to show tip
var offY= 12; 
var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
var tipFontSize= "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tipFontColor= "#000000";
var tipBgColor= "#DDECFF"; 
var tipBorderColor= "#000080";
var tipBorderWidth= 3;
var tipBorderStyle= "ridge";
var tipPadding= 4;

////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// preload images that are to appear in tooltip
// from arrays above
//if (document.images) {
//	var theImgs = new Array();
//	for (var i=0; i<messages.length; i++) {
//  	theImgs[i] = new Image();
//		theImgs[i].src = messages[i][0];
//  }
//}

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
var startStr = '<table width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.width = tipWidth+"px";
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		document.onmousemove = trackMouse;
	}
}

/////////////////////////////////////////////////
//  doTooltip function
//			Assembles content for tooltip and writes 
//			it to tipDiv
/////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function doTooltip(evt,imagePath) {
	if (!tooltip) initTip();
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	//// set colors if included in messages array
	//if (messages[num][2])	var curBgColor = messages[num][2];
	curBgColor = tipBgColor;
	//if (messages[num][3])	var curFontColor = messages[num][3];
	//curFontColor = tipFontColor;
	if (ie4||ie5||ns5) {
		var tip = startStr + imagePath + midStr + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	if (tipOn) positionTip(evt);
}

/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
	if (!tipFollowMouse) {
		standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
		mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	}
	// tooltip width and height
	var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = mouseX-(tpWd+offX)+"px";
	else tipcss.left = mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = winHt-(tpHt+offY)+"px";
	else tipcss.top = mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}

//************* end floating image preview ************************//
function validateRepairKit() 
{
    var firstName = document.getElementById('FirstName');
    if (firstName == null || firstName.value == "")
    {
      alert('Please enter first name.');
      firstName.focus();
      return false;
    }

    var lastName = document.getElementById('LastName');
    if (lastName == null || lastName.value == "")
    {
      alert('Please enter last name.');
      lastName.focus();
      return false;
    }

    var address = document.getElementById('Address');
    if (address == null || address.value == "")
    {
      alert('Please enter an address.');
      address.focus();
      return false;
    } 

    var city = document.getElementById('City');
    if (city == null || city.value == "")
    {
      alert('Please enter a city.');
      city.focus();
      return false;
    }    

    var state = document.getElementById('State');
    if (state == null || state.value == "")
    {
      alert('Please enter a state.');
      state.focus();
      return false;
    } 

    var zip = document.getElementById('Zip');
    if (zip == null || zip.value == "")
    {
      alert('Please enter a zip code.');
      zip.focus();
      return false;
    }  

    var email = document.getElementById('Email');    
    if (email != null || email.value != "")
    {
        var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
        var check=/@[\w\-]+\./;
        var checkend=/\.[a-zA-Z]{2,4}$/;

        var emailVal = email.value;
        if ((emailVal.search(exclude) != -1) || 
              (emailVal.search(check) == -1) ||
              (emailVal.search(checkend) == -1)) {
              alert("Incorrect email address! Please amend.");
              email.focus();
              return false;
        }
    }
    
    var quantity = document.getElementById('Quantity');
    if (quantity == null || quantity.value == "")
    {
      alert('Please enter a quantity.');
      quantity.focus();
      return false;
    } 
    
}

function showHideDiv(id){
    if (document.getElementById){
        obj = document.getElementById(id);
        if (obj.style.display == "none"){
            obj.style.display = "block";
        } 
        else 
        {
            obj.style.display = "none";
        }
    }
} 

function showHideMovieDiv(show,hide1,hide2,hide3){
    if (document.getElementById){
        objshow = document.getElementById(show);
        objhide1 = document.getElementById(hide1);
        objhide2 = document.getElementById(hide2);
        objhide3 = document.getElementById(hide3);
        
        objshow.style.display = "block";
        objhide1.style.display = "none";
        objhide2.style.display = "none";
        objhide3.style.display = "none";

    }
} 
