
/***************************** /home/common/js/common_all.js **********************************************/

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();				
				
				// alternate to captcha
				$.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)
	{
	   //<link rel="stylesheet" type="text/css" href="print.css" media="print" />

		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+'');
  //popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  //popUpWin = open(URLStr, 'popUpWin');

}

function roundoff(number,decimal_places)
{
	number = ""+number;
	dot_pos = number.indexOf(".");
	//console.log(dot_pos);
	if(dot_pos==-1){
		// decimal point not found
		// append zeros
		number += "."; 
		for(i=0;i<decimal_places;i++){
			number += "0";
		}
		//console.log(number);
		new_number = number;
		//console.log(new_number);
	}else{
		num_part = dot_pos + decimal_places +1;
		//console.log("indexof: "+num_part);
		new_number = number.substr(0,num_part);
		//console.log(new_number);
		//new_number = (new_number);
	}
	return new_number;
}




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;
}

/***************************** /home/common/js/product_list_all.js **********************************************/


		
		var addthis_pub="clarybusinessmachines";
		
		$(document).ready(function (){
			
			//$('.related_products a').facebox();				
			//append_script_to_footer('http://s7.addthis.com/js/200/addthis_widget.js');
			
			if( $(".quote").length > 0){
				//request_a_quote();
				//append_script_to_footer(this_www_root+"common/js/request_a_quote.js");	
				init_quote = new initialize_addons();
				init_quote.timmer = setTimeout('init_quote.initialize_request_a_quote()',3000);
			}
			
			if( $("a.show-discounted-price").length > 0){
				/*append_script_to_footer(this_www_root+"common/js/discounted_price.js");
				init_discount = new initialize_addons();
				init_discount.timmer = setTimeout('init_discount.initialize_discounted_price()',3000);*/
				/*$("a.show-discounted-price").click(function (){
					id = $(this).attr('id');
					pid = id.substr(2);
					$('form#frm'+pid+'a>:image').trigger('click');
				});*/
                
                append_script_to_footer(js_file_path+"discounted_price.js");
				append_script_to_footer(js_file_path+"common_login.js");
                
                init_discount = new initialize_addons();
				init_discount.timmer = setTimeout('init_discount.initialize_discounted_price()',3000);
				
			}
			
			$('.criteria-tooltip').Tooltip({showURL:false});
			
			
			$('#sort-combo-submitter').click(function (){
				sort_list();				
			});
			
			
			$('.showDetailedCriterias').click(function (){
				$('#category-criterias_wrapper_div').toggle('slow');			
			});
			
			
			$('.showDiv').click(function (){
				var thisdivid=$(this).attr('thisdivid');	
				$('#'+thisdivid+' .criteria-values-wrapper-div').show();	
				$('#'+thisdivid+' .hideDiv').show();	
				$('#'+thisdivid+' .showDiv').hide();	
//				alert(thisdivid);		
			});
			
			$('.hideDiv').click(function (){
				var thisdivid=$(this).attr('thisdivid');	
				$('#'+thisdivid+' .criteria-values-wrapper-div').hide();	
				$('#'+thisdivid+' .showDiv').show();	
				$('#'+thisdivid+' .hideDiv').hide();	
//				alert(thisdivid);		
			});
			
			
			
			
			
		});
		
		
		
	
		
		
		function sort_list()
		{
				var protocol = jQuery.url.attr("protocol");
				var host = jQuery.url.attr("host");
				var path = jQuery.url.attr("path");
				
				// remove page number...
				var to_remove = 'page/';				
				var to_remove_pos = path.indexOf(to_remove);
				if(to_remove_pos !== -1)
				{					
					to_replace = path.substr(to_remove_pos,7);					
					path = path.replace(to_replace,'');
				}
				
				// remove previous sort order
				to_remove = 'sortby/';
				to_remove_pos = path.indexOf(to_remove);				
				if(to_remove_pos !== -1)
				{					
					to_remove_pos_2 = path.indexOf('/',to_remove_pos + 8);					
					if(to_remove_pos_2 !== -1){
						to_replace = path.substring(to_remove_pos,to_remove_pos_2+1);						
						path = path.replace(to_replace,'');
					}
				}
				
				// remove order by clause
				/*to_remove = 'orderby/';
				to_remove_pos = path.indexOf(to_remove);
				if(to_remove_pos !== -1)
				{					
					to_remove_pos_2 = path.indexOf('/',to_remove_pos + 9);
					if(to_remove_pos_2 !== -1){
						to_replace = path.substring(to_remove_pos,to_remove_pos_2+1);
						path = path.replace(to_replace,'');
					}
				}*/
				
				
				// append trailing slash, if necessary...
				var len = path.length;	
				if (path.charAt(len-1) != '/') {
					path = path+'/';
				}
				
				
				var sortby = document.frmSortList.sortby.value;
				if(sortby == "")
				{
					var url_part =  path;					
				}
				else
				{
					/*var hyphen_pos = sortby.indexOf('-');
					if( hyphen_pos == -1)
					{
						var url_part = path+ 'sortby/'+ sortby+'/';
					}
					else
					{
						orderby = sortby.slice(hyphen_pos+1);
						sortby = sortby.slice(0,hyphen_pos);
						var url_part = path+ 'sortby/'+ sortby+'/orderby/'+orderby+'/';
					}*/	
					var url_part = path+ 'sortby/'+ sortby+'/';
				}
				
				var url = protocol + '://' + host + url_part;
								
				//console.log(url);
				document.location.href = url;
		}

/***************************** /home/common/js/clarybusinessmachines/product_list.js **********************************************/



/***************************** /home/common/js/jquery/jquery.dimensions.pack.js **********************************************/

/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-12-20 08:43:48 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4257 $
 *
 * Version: 1.2
 *
 * Requires: jQuery 1.2+
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$.19={P:\'1.2\'};$.u([\'j\',\'w\'],5(i,d){$.q[\'O\'+d]=5(){p(!3[0])6;g a=d==\'j\'?\'s\':\'m\',e=d==\'j\'?\'D\':\'C\';6 3.B(\':y\')?3[0][\'L\'+d]:4(3,d.x())+4(3,\'n\'+a)+4(3,\'n\'+e)};$.q[\'I\'+d]=5(b){p(!3[0])6;g c=d==\'j\'?\'s\':\'m\',e=d==\'j\'?\'D\':\'C\';b=$.F({t:Z},b||{});g a=3.B(\':y\')?3[0][\'8\'+d]:4(3,d.x())+4(3,\'E\'+c+\'w\')+4(3,\'E\'+e+\'w\')+4(3,\'n\'+c)+4(3,\'n\'+e);6 a+(b.t?(4(3,\'t\'+c)+4(3,\'t\'+e)):0)}});$.u([\'m\',\'s\'],5(i,b){$.q[\'l\'+b]=5(a){p(!3[0])6;6 a!=W?3.u(5(){3==h||3==r?h.V(b==\'m\'?a:$(h)[\'U\'](),b==\'s\'?a:$(h)[\'T\']()):3[\'l\'+b]=a}):3[0]==h||3[0]==r?S[(b==\'m\'?\'R\':\'Q\')]||$.N&&r.M[\'l\'+b]||r.A[\'l\'+b]:3[0][\'l\'+b]}});$.q.F({z:5(){g a=0,f=0,o=3[0],8,9,7,v;p(o){7=3.7();8=3.8();9=7.8();8.f-=4(o,\'K\');8.k-=4(o,\'J\');9.f+=4(7,\'H\');9.k+=4(7,\'Y\');v={f:8.f-9.f,k:8.k-9.k}}6 v},7:5(){g a=3[0].7;G(a&&(!/^A|10$/i.16(a.15)&&$.14(a,\'z\')==\'13\'))a=a.7;6 $(a)}});5 4(a,b){6 12($.11(a.17?a[0]:a,b,18))||0}})(X);',62,72,'|||this|num|function|return|offsetParent|offset|parentOffset|||||borr|top|var|window||Height|left|scroll|Left|padding|elem|if|fn|document|Top|margin|each|results|Width|toLowerCase|visible|position|body|is|Right|Bottom|border|extend|while|borderTopWidth|outer|marginLeft|marginTop|client|documentElement|boxModel|inner|version|pageYOffset|pageXOffset|self|scrollTop|scrollLeft|scrollTo|undefined|jQuery|borderLeftWidth|false|html|curCSS|parseInt|static|css|tagName|test|jquery|true|dimensions'.split('|'),0,{}))

/***************************** /home/common/js/jquery/jquery.tooltip.pack.js **********************************************/

/*
 * jQuery Tooltip plugin 1.1
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 *
 * Copyright (c) 2006 Jörn Zaefferer, Stefan Petre
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.tooltip.js 2237 2007-07-04 19:11:15Z joern.zaefferer $
 *
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3($){n d={},l,f,u,O=$.29.1W&&/1S\\s(5\\.5|6\\.)/.1s(1o.28),F=16;$.p={q:16,13:{K:1I,V:U,M:"",t:15,w:15},1n:3(){$.p.q=!$.p.q}};$.Q.1f({p:3(a){a=$.1f({},$.p.13,a);1d();e 2.A(3(){2.8=a;2.N=2.f;$(2).1R("f");2.1Q=""}).1N(11,g).1J(g)},D:O?3(){e 2.A(3(){n b=$(2).m(\'I\');4(b.1z(/^k\\(["\']?(.*\\.1v)["\']?\\)$/i)){b=1t.$1;$(2).m({\'I\':\'1r\',\'S\':"1p:1m.1l.1k(1j=U, 27=24, 1g=\'"+b+"\')"}).A(3(){n a=$(2).m(\'1e\');4(a!=\'1X\'&&a!=\'1b\')$(2).m(\'1e\',\'1b\')})}})}:3(){e 2},1a:O?3(){e 2.A(3(){$(2).m({\'S\':\'\',I:\'\'})})}:3(){e 2},19:3(){e 2.A(3(){$(2)[$(2).z()?"j":"g"]()})},k:3(){e 2.1c(\'1V\')||2.1c(\'1g\')}});3 1d(){4(d.7)e;d.7=$(\'<o 1U="1T"><L></L><o 14="9"></o><o 14="k"></o></o>\').g().1P(\'9\');4($.Q.12)d.7.12();d.f=$(\'L\',d.7);d.9=$(\'o.9\',d.7);d.k=$(\'o.k\',d.7)}3 P(a){4(2.8.K)u=1M(j,2.8.K);B j();F=!!2.8.F;$(\'9\').1L(\'G\',r);r(a)}3 11(){4($.p.q||2==l||!2.N)e;l=2;f=2.N;4(2.8.Z){d.f.g();d.9.z(2.8.Z.1H(2)).j()}B 4(2.8.X){n a=f.1F(2.8.X);d.f.z(a.1E()).j();d.9.1C();1B(n i=0,H;H=a[i];i++){4(i>0)d.9.T("<1A/>");d.9.T(H)}d.9.19()}B{d.f.z(f).j();d.9.g()}4(2.8.V&&$(2).k())d.k.z($(2).k().1y(\'1D://\',\'\')).j();B d.k.g();d.7.1x(2.8.M);4(2.8.D)d.7.D();P.1w(2,1G)}3 j(){u=J;d.7.j();r()}3 r(c){4($.p.q)e;4(!F&&d.7.1u(":1K")){$(\'9\').W(\'G\',r)}4(l==J){$(\'9\').W(\'G\',r);e}n b=d.7[0].Y;n a=d.7[0].10;4(c){b=c.1q+l.8.w;a=c.1O+l.8.t;d.7.m({w:b+\'C\',t:a+\'C\'})}n v=R(),h=d.7[0];4(v.x+v.1i<h.Y+h.18){b-=h.18+20+l.8.w;d.7.m({w:b+\'C\'})}4(v.y+v.17<h.10+h.1h){a-=h.1h+20+l.8.t;d.7.m({t:a+\'C\'})}}3 R(){e{x:$(E).26(),y:$(E).25(),1i:$(E).23(),17:$(E).22()}}3 g(a){4($.p.q)e;4(u)21(u);l=J;d.7.g().1Z(2.8.M);4(2.8.D)d.7.1a()}})(1Y);',62,134,'||this|function|if|||parent|tSettings|body|||||return|title|hide|||show|url|current|css|var|div|Tooltip|blocked|update||top|tID||left|||html|each|else|px|fixPNG|window|track|mousemove|part|backgroundImage|null|delay|h3|extraClass|tooltipText|IE|handle|fn|viewport|filter|append|true|showURL|unbind|showBody|offsetLeft|bodyHandler|offsetTop|save|bgiframe|defaults|class||false|cy|offsetWidth|hideWhenEmpty|unfixPNG|relative|attr|createHelper|position|extend|src|offsetHeight|cx|enabled|AlphaImageLoader|Microsoft|DXImageTransform|block|navigator|progid|pageX|none|test|RegExp|is|png|apply|addClass|replace|match|br|for|empty|http|shift|split|arguments|call|200|click|visible|bind|setTimeout|hover|pageY|appendTo|alt|removeAttr|MSIE|tooltip|id|href|msie|absolute|jQuery|removeClass||clearTimeout|height|width|crop|scrollTop|scrollLeft|sizingMethod|userAgent|browser'.split('|'),0,{}))

/***************************** /home/common/js/jquery/jquery.url.packed.js **********************************************/

jQuery.url=function(){var segments={};var parsed={};var options={url:window.location,strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var parseUri=function(){str=decodeURI(options.url);var m=options.parser[options.strictMode?"strict":"loose"].exec(str);var uri={};var i=14;while(i--){uri[options.key[i]]=m[i]||""}uri[options.q.name]={};uri[options.key[12]].replace(options.q.parser,function($0,$1,$2){if($1){uri[options.q.name][$1]=$2}});return uri};var key=function(key){if(!parsed.length){setUp()}if(key=="base"){if(parsed.port!==null&&parsed.port!==""){return parsed.protocol+"://"+parsed.host+":"+parsed.port+"/"}else{return parsed.protocol+"://"+parsed.host+"/"}}return(parsed[key]==="")?null:parsed[key]};var param=function(item){if(!parsed.length){setUp()}return(parsed.queryKey[item]===null)?null:parsed.queryKey[item]};var setUp=function(){parsed=parseUri();getSegments()};var getSegments=function(){var p=parsed.path;segments=[];segments=parsed.path.length==1?{}:(p.charAt(p.length-1)=="/"?p.substring(1,p.length-1):path=p.substring(1)).split("/")};return{setMode:function(mode){strictMode=mode=="strict"?true:false;return this},setUrl:function(newUri){options.url=newUri===undefined?window.location:newUri;setUp();return this},segment:function(pos){if(!parsed.length){setUp()}if(pos===undefined){return segments.length}return(segments[pos]===""||segments[pos]===undefined)?null:segments[pos]},attr:key,param:param}}();

/***************************** /home/common/js/initialize_addons.js **********************************************/


	function initialize_addons()
	{
		this.timmer = null; // used to clear timeouts..
		
		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);
			}
			
		};			
			
	}

/***************************** /home/common/js/request_a_quote.js **********************************************/


function request_a_quote()
{
	$(".quote").click(function(e)
	{
		// custom_products
		
		var quote_type = $(this).attr('type');
		
		//alert(quote_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);
        
        $('#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();
		}
		
		/*cmb = $('.attribute').get();
		var desc = "";
		$.each(cmb , function(i, n){
			//desc += ", "+$(n).attr('name') +" : "+$(n).val();
			desc += ", "+$(n).attr('name') +" : "+ $(this).children('option:selected').text();
			//console.log($(this).children('option:selected').text());
		});
		
		desc = desc.substr(2);
		console.log(desc);*/
		

		$("#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)		// pass $(this) as argument
	{
			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();
					
            //var html = $("#request_quote").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) 	// pass $(this) as argument
	{
			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)	// pass $(this) as argument
	{
			var id = document.component_form.id.value;
            			
			var accessories_id;
            
            request_a_quote.open_popup();
			
			// if more than one product selected...
			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>";					
					//var ctrl_text = $(":input[id^=inp-"+accessories_id[0]+"][checked]").parent().siblings("[id^=name-"+accessories_id[0]+"]").children('<b>').text();
					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);
                         
        });
        
    }
	
	
}

/***************************** /home/common/js/jquery/jquery.facebox.js **********************************************/

/*
 * DX-SADAF NOTE: THIS IS NOT THE ORIGINAL VERSION
 * I HAVE EDITED IT TO INCLUDE MODAL FUNCTIONALITY...
 *
 *
 *
 *
 * Facebox (for jQuery)
 * version: 1.2 (05/05/2008)
 * @requires jQuery v1.2 or later
 *
 * Examples at http://famspam.com/facebox/
 *
 * Licensed under the MIT:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
 *
 * Usage:
 *  
 *  jQuery(document).ready(function() {
 *    jQuery('a[rel*=facebox]').facebox() 
 *  })
 *
 *  <a href="#terms" rel="facebox">Terms</a>
 *    Loads the #terms div in the box
 *
 *  <a href="terms.html" rel="facebox">Terms</a>
 *    Loads the terms.html page in the box
 *
 *  <a href="terms.png" rel="facebox">Terms</a>
 *    Loads the terms.png image in the box
 *
 *
 *  You can also use it programmatically:
 * 
 *    jQuery.facebox('some html')
 *
 *  The above will open a facebox with "some html" as the content.
 *    
 *    jQuery.facebox(function($) { 
 *      $.get('blah.html', function(data) { $.facebox(data) })
 *    })
 *
 *  The above will show a loading screen before the passed function is called,
 *  allowing for a better ajaxy experience.
 *
 *  The facebox function can also display an ajax page or image:
 *  
 *    jQuery.facebox({ ajax: 'remote.html' })
 *    jQuery.facebox({ image: 'dude.jpg' })
 *
 *  Want to close the facebox?  Trigger the 'close.facebox' document event:
 *
 *    jQuery(document).trigger('close.facebox')
 *
 *  Facebox also has a bunch of other hooks:
 *
 *    loading.facebox
 *    beforeReveal.facebox
 *    reveal.facebox (aliased as 'afterReveal.facebox')
 *    init.facebox
 *
 *  Simply bind a function to any of these hooks:
 *
 *   $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... })
 *
 */
(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)
  }

  /*
   * Public, $.facebox methods
   */

  $.extend($.facebox, {
    settings: {
      opacity      : 0.5,
      overlay      : true,
      modal        : true,  //New parameter 
      showFooter : true,	// New parameter
      loadingImage : this_www_root+'common/images/facebox/loading.gif',
      closeImage   : this_www_root+'common/images/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="'+this_www_root+'common/images/facebox/closelabel.gif" title="close" class="close_image" /> \
                  </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')
      //////////////////CUSTOM CODE ////////////////////////////////////////  
      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
    }
  })

  /*
   * Public, $.fn methods
   */

  $.fn.facebox = function(settings) {
    init(settings)

    function clickHandler() {
      $.facebox.loading(true)

      // support for rel="facebox.inline_popup" syntax, to add a class
      // also supports deprecated "facebox[.inline_popup]" syntax
      var klass = this.rel.match(/facebox\[?\.(\w+)\]?/)
      if (klass) klass = klass[1]

      fillFaceboxFromHref(this.href, klass)
      return false
    }

    return this.click(clickHandler)
  }

  /*
   * Private methods
   */

  // called one time to setup facebox on this page
  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').find('.b:first, .bl, .br, .tl, .tr').each(function() {
      preload.push(new Image())
      preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1')
    })

    $('#facebox .close').click($.facebox.close)
    $('#facebox .close_image').attr('src', $.facebox.settings.closeImage)
  }
  
  // getPageScroll() by quirksmode.com
  function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;	
    }
    return new Array(xScroll,yScroll) 
  }

  // Adapted from getPageSize() by quirksmode.com
  function getPageHeight() {
    var windowHeight
    if (self.innerHeight) {	// all except Explorer
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowHeight = document.body.clientHeight;
    }	
    return windowHeight
  }

  // Backwards compatibility
  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
  }

  // Figures out what you want to display and displays it
  // formats are:
  //     div: #id
  //   image: blah.extension
  //    ajax: anything else
  function fillFaceboxFromHref(href, klass) {
    // div
    if (href.match(/#/)) {
      var url    = window.location.href.split('#')[0]
      var target = href.replace(url,'')
      $.facebox.reveal($(target).clone().show(), klass)

    // image
    } else if (href.match($.facebox.settings.imageTypesRegexp)) {
      fillFaceboxFromImage(href, klass)
    // ajax
    } 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
  }

  /*
   * Bindings
   */

  $(document).bind('close.facebox', function() {
    $(document).unbind('keydown.facebox')
    $('#facebox').fadeOut(function() {
      $('#facebox .content').removeClass().addClass('content')
      hideOverlay()
      $('#facebox .loading').remove()
    })
  })

})(jQuery);


/***************************** /home/clary52/public_html/_templates/_js/header.js **********************************************/



/***************************** /home/clary52/public_html/_templates/_js/product_list.js **********************************************/


	
			
