(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);

dc_Ns = (navigator.appName.indexOf("Netscape") !=-1);
document.onmousemove = mmPos;

function mmPos(ev){
	mX = ((dc_Ns) ? ev.layerX : window.event.offsetX+70);
	mY = ((dc_Ns) ? ev.layerY : window.event.offsetY+250);
	
}

function showInfoPopUp(elm){

document.getElementById(elm).style.top = mY + "px";
document.getElementById(elm).style.left = mX + "px";
document.getElementById(elm).style.visibility = "visible";
}

function hideInfoPopUp(elm){

document.getElementById(elm).style.top = "0px";
document.getElementById(elm).style.left = "0px";
document.getElementById(elm).style.visibility = "hidden";
}

function ContentPreviewSet(id,url,name,description)
{
    $(document).ready(function () 
    {
        $(".gallerypreview").attr('src', url);
        $(".gallerypreview").alt=name;
        $(".gallerypreview").title=description;
    })
}

function order_shippingdata(obj)
{  
    var ischecked = obj.checked;
    if(ischecked)
    {
       document.getElementById('txtSUname').value=document.getElementById('txtFname').value;
       document.getElementById('txtSLname').value=document.getElementById('txtLName').value;       
       document.getElementById('txtSStreet').value=document.getElementById('txtStreet').value;       
       document.getElementById('txtSCity').value=document.getElementById('txtCity').value;    
       document.getElementById('txtSZip').value=document.getElementById('txtPSC').value;
       document.getElementById('txtSState').value=document.getElementById('txtState').value;
       document.getElementById('txtSTel').value=document.getElementById('txtTel').value;
       document.getElementById('txtSFax').value=document.getElementById('txtFax').value;
       document.getElementById('txtSEmail').value=document.getElementById('txtEmail').value;
    }
}

function UFClear()
{
    $('#content_text input[type="text"]').val("");
}

function UFFill(name,value,type,disable)
{
    switch(type)
    {
        case 'text':
           $("input[name="+name+"]").val(value);
           if(disable)
                $("input[name="+name+"]").attr("readonly","true");
          break;    
        case 'select':
          $("select[name="+name+"]").val(value);
          if(disable)
                $("select[name="+name+"] option").each(function()
                {
                      if($(this).val()!=value)
                      {
                        $(this).remove();
                      }
                });

          break;
        case 'radio':
             $('input[name="'+name+'"]').each(function (i) 
             {
                     if($(this).val()==value)
                     {
                        $(this).attr("checked","true");
                        $(this).click(function (i)
                        {
                             $(this).attr("checked","true");
                        });
                     }
             });
              
            if(disable)
            {
              $('input[name="'+name+'"]').each(function (i) 
              {
                     if($(this).val()!=value)
                     {
                        $(this).attr("disabled","true");
                     }
              });
            }
          break;
        case 'checkbox':
            $('input[name="'+name+'"]').each(function (i) 
             {
                     if($(this).val()==value)
                     {
                        $(this).attr("checked","true");
                        $(this).click(function (i)
                        {
                             $(this).attr("checked","true");
                        });
                     }
             });
              
            if(disable)
            {
              $('input[name="'+name+'"]').each(function (i) 
              {
                     if($(this).val()!=value)
                     {
                        $(this).attr("disabled","true");
                     }
              });
            }
          break;                 
        case 'textarea':
          $("textarea[name="+name+"]").val(value);
          if(disable)
                $("textarea[name="+name+"]").attr("readonly","true");
          break;
        default:
    
    }           
}

/********************** modal form *************************/

$(document).ready(function () 
{   
//$('A[rel="gallery"], A[rel="show_gallery"], .show_gallery A,A[rel="show_modal"]').nyroModal();
if (jQuery().nyroModal) 
{
    $(function() 
    {
        $.fn.nyroModal.settings.processHandler = function(settings) 
        {
            var from = settings.from;

            if (from && from.href && from.href.indexOf('.aspx') > 0) 
            {
                var page_url=from.href;
                var param="?page_content_only=";

                if(page_url.indexOf('?')>0)
                {
                    param="&page_content_only=";
                }
                
                page_url=page_url+param;
                
                $.nyroModalSettings(
                {
                    galleryLinks:"",
                    url: page_url
                });     
            }    
        };  
    });
}

//$('A[rel="show_modal"]').nyroModal();
//$('A[rel="show_modal"]').click(function(e) 
//{
//    e.preventDefault();
//    $.nyroModalManual({
//      url: 'http://localhost/web/receiver.html'
//    });
//    return false;
//  });

//$(window).load(function (e) 
//   {
//        e.preventDefault();
//        $.nyroModalManual({
//          blocker: '#inline_form',
//          url: 'http://localhost/web/1.htm'
//        });
//    });

        if (jQuery().nyroModal) 
        {
            $('A[rel="catalog_score"]').click(function (e) 
	        {	
		        e.preventDefault();
			        $("#EshopConditions").modal(
			        {
				        close: true,
				        position: ["10%",],
				        overlayId: 'simplemodal-overlay',
				        containerId: 'simplemodal-container',
				        onOpen: contact.open2,
				        onClose: contact.close
			        });
        		
		        return false;
	        });
        	
	        $('A[rel="show_modal"]').nyroModal(); 
	        return false;
	    }
	    else
        {
            $('A[rel="show_modal"]').click(function (e) 
            {
		        e.preventDefault();
		        // load the contact form using ajax
		        $.get(tb_pathToRoot+"getcontentbyurl.aspx?url="+this, function(data)
		        {
			        // create a modal dialog with the data
			        $(data).modal(
			        {
				        close: true,
				        position: ["10%",],
				        overlayId: 'simplemodal-overlay',
				        containerId: 'simplemodal-container',
				        onOpen: contact.open,
				        onClose: contact.close
			        });
		        });
		        return false;
		     });
		}
	
	$('A[rel="catalog_score"]').click(function (e) 
	{	
		e.preventDefault();
		// load the contact form using ajax
			// create a modal dialog with the data
			$("#EshopConditions").modal(
			{
				close: true,
				position: ["10%",],
				overlayId: 'simplemodal-overlay',
				containerId: 'simplemodal-container',
				onOpen: contact.open2,
				onClose: contact.close
			});
		
		return false;
	});

	// preload images
	/*
	var img = ['cancel.png', 'form_bottom.gif', 'form_top.gif', 'loading.gif', 'send.png'];
	$(img).each(function () 
	{
		var i = new Image();
		i.src = '' + this;
	});
	*/
});

var contact = 
{
	message: null,
	open: function (dialog) 
	{
		// dynamically determine height
		var h = 280;
		if ($('#modalbody').length) {
			h += 26;
		}
		if ($('#contact-cc').length) {
			h += 22;
		}
		
		var title = $('#simplemodal-container .modalheader').html();
		
		$('#simplemodal-container .modalheader').html('Loading...');
		
		dialog.overlay.fadeIn(200, function () 
		{
			dialog.container.slideDown(300, function () 
			{
				dialog.data.fadeIn(500, function () 
				{				    
					//$('#simplemodal-container .modalbody').animate({height: h}, function () 
					//{		
					    
						$('#simplemodal-container .modalheader').html(title);
						$('#simplemodal-container form').fadeIn(200, function () 
						{
						    $('#simplemodal-container').css("background-image","none");
						    $('#simplemodal-container .modalbody').removeClass("nodisplay");
						});
					//});
				});
			});
		});
	},
	open2: function (dialog) 
	{
		// dynamically determine height
		
		var h = 280;
		if ($('#modalbody').length) {
			h += 26;
		}
		if ($('#contact-cc').length) {
			h += 22;
		}
		
		var title = $('#simplemodal-container .modalheader').html();
		
		$('#simplemodal-container .modalheader').html('Loading...');
		
		dialog.overlay.fadeIn(200, function () 
		{
			dialog.container.slideDown(300, function () 
			{
				dialog.data.fadeIn(500, function () 
				{				    
					//$('#simplemodal-container .modalbody').animate({height: h}, function () 
					//{		
					 $('#simplemodal-container').css("background-image","none");
						    $('#simplemodal-container .modalbody').removeClass("nodisplay");
						     $('#simplemodal-container .modalheader').removeClass("nodisplay");

						$('#simplemodal-container .modalheader').html(title);
						//$('#simplemodal-container form').fadeIn(200, function () 
						//{
						  //  $('#simplemodal-container').css("background-image","none");
						   // $('#simplemodal-container .modalbody').removeClass("nodisplay");
						//});
					//});
				});
			});
		});
	
	},
	close: function (dialog) 
	{
		$('#simplemodal-container .message').fadeOut();
		$('#simplemodal-container .modalheader').html('Goodbye...');
		$('#simplemodal-container form').fadeOut(200);
		$('#simplemodal-container .modalbody').animate(
		{
			height: 40
		}, function () 
		{
			dialog.data.fadeOut(200, function () 
			{
				dialog.container.fadeOut(200, function () 
				{
					dialog.overlay.fadeOut(200, function () 
					{
						$.modal.close();
					});
				});
			});
		});
	},
	error: function (xhr) 
	{
		alert(xhr.statusText);
	}
};
    
function parseXML(data) 
{

    var results = [];
    var items = $(data).find('Item');

    $(items).each(function() 
    {
        var text = $.trim($(this).find('name').text());
        results[results.length] = {'data': [text], 'result': text, 'value': text};
    });
        $(results).each(function() 
    {
    });

    return results;
};

$(document).ready(function(){
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.jqbookmark").attr("rel") != ""){
			$("a.jqbookmark").attr("rel","sidebar");
		} 
	}

	$("a.jqbookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.title;
		
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing
		} else { 
			 alert('Unfortunately, this browser does not support the requested action, please bookmark this page manually.');
		}
	
	});
});

$(document).ready(function()
{
    $('A[rel="print_page"]').click(function(e) 
    {
        e.preventDefault();
        window.print();
        return false;
     });
})


$(document).ready(function()
{  
    if (jQuery().nyroModal) 
    {
        $('A[rel="gallery"], A[rel="show_gallery"], .show_gallery A').nyroModal();
    }
    else
    {
        tb_init('A[rel="gallery"], A[rel="show_gallery"], .show_gallery A');
        imgLoader = new Image();
        imgLoader.src = tb_pathToImage+"loading.gif";
    }
  
});


function setIECookie()
{
    var options = { path: '/', expires: 1 };

    $.cookie("web_ie_warn", '1', options);
    
    window.location.reload();
}

$.getScript('http://use.typekit.com/vqg7idk.js',function(){
		try{Typekit.load();}catch(e){}
	});

