function include_dom(script_filename){document.write('<'+'script');document.write(' language="javascript"');document.write(' type="text/javascript"');document.write(' src="'+script_filename+'">');document.write('</'+'script'+'>');}
$(document).ready(function(){$('#siteSearchForm').submit(function(){var url=$(this).attr('action');keyword=$('#siteSearchForm input[type=text]').val();url+='keyword/'+keyword;document.location.href=url;return false;});switch(page)
{case"contact_us":case"return_policy":case"link_us":$.meta.setType("attr","validate");$("#custInfo").validate();$.get(this_www_root+'ajax.php?cmd=set_form_token',function(data){var hdn='<input type="hidden" name="ts" value="'+data+'">'
$('#custInfo').append(hdn);});break;case"related_products":jQuery('#related-products').jcarousel({scroll:4,visible:3,initCallback:function(){jQuery('#loading-div').hide();jQuery('.jcarousel-skin-tango').css('visibility','visible');}});break;}});function append_script_to_header(script_path)
{var script=$('script').filter('[src="'+script_path+'"]');if(script.length==0)
{var str_include='<'+'script';str_include+=' language="javascript"';str_include+=' type="text/javascript"';str_include+=' src="'+script_path+'">';str_include+='</'+'script'+'>';$('head').append(str_include);}}
function append_script_to_footer(script_path)
{var script=$('script').filter('[src="'+script_path+'"]');if(script.length==0)
{var str_include='<'+'script';str_include+=' language="javascript"';str_include+=' type="text/javascript"';str_include+=' src="'+script_path+'">';str_include+='</'+'script'+'>';$('body').append(str_include);}}
function append_style_to_footer(style_path)
{var style=$('style').filter('[href="'+style_path+'"]');if(style.length==0)
{var str_include='<'+'link';str_include+=' rel="stylesheet"';str_include+=' type="text/css"';str_include+=' href="'+style_path+'"';str_include+=' />';$('body').append(str_include);}}
var popUpWin=0;function popUpWindow(URLStr,width,height)
{var left=50;var top=50;if(width<1)
width=420;if(height<1)
height=495;if(popUpWin)
{if(!popUpWin.closed)popUpWin.close();}
popUpWin=open(URLStr,'popUpWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');}
function roundoff(number,decimal_places)
{number=""+number;dot_pos=number.indexOf(".");if(dot_pos==-1){number+=".";for(i=0;i<decimal_places;i++){number+="0";}
new_number=number;}else{num_part=dot_pos+decimal_places+1;new_number=number.substr(0,num_part);}
return new_number;}
function addCommasToNumbers(nStr)
{nStr+='';x=nStr.split('.');x1=x[0];x2=x.length>1?'.'+x[1]:'';var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2');}
return x1+x2;}
function is_valid_email(email){return email.match(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i);}
function is_empty_string(str){if(str==''){return true;}else if(typeof str=="string"&&str.match(/^\s$/i)){return true;}else{return false;}}
function getMousePosX(e)
{var posx=0;if(!e)var e=window.event;if(e.pageX){posx=e.pageX;}
else if(e.clientX){posx=e.clientX+document.body.scrollLeft
+document.documentElement.scrollLeft;}
return posx;}
function getMousePosY(e)
{var posy=0;if(!e)var e=window.event;if(e.pageY){posy=e.pageY;}
else if(e.clientY){posy=e.clientY+document.body.scrollTop
+document.documentElement.scrollTop;}
return posy;}
function str_replace(search,replace,str)
{while(str.indexOf(search)!=-1){str=str.replace(search,replace);}
return str;}
var ajaxCartCounterInterval;function addToCart(formId){var options={beforeSubmit:showAddToCartLoader,success:callBackAddToCart,dataType:'json',failure:callBackFailedAddToCart,data:{is_ajax_cart:'1'},timeout:5000};$('#'+formId).ajaxSubmit(options);return false;}
function addToCartAjax(formId){showAddToCartLoader();var buyFormCommand=$('#'+formId+' input[name=ajax_cart_command]').val();var formAction=www_root+'cart.php?cmd='+buyFormCommand+'&';var formData=$('#'+formId).serialize()+"&is_ajax_cart=1";var cartUrl=formAction+formData;$.ajax({url:cartUrl,type:"GET",error:function(jqXHR,textStatus,errorThrown){callBackFailedAddToCart(jqXHR,textStatus,errorThrown)},dataType:'jsonp'});return false;}
function showAddToCartLoader(formData,jqForm,options){clearInterval(ajaxCartCounterInterval);$('#ajaxcart_dialog_progress_container').show();return true;}
function callBackAddToCart(responseText,error){$('#ajaxcart_dialog_progress_container').hide();$('#ajaxcart_dialog_detail_container').show();if(error==true){$('#ajaxcart_dialog_product_name_contaner').html(responseText);}else{$('#ajaxcart_dialog_detail_product_name').html(decodeURIComponent(responseText.Product_Name));}
var ajaxCartCountdownNumber=6;if(typeof ajaxCartCounterInterval!='undefined')clearInterval(ajaxCartCounterInterval);ajaxCartCounterInterval=setInterval(function(){ajaxCartCountdownNumber--;if(ajaxCartCountdownNumber<1){clearInterval(ajaxCartCounterInterval);closeAjaxCartDialog();window.location=www_root+'cart/view_cart/';}else{$('#ajaxcart_dialog_detail_countdown').html(ajaxCartCountdownNumber);}},1000);if(error==false){updateHeaderCartDetails(responseText.Cart_Price_Total,responseText.Cart_Total_Items_Count);}}
function callBackFailedAddToCart(){callBackAddToCart('<b><font color="red">Failed Adding To Cart, Please Try Again!</font></b>',true);}
function closeAjaxCartDialog(){$('#ajaxcart_dialog_progress_container').hide();$('#ajaxcart_dialog_detail_container').hide();$('#ajaxcart_dialog_detail_countdown').html('5');}
function continueShoppingAjaxCart(){clearInterval(ajaxCartCounterInterval);closeAjaxCartDialog();}
function updateHeaderCartDetails(cartTotalPrice,cartTotalItems){var cartTotalPrice=addCommasToNumbers(roundoff(cartTotalPrice,1));$('#header_cart_items_count_container').html(cartTotalItems);$('#header_cart_items_total_container').html(cartTotalPrice);var loadUrl=this_www_root+'ajax.php';$.get(loadUrl,{Cart_Total_Price:cartTotalPrice,Total_Items:cartTotalItems,cmd:'update_cart_session'},function(responseText){$("#result").html(responseText);},"html");}
function openPopupChatWindow(){var livePersonChatUrl='https://server.iad.liveperson.net/hc/51262989/?cmd=file&file=visitorWantsToChat&site=51262989';window.open(livePersonChatUrl+"&referrer="+escape(document.location),"Window1","menubar=no,width=430,height=360,toolbar=no");}
(function($){$.facebox=function(data,settings,klass){$.facebox.loading()
if(data.ajax)fillFaceboxFromAjax(data.ajax)
else if(data.image)fillFaceboxFromImage(data.image)
else if(data.div)fillFaceboxFromHref(data.div)
else if($.isFunction(data))data.call($)
else $.facebox.reveal(data,settings,klass)}
$.extend($.facebox,{settings:{opacity:0.5,overlay:true,modal:true,showFooter:true,loadingImage:images_web+'facebox/loading.gif',closeImage:images_web+'facebox/closelabel.gif',imageTypes:['png','jpg','jpeg','gif'],faceboxHtml:'\
    <div id="facebox" style="display:none;"> \
      <div class="popup"> \
        <table> \
          <tbody> \
            <tr> \
              <td class="tl"/><td class="b"/><td class="tr"/> \
            </tr> \
            <tr> \
              <td class="b"/> \
              <td class="body"> \
                <div class="content"> \
                </div> \
                <div class="footer"> \
                  <a href="#" class="close"> \
                    <img src="'+images_web+'facebox/closelabel.gif" title="close" class="close_image" width="66px" height="22px" /> \
                  </a> \
                </div> \
              </td> \
              <td class="b"/> \
            </tr> \
            <tr> \
              <td class="bl"/><td class="b"/><td class="br"/> \
            </tr> \
          </tbody> \
        </table> \
      </div> \
    </div>'},loading:function(){init()
if($('#facebox .loading').length==1)return true
showOverlay()
$('#facebox .content').empty()
$('#facebox .body').children().hide().end().append('<div class="loading"><img src="'+$.facebox.settings.loadingImage+'"/></div>')
$('#facebox').css({top:getPageScroll()[1]+(getPageHeight()/10),left:385.5}).show()
if($.facebox.settings.modal!=true){$(document).bind('keydown.facebox',function(e){if(e.keyCode==27)$.facebox.close()
return true})}
$(document).trigger('loading.facebox')},reveal:function(data,settings,klass){$(document).trigger('beforeReveal.facebox')
if(klass)$('#facebox .content').addClass(klass)
$('#facebox .content').append(data)
$('#facebox .loading').remove()
$('#facebox .body').children().fadeIn('normal')
if(settings!=null){if(!settings.showFooter)$('#facebox .footer').hide();}
$('#facebox').css('left',$(window).width()/2-($('#facebox table').width()/2))
$(document).trigger('reveal.facebox').trigger('afterReveal.facebox')},close:function(){$(document).trigger('close.facebox')
return false}})
$.fn.facebox=function(settings){init(settings)
function clickHandler(){$.facebox.loading(true)
var klass=this.rel.match(/facebox\[?\.(\w+)\]?/)
if(klass)klass=klass[1]
fillFaceboxFromHref(this.href,klass)
return false}
return this.click(clickHandler)}
function init(settings){if($.facebox.settings.inited)return true
else $.facebox.settings.inited=true
$(document).trigger('init.facebox')
makeCompatible()
var imageTypes=$.facebox.settings.imageTypes.join('|')
$.facebox.settings.imageTypesRegexp=new RegExp('\.'+imageTypes+'$','i')
if(settings)$.extend($.facebox.settings,settings)
$('body').append($.facebox.settings.faceboxHtml)
var preload=[new Image(),new Image()]
preload[0].src=$.facebox.settings.closeImage
preload[1].src=$.facebox.settings.loadingImage
$('#facebox .close').click($.facebox.close)
$('#facebox .close_image').attr('src',$.facebox.settings.closeImage)}
function getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
return new Array(xScroll,yScroll)}
function getPageHeight(){var windowHeight
if(self.innerHeight){windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowHeight=document.documentElement.clientHeight;}else if(document.body){windowHeight=document.body.clientHeight;}
return windowHeight}
function makeCompatible(){var $s=$.facebox.settings
$s.loadingImage=$s.loading_image||$s.loadingImage
$s.closeImage=$s.close_image||$s.closeImage
$s.imageTypes=$s.image_types||$s.imageTypes
$s.faceboxHtml=$s.facebox_html||$s.faceboxHtml}
function fillFaceboxFromHref(href,klass){if(href.match(/#/)){var url=window.location.href.split('#')[0]
var target=href.replace(url,'')
$.facebox.reveal($(target).clone().show(),klass)}else if(href.match($.facebox.settings.imageTypesRegexp)){fillFaceboxFromImage(href,klass)}else{fillFaceboxFromAjax(href,klass)}}
function fillFaceboxFromImage(href,klass){var image=new Image()
image.onload=function(){$.facebox.reveal('<div class="image"><img src="'+image.src+'" /></div>',klass)}
image.src=href}
function fillFaceboxFromAjax(href,klass){$.get(href,function(data){$.facebox.reveal(data,klass)})}
function skipOverlay(){return $.facebox.settings.overlay==false||$.facebox.settings.opacity===null}
function showOverlay(){if(skipOverlay())return
if($('facebox_overlay').length==0)
$("body").append('<div id="facebox_overlay" class="facebox_hide"></div>')
$('#facebox_overlay').hide().addClass("facebox_overlayBG").css('opacity',$.facebox.settings.opacity).click(function(){if($.facebox.settings.modal!=true)$(document).trigger('close.facebox')}).fadeIn(200)
return false}
function hideOverlay(){if(skipOverlay())return
$('#facebox_overlay').fadeOut(200,function(){$("#facebox_overlay").removeClass("facebox_overlayBG")
$("#facebox_overlay").addClass("facebox_hide")
$("#facebox_overlay").remove()})
return false}
$(document).bind('close.facebox',function(){$(document).unbind('keydown.facebox')
$('#facebox').fadeOut(function(){$('#facebox .content').removeClass().addClass('content')
hideOverlay()
$('#facebox .loading').remove()})})})(jQuery);function initialize_addons()
{this.timmer=null;this.initialize_request_a_quote=function(){if(typeof(request_a_quote)!="undefined"){request_a_quote();var str_code="clearTimeout("+this.timmer+");";eval(str_code);}};this.initialize_discounted_price=function(){if(typeof(discountedPrice)!="undefined"){discountedPrice();var str_code="clearTimeout("+this.timmer+");";eval(str_code);}};this.initialize_product_attributes=function(){if(typeof(product_attributes)!="undefined"){product_attributes();var str_code="clearTimeout("+this.timmer+");";eval(str_code);}};}
function request_a_quote()
{$(".quote").click(function(e)
{var quote_type=$(this).attr('type');switch(quote_type)
{case"custom":id=request_a_quote.custom_product_quote(this,e);break;case"product":id=request_a_quote.main_product_quote(this,e);break;case"component":id=request_a_quote.multiple_products_quote(this,e);break;}
document.frmQuote.id.value=id;$('<input type="hidden" name="type" value="'+quote_type+'">').prependTo(document.frmQuote);$.getJSON(this_www_root+"ajax.php",{cmd:"get_field",table:'products',return_field:'Category',field1:'Product_ID',value1:id},function(json){data=json.data;if(typeof(document.frmQuote.category)=='undefined'){$('<input type="hidden" name="category" value="'+data+'">').prependTo(document.frmQuote);}else{document.frmQuote.category.value=data;}});$('#btnRequest').bind("click",request_a_quote.btnRequest_handler);return false;});$(".close_quote").click(function(e){$("#request_quote").slideUp("slow");return false;});$(".close_message").click(function(e){$("#quote_message").slideUp("slow");return false;});request_a_quote.btnRequest_handler=function(e)
{var id=document.frmQuote.id.value;var name=document.frmQuote.name.value;var email=document.frmQuote.email.value;var phone=document.frmQuote.phone.value;var category="";if(typeof(document.frmQuote.category)!="undefined")
category=document.frmQuote.category.value;var custom_products="";if(document.frmQuote.custom_products.value!=""){custom_products=document.frmQuote.custom_products.value;}
if($.trim(name)==""||$.trim(email)==""||$.trim(phone)=="")
{alert("Please fill in all fields");return;}
var desc="";if(custom_products==1)
{desc+=$('#quote_prod_name').html();desc+="<br>";desc+=$('#quote_accessories').html();}
$("#quote_dummy").show();$("#request_a_quote").hide();$.post(this_www_root+"ajax.php",{cmd:"quote_request",id:id,category:category,name:name,email:email,phone:phone,custom_products:desc},function(data){$("#quote_message").show();$("#quote_dummy").hide();});};request_a_quote.get_product_category=function(ajax_product_id)
{$.getJSON(this_www_root+"ajax.php",{cmd:"get_field",table:'products',return_field:'Category',field1:'Product_ID',value1:ajax_product_id},function(json){data=json.data;frm=document.frmQuote;if(typeof(document.frmQuote.category)=='undefined'){$('<input type="hidden" name="category" value="'+data+'">').prependTo(frm);}else{document.frmQuote.category.value=data;}});}
request_a_quote.main_product_quote=function(anchor,e)
{var id=$(anchor).attr("id");id=id.substring(2);request_a_quote.get_product_category(id);var prod_name=$("#name-"+id).html();var prod_img=$("#image-"+id).html();request_a_quote.open_popup();$("#quote_prod_name").html('<b>'+prod_name+'</b>');$("#quote_prod_img").html(prod_img);return id;}
request_a_quote.custom_product_quote=function(anchor,e)
{var name=$(anchor).attr("name");var prod_name=name;request_a_quote.open_popup();$("#quote_prod_name").html('<b>'+prod_name+'</b>');document.frmQuote.custom_products.value="1";}
request_a_quote.multiple_products_quote=function(anchor,e)
{var id=document.component_form.id.value;var accessories_id;request_a_quote.open_popup();main_product=product_all.get_main_product_id();request_a_quote.get_product_category(main_product);if(id.indexOf(",")==-1&&main_product==id)
{$("#quote_accessories").html("");}else{accessories_id=id.split(",");if(accessories_id[0]==main_product){accessories_id.shift();}
if(accessories_id[accessories_id.length-1]==""){accessories_id.pop();}
if(accessories_id.length>0)
{var acc_products="<b>Accessories Selected:</b><ul>";for(var i in accessories_id)
{try{acc_products+="<li>";acc_products+=$(":input[id^=inp-"+accessories_id[i]+"][checked]").parent().siblings("[id^=name-"+accessories_id[i]+"]").children('b').text();acc_products+="</li>";}catch(e){}}
acc_products+='</ul><hr>';$("#quote_accessories").html(acc_products);document.frmQuote.custom_products.value="1";}}
var main_product="<b>"+$('h1[id^=name-]').text()+"</b>";if(include_main_product){$('#quote_prod_name').html(main_product);}else{$('#quote_prod_name').html("");}
return id;}
request_a_quote.open_popup=function()
{jQuery.facebox(function(){jQuery.facebox($.ajax({url:this_www_root+'ajax.php?cmd=get_quote_div',async:false}).responseText);});}}
append_script_to_footer(js_file_path+"jquery/jquery.cookie.js");append_script_to_footer(js_file_path+"common_discountedPrice.js");function discountedPrice()
{discountedPrice.productID=0;discountedPrice.handleLoginRegisterSuccess=function(successCode)
{$('.show-discounted-price').hide();$('.discounted-price').show();$('.buy-now-form').show();$('.discounted-price').css({'visibility':'visible'});if(successCode==commonDiscounterPriceDialog.registerSuccess){timmer=setTimeout("jQuery(document).trigger('close.facebox');",3000);}else{jQuery(document).trigger('close.facebox');}
if(typeof(commonPostLoginTasks)=="function"){commonPostLoginTasks();}}
$("a.show-discounted-price").click(function(){id=$(this).attr('id');discountedPrice.productID=id.substr(2);commonDiscounterPriceDialog(discountedPrice.handleLoginRegisterSuccess);$.getJSON(this_www_root+"ajax.php",{cmd:"get_field",return_field:"Name",field1:"Product_ID",value1:discountedPrice.productID,table:"products"},function(json){if(json.data!=""){commonDiscounterPriceDialog.heading="Discounted Price for "+json.data;}})
commonDiscounterPriceDialog.show("Discounted Price Check",site_name);});discountedPrice.bindEvents=function(){}
discountedPrice.bindEvents();}
function bundlediscountedPrice(objOne,objTwo,objThree)
{bundlediscountedPrice.handleLoginRegisterSuccess=function(successCode){if(successCode==commonDiscounterPriceDialog.registerSuccess){timmer=setTimeout("jQuery(document).trigger('close.facebox');",3000);$('#'+objOne).show();$('#'+objTwo).hide();}else{jQuery(document).trigger('close.facebox');$('#'+objOne).show();$('#'+objTwo).hide();}}
bundleevents(objThree);}
function bundleevents(objThree){commonDiscounterPriceDialog(bundlediscountedPrice.handleLoginRegisterSuccess);commonDiscounterPriceDialog.heading=objThree;commonDiscounterPriceDialog.show("Discounted Price Check",site_name);};function bundlediscountedPricekeypressed(objOne,objTwo,objThree){if(event.keyCode=='13'){bundlediscountedPrice(objOne,objTwo,objThree);}}$(document).ready(function(){});var timeout=500;var closetimer=0;var ddmenuitem=0;function dropdown_open()
{dropdown_canceltimer();dropdown_close();ddmenuitem=$(this).find('ul').css('display','block');}
function dropdown_close()
{if(ddmenuitem)ddmenuitem.css('display','none');}
function dropdown_timer()
{closetimer=window.setTimeout(dropdown_close,timeout);}
function dropdown_canceltimer()
{if(closetimer)
{window.clearTimeout(closetimer);closetimer=null;}}
function dropdown_create(menu_ul)
{$(menu_ul+' > li').bind('mouseover',dropdown_open)
$(menu_ul+' > li').bind('mouseout',dropdown_timer)}
document.onclick=dropdown_close;$(document).ready(function(){switch(page)
{case"support":case"about_us":case"contact_us":case"return_policy":case"product_list":case"product":case"static":adjust_panel_height();break;case"comparison":adjust_panel_height();$('.comparison').flexigrid({height:'auto',striped:false});break;case"index":$('.product_combo').change(function(){prod_id=$(this).val();url=this_www_root+'index/product/id/'+prod_id+'#accessories'
document.location=url;});break;}});function adjust_panel_height(){new_height=$("#middle-right").height();prev_height=$("#panel-left").height();if(prev_height<new_height){$("#panel-left").css('height',new_height+'px');}}
