function linkURL(url)
{
   location.href=url;
}



function open_new_window_full(url)
{
 new_window = window.open(url,'window_name','toolbar=1,menubar=1,resizable=1,scrollbars=1,dependent=1,status=1')
 //new_window = window.open(url,'window_name','toolbar=0,menubar=0,resizable=1,scrollbars=1,dependent=0,status=0,width=450,height=300,left=10,top=10');
}


//this used for layers
 function show(idName)
 {
     //fix.style.display='none';    
     //float.style.display='none';    

     identity = document.getElementById(idName);
     identity.style.display='inline';
 }
 
 function hide(idName)
 {
     //fix.style.display='none';    
     //float.style.display='none';    

     identity = document.getElementById(idName);
     identity.style.display='none';
 }
 
 
 /////////////////// AJAX /////////////////
// var xmlhttp
// function showHint(str)
// {
// if (str.length==0)
//   {
//   document.getElementById("txtHint").innerHTML="";
//   return;
//   }
// xmlhttp=GetXmlHttpObject();
// if (xmlhttp==null)
//   {
//   alert ("Your browser does not support XMLHTTP!");
//   return;
//   }
// var url="gethint.asp";
// url=url+"?q="+str;
// url=url+"&sid="+Math.random();
// xmlhttp.onreadystatechange=stateChanged;
// xmlhttp.open("GET",url,true);
// xmlhttp.send(null);
// }

// function stateChanged()
// {
// if (xmlhttp.readyState==4)
//   {
//   document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
//   }
// }
 
 //used on shoppingCart.do page
 function aNoMagPromoCall(obj,path)
 {
   // document.forms.cart.nomagpromo.value = "F";
   //obj.form.submit()
   //alert(obj.checked);         

  URL = path + "/jsp/noMagPromo.jsp?nomagpromo=false";//this will set the slsHdrBo.nomagpromoto false 
  if(obj.checked == true)
  {
     URL = path + "/jsp/noMagPromo.jsp?nomagpromo=true"; 
  }

  //alert("3");
  var xhReq = GetXmlHttpObject(); //new XMLHttpRequest();
  xhReq.open("GET", URL, true);
  xhReq.send(null);
  
   //alert("4");  
  //var serverResponse = xhReq.responseText;
  //alert(serverResponse); // Shows "15"
 }
 
 function GetXmlHttpObject()
 {
   if (window.XMLHttpRequest)
   {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    return new XMLHttpRequest();
   }
  
   if (window.ActiveXObject)
   {
    // code for IE6, IE5
    return new ActiveXObject("Microsoft.XMLHTTP");
   }

   return null;
 } 

 // The following is used with IFrames which can be used instead of AJAX
 // <span id="txtHint"></span></p>
 // <iframe id='iFrame' onload='onIFrameLoad();'></iframe> 

  //var iFrameBody = document.getElementById("iFrame").contentWindow.document.body;
 // iFrameBody.innerHTML = "whatever html code you want";

 
 ///////////////////////////////    This is used for SLI   /////////////////////////////////////////////
 function getFocus() 
 {
     // place the id below of the field you want to have focus upon page load
    //var focusHere = document.getElementById("sli_search_1")
   //this is need to support an element in a Div
   var focusHere = document.getElementById("sli_search_div").getElementsByTagName('input')[0]; 
   if(focusHere != null)
   {
	   focusHere.focus();
   }  
}//end function getFocus()
///////////////////////////////    Body Onload  /////////////////////////////////////////////
//called on the body of every page 
 function abeOnload() 
 {
	 //only set focus if there is no anchor on this URL
	 if(document.location.href.toString().indexOf("#") == -1 && document.location.href.toString().indexOf("https:") == -1)
	 {
		 getFocus();//used for search sli
	 }
 
 } 

 function ajaxsearchsubmit(form){
 	 var search = escape(form.w.value);
	 var asug = escape(form.asug.value);
	 window.location="http://cameras.abesofmaine.com/search#w="+search+"&asug="+asug;
	 return false;
	 }//this is used for SLI search

 
    //this is used to clear the search form instructional text when a user submits without typing anyting
    function searchTextToClear(textToClear)
	{
		//alert("document.forms.searchform.w.value 1= " + document.forms.searchform.w.value);
		 if(document.forms.searchform.w.value==textToClear)
		 {
			 document.forms.searchform.w.value="";
		 }
	}//end funtion
 
 
///////////////////////////////   Used for SLI Search and other fields  /////////////////////////////////////////////
 
	function clickclear(thisfield, defaulttext) 
	{
		if (thisfield.value == defaulttext) 
		{
			thisfield.value = "";
		}
	}
	
	function clickrecall(thisfield, defaulttext) 
	{
		if (thisfield.value == "") 
		{
			thisfield.value = defaulttext;
		}
	}
	
	

//END R JavaScript --------------------------------





//BEGIN J JavaScript --------------------------------


//BEGIN MASTER ON DOCUMENT.READY!
$(document).ready(function() {

//Homepage Daily Specials Initializer by first image load.
	var mainIMGLoaded = function() {
		$('#slider').nivoSlider();
	}
	$('#mainIMG').each(function() {
		var tmpImg = new Image() ;
		tmpImg.onload = mainIMGLoaded ;
		tmpImg.src = $(this).attr('src') ;
   	});
   	
//Homepage Featured Categories slide
	$("#hp_cats_next").click(function () {
		$("#hp_cats_left").hide("slide", { direction: "left" }, 750);
		$("#hp_cats_right").show("slide", { direction: "right" }, 750);
	});

	$("#hp_cats_prev").click(function () {
		$("#hp_cats_right").hide("slide", { direction: "right" }, 750);
		$("#hp_cats_left").show("slide", { direction: "left" }, 750);
	});

//CHANGE IMAGES ON CLICK
	$(".changeIMG").click(function() {
	var changeSrc = $(this).attr("href");
		$("#mainIMG").attr("src",changeSrc);
		return false;
	});
	
//END CHANGE IMAGES ON CLICK


//LOGINPAGE CREATE/ACCOUNT HIDE/SHOW SLIDE
	$(".showCAext").click(function() {
		$('#CAinit').hide();
		$('#CAform').show();
	});
//END LOGINPAGE CREATE/ACCOUNT HIDE/SHOW SLIDE


//FORGOT PASSWORD LOGIN FORM SWITCH
	$(".forgotpassSW").click(function() {
		$('#logininit').hide();
		$('#CAwrap').hide();
		$('#forgotpass').show(); //removed '600' to make it work
	});
//END FORGOT PASSWORD LOGIN FORM SWITCH


//LOGINMESSAGE TOGGLE
	$('#loginMsgDisp1').hide(); //HIDE INITIAL
	$('.slidenotif1').click(function() {
		$('#loginMsgDisp2').slideUp();
		$('#loginMsgDisp3').slideUp();
		$('#loginMsgDisp1').slideToggle('600', function() {
		});
	});
	$('#loginMsgDisp2').hide(); //HIDE INITIAL
	$('.slidenotif2').click(function() {
		$('#loginMsgDisp1').slideUp();
		$('#loginMsgDisp3').slideUp();
		$('#loginMsgDisp2').slideToggle('600', function() {
		});
	});
	$('#loginMsgDisp3').hide(); //HIDE INITIAL
	$('.slidenotif3').click(function() {
		$('#loginMsgDisp1').slideUp();
		$('#loginMsgDisp2').slideUp();
		$('#loginMsgDisp3').slideToggle('600', function() {
		});
	});
//END LOGINMESSAGE TOGGLE


//HIDE THE FAQS DIVS ON PAGE LOAD
	$("div.faq_a").hide();
//FAQ ACCORDION BUTTON ACTION
	$('div.faq_q').click(function() {
		$('div.faq_a').slideUp('fast');	
		$(this).next().slideDown('fast');
	});
//END FAQ ACCORDION BUTTON ACTION
 

//SHIPPING SAME AS BILLING CHECKBOX FUNCTION
	$(".shipsame").click(function(){
		if ($(".shipsame").is(':checked'))
		{
		// Checked, copy values
		$("input#shipfname").val($("input#billfname").val());
		$("input#shiplname").val($("input#billlname").val());
		$("input#shipadd1").val($("input#billadd1").val());
		$("input#shipadd2").val($("input#billadd2").val());
		$("input#shipadd3").val($("input#billadd3").val());
		$("input#shipcity").val($("input#billcity").val());
		$("select#shipst").val($("select#billst").val());
		$("input#shipzip").val($("input#billzip").val());
		$("select#shipcountry").val($("select#billcountry").val());
		$("input#shiphtel").val($("input#billhtel").val());
		$("input#shipbtel").val($("input#billbtel").val());
		}
			else
		{
			// Clear on uncheck
			$("input#shipfname").val("");
			$("input#shiplname").val("");
			$("input#shipadd1").val("");
			$("input#shipadd2").val("");
			$("input#shipadd3").val("");
			$("input#shipcity").val("");
			$("select#shipst").val("");
			$("input#shipzip").val("");
			$("select#shipcountry").val("US");
			$("input#shiphtel").val("");
			$("input#shipbtel").val("");
		}
	});
//END SHIPPING SAME CHECKBOX FUNCTION	


//UPDATE (REVIEW) CART BUTTON ACTION
	$('.updatehide').hide(); //HIDE INITIAL
	$('.updatecart').click(function() {
		$('.updatehide').show(); 
		$('.updateshow').hide();

	});
//END UPDATE (REVIEW) CART BUTTON ACTION


//PAYMENT OPTIONS HIDE/SHOW SLIDE
	$(".showcc").click(function() {
		$('#creditCardFields').slideDown('600');
		$("#paymentsubmitimg").attr("src","imgWeb/images/buttons/revieworder.png");
		$('#popts1').show();
		$('#popts2').hide();
	});
	
	$(".hidecc").click(function() {
		$('#creditCardFields').slideUp('300');
		$("#paymentsubmitimg").attr("src","imgWeb/images/buttons/paymentcont.png");
		$('#popts1').hide();
		$('#popts2').show();
	});
//END PAYMENT OPTIONS HIDE/SHOW SLIDE




});
//END MASTER ON DOCUMENT.READY!

//MASTER WINDOW LOAD FUNCTIONS
$(window).load(function() {

	//Load effect for Featured Categories
	$("#hp_cats_right").hide("slide", { direction: "right" }, 750);
	$("#hp_cats_left").show("slide", { direction: "left" }, 750);

	//Fade out the load bkrnd
	$(".loadinginbkrnd").fadeOut('fast');

});
//END MASTER WINDOW LOAD FUNCTIONS

//LOGINPAGE CREATE/ACCOUNT HIDE/SHOW SLIDE
	$(".showCAext").live('click', function() {
		$('#CAinit').hide();
		$('#CAform').show();
	});
//END LOGINPAGE CREATE/ACCOUNT HIDE/SHOW SLIDE

//CART SMOOTH SCROLL
$(function () {$('#scrltocheckoutopts').click(function () {$('html, body').animate({scrollTop: (450)},1000);return false;});});

//Live Chat
var lpMTagConfig = {'lpServer' : "server.iad.liveperson.net",'lpNumber' : "70582249",'lpProtocol' : (document.location.toString().indexOf('https:')==0) ? 'https' : 'http'}; function lpAddMonitorTag(src){if(typeof(src)=='undefined'||typeof(src)=='object'){src=lpMTagConfig.lpMTagSrc?lpMTagConfig.lpMTagSrc:'/hcp/html/mTag.js';}if(src.indexOf('http')!=0){src=lpMTagConfig.lpProtocol+"://"+lpMTagConfig.lpServer+src+'?site='+lpMTagConfig.lpNumber;}else{if(src.indexOf('site=')<0){if(src.indexOf('?')<0)src=src+'?';else src=src+'&';src=src+'site='+lpMTagConfig.lpNumber;}};var s=document.createElement('script');s.setAttribute('type','text/javascript');s.setAttribute('charset','iso-8859-1');s.setAttribute('src',src);document.getElementsByTagName('head').item(0).appendChild(s);} if (window.attachEvent) window.attachEvent('onload',lpAddMonitorTag); else window.addEventListener("load",lpAddMonitorTag,false);


//FOOTER EMAIL SUBMISSION
		function submitFooterEmail(type)
		{
			
			var inputvalue = document.getElementById('footerEmailAddress').value;
			var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    		if(pattern.test(inputvalue)){         
				if(type == 'remove')
				{
					document.getElementById('footerFORM_ACTION').value = 'remove';
				}
    			document.forms.FooterSignupForm.submit();   
    		}else{   
				alert("Please enter a valid email address.");
				document.getElementById('footerEmailAddress').focus();
				return;
    		}
		}

//END FOOTER EMAIL SUBMISSION


//PRELOADING OF IMAGES
if (document.images)
{
  pic1= new Image(990,90); 
  pic1.src="imgWeb/images/global/topbkrnd.png";
  pic2= new Image(994,38); 
  pic2.src="imgWeb/images/global/topcatnavbkrnd.png";
 // pic3= new Image(1,35); 
 // pic3.src="imgWeb/images/global/topnavbkrndhover.png"; 
}
//END PRELOADING OF IMAGES











//This will toggle the layer or do the opposite
function toggleLayer(whichLayer)
{

       //alert(whichLayer);
	if (document.getElementById)
	{
	   //alert("1");
	
	    // this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"inline";
//                style2.display = "inline";

	}
	else if (document.all)
		{
	//alert("2");

		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
                //style2.display = "inline";

	}
	else if (document.layers)
	{
//alert("3");

		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
                //style2.display = "inline";
	}
}//end toggleLayer(whichLayer)

//////////////////////////////////////////////////////
//this will show and individual layer
function showLayer(whichLayer)
{
	if (document.getElementById)
	{
	    // this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		//style2.display = style2.display? "":"inline";
        style2.display = "inline";
	}
	else if (document.all)
		{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "block";
	}
}//end showLayer(whichLayer)
/////////////////////////////////////////////
//this will hide an individual layer
function hideLayer(whichLayer)
{
	if (document.getElementById)
	{
	    // this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		//style2.display = style2.display? "":"inline";
		style2.display = "";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "";
	}
}//end hideLayer(whichLayer)
/////////////////////////////////////////////
//this will hide all layers
function hideAllLayers()
{
	//hideLayer('otherPricesId');
	hideLayer('accessoriesId');
	hideLayer('kitsPackagesId');
	hideLayer('descriptionId');
	hideLayer('rebatesId');
	hideLayer('kitDetailsId');
	hideLayer('wibId');
	hideLayer('productReviewsId');
	hideLayer('answersId');
	
}//end hideAllLayers()
/////////////////////////////////////////////
//show one layer and hide the rest of them
function showOneLayerOnly(whichLayer)
{
	hideAllLayers();
	showLayer(whichLayer);
}//end hideAllLayers()
/////////////////////////////////////////////

function moveLayer(whichLayer,top,left)
{
	if (document.getElementById)
	{
	   	//alert("1");
	    // this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		//style2.display = style2.display? "":"inline";
        //style2.display = "inline";
		style2.top = top;
		style2.left = left;
	}
	else if (document.all)
		{
	   	//alert("2");
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "block";
		style2.top = top;
		style2.left = left;

	}
	else if (document.layers)
	{
		//alert("3");
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		//style2.display = style2.display? "":"block";
        style2.display = "block";
		style2.top = top;
		style2.left = left;

	}
}//end showLayer(whichLayer)



///////////////////////////////////////////////////
////This is used for Verify By Visa layers   //////
///////////////////////////////////////////////////
/////////////////////////////////////////////
//this will hide all layers
function hideAllVbvLayers()
{
	//hideLayer('otherPricesId');
	hideLayer('masterCardId');
	hideLayer('visaId');
//	hideLayer('vbvTextId');
}//end hideAllLayers()
/////////////////////////////////////////////
//show one layer and hide the rest of them
function showOneVbvLayerOnly(whichLayer)
{
    
	hideAllVbvLayers();
	showLayer(whichLayer);
//	showLayer("vbvTextId");//always show the verify by Visa text
}//end hideAllLayers()
/////////////////////////////////////////////
function getCeditCardType(pan)
{
        var cardType="";
        //4000000000000002
        //alert("pan = " + pan.length);
        //alert("start  = " + pan.substr(0,1));
        
		if (pan.length == 16 && pan.substr(0,1)=="4") 
		{
			cardType = "CARD_TYPE_VISA";
		} 
		else if (pan.length == 13 && pan.substr(0,1)=="5") 
		{
			cardType = "CARD_TYPE_MC";
		} 
		else if (pan.length == 16 && pan.substr(0,1)=="5") 
		{
			cardType = "CARD_TYPE_MC";
		} 
		else if (pan.length == 15 && pan.substr(0,4)=="2131") {
			cardType = "CARD_TYPE_JCB";
		} else if (pan.length == 15 && pan.substr(0,4)=="1800") {
			cardType = "CARD_TYPE_JCB";
		} else if (pan.length == 16 && pan.substr(0,1)=="3") {
			cardType = "CARD_TYPE_JCB";
		} else if (pan.length == 15 && pan.substr(0,2)=="34") {
			cardType = "CARD_TYPE_AMEX";
		} else if (pan.length == 15 && pan.substr(0,2)=="37") {
			cardType = "CARD_TYPE_AMEX";
		}

		return cardType;
}
/////////////////////////////////////////////////
function displayVbvInfo(cardObj)
{
  hideAllVbvLayers();
  //alert(cardObj.value);
  
  type =  getCeditCardType(cardObj.value)
  //alert("type = " + type);

  if(type == "CARD_TYPE_VISA" )
  {
	 showOneVbvLayerOnly("visaId")
  }
  else if(type == "CARD_TYPE_MC")
  {
	  showOneVbvLayerOnly("masterCardId")
  }
}

///////////////////////
function handleMissingImages()
{
	$(window).bind('load', function() {
$('img').each(function() {
    if((typeof this.naturalWidth != "undefined" &&
        this.naturalWidth == 0 ) 
        || this.readyState == 'uninitialized' ) {
    	if(this.src.indexOf('.gif') >= 0 || this.src.indexOf('.jpg') >= 0 || this.src.indexOf('.png') >= 0)
    	{
    	//alert(this.src);
        $(this).attr('src', 'imgWeb/images/global/catnoimg.gif');
        //alert(this.src);
        }
    }
}); })
}

/////////////////////////////////
function itemJumpToRebate()
{
	$('#rebateTab').click();
	
	$('html, body').animate({scrollTop: $("#rebateTab").offset().top }, 1000); 
}
function renderPlusone(theHREF){
	if(!theHREF)
	{
	theHREF = window.location.href;
	}
	gapi.plusone.render("g-plusone", {"size": "medium", "count": "true","href":theHREF});
}

