var ua = null;
switch(true)
{
	case navigator.userAgent.indexOf("Opera")>-1 :
		ua = "O";
		window.captureEvents(Event.MOUSEMOVE);
		window.onmousemove = function(e){mouseX = e.pageX; mouseY = e.pageY};
		break;
	case navigator.userAgent.indexOf("MSIE")>-1 :
		ua = "IE";
		break;
	case navigator.userAgent.indexOf("Gecko")>-1 :
		ua = "FF";
		window.captureEvents(Event.MOUSEMOVE);
		window.onmousemove = function(e){mouseX = e.pageX; mouseY = e.pageY};
		break;
}


function sendReproductions() {
    var img = $('#imgTV').attr('src');
    var html_text = '<input type="hidden" name="img_src" value="'+img+'" />';
    //$('#img-order-form').append(html_text);
    Navigate.isSendReproductions = true;
    Navigate.imgSrc = html_text;
    Navigate.imgUrl = img;
    Navigate.geth('/html/special-jewelry.php', 'content_box');
    //alert('s');
    return false;
    
}

function gE(id)
{
	return document.getElementById(id);
}

function s(id)
{
	document.getElementById(id).style.display = 'block';
}

function h(id)
{
	document.getElementById(id).style.display = 'none';
}

function hl()
{
//	$('//div[@align="center"]').remove();
}

var fields = {
	0: [
			'KitGroupID_21_TextOption_35'
		],
	1: [
			'KitGroupID_5_TextOption_17'		
		]
}
global_ass = undefined;
function getGI(id, pid, href)
{
	global_ass = 1;
	Tape.reset(href.indexOf('/collectable/') !== -1); 

	if (href)
	{
		trackPage(href);
	}

	if ($('#left-tape_body').html())
	{
		Navigate.geth('x-galery.subcat.aspx?categoryid=' + (pid=='37' ? id : (pid + '&stay=' + id)), 'left-tape_body', true);
		Navigate.categoryId	= (pid=='37' ? id : pid + '&stay=' + id);
		Navigate.stayId			= (pid=='37' ? 0 :	 id);
		setTimeout('$("#zoomCont").css({background:"none"});', 500);
		return false;
	}
	return true;

}

function trackPage(href)
{
	if (href.indexOf('http:') !== 0)
	{
		href = 'http://treviartgallery.com' + href;
	}

	// Google analytics
	try
	{
		pageTracker._trackPageview(href);
	}
	catch (e)	{}
}

function csel() {

	// -- ajax form
	//AForm.init();
	
	// Selects
	$('select').combobox( { comboboxContainerClass: "comboboxContainer", comboboxValueContainerClass: "comboboxValueContainer", comboboxValueContentClass: "comboboxValueContent", comboboxDropDownClass: "comboboxDropDownContainer", comboboxDropDownButtonClass: "comboboxDropDownButton", comboboxDropDownItemClass: "comboboxItem", comboboxDropDownItemHoverClass: "comboboxItemHover", comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader", comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer", animationType: "slide", width: "200px" });

//	debugger;
	if (!$('.comboboxDropDownContainer li:eq(2)').html())
	{
		$('.comboboxDropDownContainer li:eq(2)').hide();
	}

//	Img.hide_('Nerrative');

}

var AForm = {

	init : function()
	{
		if ($('#ajax-form'))
		{
			var name = $('#ajax-form').attr('name');

			$(document).ready(function() { 
				var options = { 
			//		target:			'#ajax-form',  
					beforeSubmit:	AForm.request,  // pre-submit callback 
					success:			AForm.response  // post-submit callback 
				};

				$('#ajax-form').ajaxForm(options); 

			});	

		//	debugger;
		}

	},

	request : function(formData, jqForm, options)
	{
		alert(formData);
	},

	response : function(responseText, statusText)
	{
	},

	RValidate : function()
	{

		if ($("#sfName").val() && $("#sfWidth").val() && $("#sfHeight").val() && $("#sfPhone").val() && $("#sfEmail").val())
		{
			return true;
		}

		return false;
	},

	CValidate : function()
	{

		if ($("#sfName").val() && $("#sfComment").val() && $("#sfPhone").val())
		{
			return true;
		}

		return false;
	}
}

fm = 1;

var CTitle = {

	title : '',

	cat : function(title)
	{
		this.title = title;
	//	debugger;
	},

	subcat : function(title)
	{
		var src = '/inc/fontservice/font.php?h=20&w=500&br=30&bg=30&bb=30&fr=255&fg=255&fb=255&fsize=16&text='+this.title+'+/+'+title+'&fontName=copperlate';
		$('#categoryPath>img').attr('src', src);
	},
		
	img : function(title)
	{
		var src = '/inc/fontservice/font.php?h=14&w=600&br=30&bg=30&bb=30&fr=255&fg=255&fb=255&fsize=' + (title.length > 60 ? (title.length > 80 ? 8 : 10) : 12) + '&text='+title+'&fontName=copperlate';
		$('#imgName>img').attr('src', src);
	}
		

}



function myinit()
{
	if (($.browser.msie || $.browser.mozilla || $.browser.opera || $.browser.safari) && !$.cookie('intro'))
	{	
		var so = new SWFObject("/i/headerArt.swf","introswf","835","380","8","#000000");
		so.addParam("wmode", "transparent");
		so.write("intro");

        
		$('#logo').css({display: 'block'});
        var DAY = 24 * 60 * 60 * 1000;
        var date = new Date();
        date.setTime(date.getTime() + (1 * DAY)); // 1 day
		$.cookie('intro', 1, { path: '/', expires: date} );

//		window.setTimeout("hideIntro()", 7000);
		window.setTimeout("introChkStop()", 5000);

	}

	run_writer(); //setInterval("run_writer();", 30000);
	csel();

	if (location.href.indexOf('/reproductions') !== -1)
	{
		Tape.reset(); 
		//$('#order-box-form').css({display: 'none'});
	}

}


function run_writer()
{

	if ($.browser.msie)
	{
		$('#fwriter').media({
			width:     500,
			height:    150,
			src:       "/i/swf/demo_jewel.swf?sign_text=" + escape("Happy holiday season!! \n50% off on all digital images")+"&sign_scale=0.55&offset_x=10&sign_color=0xFFFFFF&line_height=60&offset_x=0&offset_y=40",
			attrs:     {id:'swfwriter',wmode: 'transparent', scale: "noborder", quality:"high", allowscriptaccess:"crossDomain", bgcolor:"2A2A2A"},  // object/embed attrs 
			params:    {id:'swfwriter',wmode: 'transparent', scale: "noborder", quality:"high", allowscriptaccess:"crossDomain", bgcolor:"2A2A2A"} // object params/embed attrs 
		});

		$('#fwriter').css({background:'none',position:'absolute',top:'-50px',left:'250px'});
	}
	else
	{
		$('#fwriter').media({
			width:     900,
			height:    130,
			src:       "/i/swf/demo_jewel.swf?sign_text=" + escape("Happy holiday season!! 50% off on all digital images")+"&sign_scale=0.35&offset_x=10&sign_color=0xFFFFFF&line_height=60&offset_x=30&offset_y=40",
			attrs:     {id:'swfwriter',wmode: 'transparent', scale: "noborder", quality:"high", allowscriptaccess:"crossDomain", bgcolor:"2A2A2A"},  // object/embed attrs 
			params:    {id:'swfwriter',wmode: 'transparent', scale: "noborder", quality:"high", allowscriptaccess:"crossDomain", bgcolor:"2A2A2A"} // object params/embed attrs 
		});

		$('#fwriter').css({background:'none',position:'absolute',top:'3px',left:'78px'});
	}
}


function choform()
{
	if (!Img.nosub)
	{
		var val  = jQuery('#kit-select').val();

		if (val)
		{

			$.get('/order_painting.php?productId=' + ($('#sale-id').length ? $('#sale-id').html() : $('.comboboxDropDownContainer .sale-id').html()), function (data) {

				choform_(data);
			});
		}
		else
		{
			choform_(val);
		}
	}

}

function choform_(val)
{
	if (val)
	{
		jQuery('input[@name="ProductID"]').val(val).attr('id', 'ProductID_'+val);
		jQuery('input[@name="IsWishList"]').attr('id', 'IsWishList_'+val);
		jQuery('input[@name="UnitMeasureCode"]').attr('id', 'UnitMeasureCode_'+val);
		jQuery('input.vAddtoCart').attr('id', 'AddtoCart_'+val).attr('name', 'AddtoCart_'+val);
	}
}
/*
function setJwProductID(val)
{
	jQuery('#order-box-ext input[@name="ProductID"]').val(val).attr('id', 'ProductID_'+val);
	jQuery('#order-box-ext input[@name="IsWishList"]').attr('id', 'IsWishList_'+val);
	jQuery('#order-box-ext input[@name="UnitMeasureCode"]').attr('id', 'UnitMeasureCode_'+val);
	jQuery('#order-box-ext input.vAddtoCart').attr('id', 'AddtoCart_'+val).attr('name', 'AddtoCart_'+val);
}
*/
function choform_jewelry()
{
	var productId	= $('#order-box-ext .ProductID').val();
	
	var issue = $('.issue').html();

	var url = 'order_' + (issue == 'jewelry' ? 'jewelry' : 'armory') + '.php?productId=' + productId;

	$.get(url, function (data) {

		$("#order-box-ext .ProductID").val(data).attr('id', 'ProductID_' + data);
		$("#order-box-ext .AddtoCart").attr('name', 'AddToCart_' + data).attr('id', 'AddToCart_' + data);
		$("#order-box-ext .IsWishList").attr('name', 'IsWishList_' + data).attr('id', 'IsWishList_' + data);

		$('#add-to-card-ext').submit();

	});

}

function loadSound()
{
        var sounds = [
		"/i/sound/shopen-waltz-in-c.mp3",
                "/i/sound/shopen-waltz-in-e.mp3",
                "/i/sound/shopen-waltz-in-g.mp3",
		"/i/sound/moscow.mp3"
        ];
	$.fn.media.defaults.bgColor="";
	if(document.location.pathname != "/")
        $('#snd').media({
                width:     115,
                height:    25,
                src:       "/i/sound/snd.swf?mp3String="+sounds.join(";"),
                attrs:     { wmode: 'transparent', scale: "noborder", quality:"high", allowscriptaccess:"sameDomain"},  // object/embed attrs 
                params:    { wmode: 'transparent', scale: "noborder", quality:"high", allowscriptaccess:"sameDomain"} // object params/embed attrs 
        });
	if($.browser.msie) {
                //alert(1);
                ///$("#snd").attr('style', 'top: 1080px');
        }

}

