//eDIY AJAX script
var ajaxIsBusy = 0;
var orderState = "";
var userAgentButton = "";
var updateOrderStatus = 0;
var currPageY = 0;
//var updateOrderStatus = 0;
function ajaxOrderAlert() {
	alert("This item has been added to your cart.  When you have finished adding items, scroll to the top of the page and click Checkout >> to continue.");
}

function GoToSummary() {
	window.location='/content.asp?function=ordersummary';
}

function onLoad() {
	//loadOnlyFirst();

	onPageShow();
	
}

function UpdateProductPicture(src, value) {
	var v;
	v = value.split("_");
	//alert(value);

	try {
		if (parseInt(v[1]) > 0) {
			document.getElementById('PRDPIC'+v[2]).src= "/site/images/" + v[1] + ".jpg";
			//document.getElementById('PRDPIC'+v[2]).height="";
			//document.getElementById('PRDPIC'+v[2]).width="";
		}
	}
	catch(e) {}

	try {	
		if (parseInt(v[1]) > 0) {
			document.getElementById('PRDTHUMB'+v[2]).src= "/site/images/" + v[1] + "_thumb.jpg";
			//document.getElementById('PRDTHUMB'+v[2]).height="";
			//document.getElementById('PRDTHUMB'+v[2]).width="";
		}

	}
	catch(e) {}

}

function OnCreatedResale() {

}
function AddServicesPanel() {

}

var httpPV;

function OpenProductView(prdID, templateID) {
	httpPV = ajaxCreateRequestObject();
	try {
		document.getElementById("sb-product").outerHTML = "";
	} catch(e) {}
	
	httpPV.open('get', '/dynamic/content.asp?syscmd=ajaxcommand&cmd=Render&dispmode=frame&args=,viewprd,0&style=' + templateID + '&prd_id=' + prdID + '&rnd='+rnd(9999999));
   httpPV.onreadystatechange = ajaxPVResponse;
   httpPV.send(null);
}

function OpenPageView(pageID) {
	httpPV = ajaxCreateRequestObject();
	try {
		document.getElementById("sb-product").outerHTML = "";
	} catch(e) {}
	
	httpPV.open('get', '/dynamic/content.asp?syscmd=ajaxcommand&cmd=Render&dispmode=frame&args=,,'+pageID+'&rnd='+rnd(9999999));
   httpPV.onreadystatechange = ajaxPVResponse;
   httpPV.send(null);
}


function OpenProductFunction(funcName, prdID,  templateID) {
	httpPV = ajaxCreateRequestObject();
	try {
		document.getElementById("sb-product").outerHTML = "";
	} catch(e) {}
	
	
	var qty = document.getElementById("QTY" + prdID).value;
	var pmmID = 0;
	if (qty != "") {
		if (document.getElementById("PR" + prdID)) {
			var v = document.getElementById("PR" + prdID).value.split("_");
			pmmID = v[0];
		}
	}
	
	httpPV.open('get', '/dynamic/content.asp?dispmode=frame&function=' + funcName + '&style=' + templateID + '&prdid=' + prdID + '&pmmid='+ pmmID + '&qty='+qty+'&rnd='+rnd(9999999));
	httpPV.onreadystatechange = ajaxPVResponse;
	httpPV.send(null);
}
function OpenPicture(picUrl, lMaxWidth) {
	Shadowbox.open({
				  player:     'img',
				  content:    picUrl

			});
}

function ajaxPVResponse() {
	if(httpPV.readyState == 4){
		//var response = httpPV.responseText;
		try {
			Shadowbox.open({
				  player:     'html',
				  content:    '<div id="sb-product" style="text-align: left; height:340px;width:550px; padding: 10px; font: 10pt Verdana">' + httpPV.responseText + '</div><div style=" display:block; width:95%; text-align: right; padding: 10px; font: 11pt Arial"><a href="#" onClick="Shadowbox.close();">Close</a></div>',
				  height:     550,
				  width:      600
			});
		}
		catch (e) {
		}
	}
}

var httpEval;

function OpenScriptEval(sURL) {
	
	httpEval = ajaxCreateRequestObject();
	
	httpEval.open('get', sURL);
   httpEval.onreadystatechange = ajaxEvalResponse;
   httpEval.send(null);
}

function ajaxEvalResponse() {
	if(httpEval.readyState == 4){
		try {
			eval( httpEval.responseText );
		}
		catch (e) {
			alert ("Eval error: " + e.message);
		}
	}
}

function pollYPosition(){
	if (navigator.appName == "Microsoft Internet Explorer")
		{var position = document.body.scrollTop;}
	else 
		{var position = window.pageYOffset;}
	 
	if (position != currPageY)
		{
			$("#bottomstatusbar").width($("#bottomstatusbar").width());
			currPageY = position;
		}
	return true;
}
	
function onPageShow() {
	var FORM_STATUSBOX = 168;
	try {
		setInterval("pollYPosition()",500);
 

		if (updateOrderStatus)
		{
			if (updateOrderStatus == 1) {
				ajaxSendRequest("orderstatus","OrderStatus","0,2"); // no container div
			}
		}
	}
	catch (e){
		try {
			ajaxSendRequest("orderstatus","OrderStatus","0,2");
			
		}
		catch (e){
		}
		
	}
	
}

function edUpdateOrderStatus() {
	
}

var Webtrade = {
	ProfileEvent: function (custID,other,ptype,orientation, tplID) {
		//var url = "/content.asp?function=member&tplID=224&type="+ptype+"&id="+custID+"&TPLPreviewID="+tplID+"&TPLPreviewDir="+orientation;
		//window.location.href = url;
		
	}
}


function addEvent(element, type, handler)
{
	if (element.addEventListener)
		element.addEventListener(type, handler, false);
	else
	{
		if (!handler.$$guid) handler.$$guid = addEvent.guid++;
		if (!element.events) element.events = {};
		var handlers = element.events[type];
		if (!handlers)
		{
			handlers = element.events[type] = {};
			if (element['on' + type]) handlers[0] = element['on' + type];
			element['on' + type] = handleEvent;
		}
	
		handlers[handler.$$guid] = handler;
	}
}
addEvent.guid = 1;

function removeEvent(element, type, handler)
{
	if (element.removeEventListener)
		element.removeEventListener(type, handler, false);
	else if (element.events && element.events[type] && handler.$$guid)
		delete element.events[type][handler.$$guid];
}

function handleEvent(event)
{
	
	var returnValue = true;
	try {
		event = event || fixEvent(window.event);
		var handlers = this.events[event.type];
	
		for (var i in handlers)
		{
			if (!Object.prototype[i])
			{
				this.$$handler = handlers[i];
				if (this.$$handler(event) === false) returnValue = false;
			}
		}
	
		if (this.$$handler) this.$$handler = null;
	}
	catch (e) {
	}
	return returnValue;
}

function fixEvent(event)
{
	event.preventDefault = fixEvent.preventDefault;
	event.stopPropagation = fixEvent.stopPropagation;
	return event;
}
fixEvent.preventDefault = function()
{
	this.returnValue = false;
}
fixEvent.stopPropagation = function()
{
	this.cancelBubble = true;
}

if (!window.addEventListener)
{
	document.onreadystatechange = function()
	{
		if (window.onload && window.onload != handleEvent)
		{
			try {
				addEvent(window, 'load', window.onload);
				window.onload = handleEvent;
			}
			catch (e) {
			}
		}
	}
}

function flashCart() {
	//for (var i = 1; i <= 5; i++) {
	//	var c = document.getElementById("cart"+i);
	//	c.style.backgroundColor="#cccc66";
//	}
}

var inFade = 0;
var inDelay = 0;
var isOver = 0;
var fader = {
	flash: function(objID) {
		setTimeout("fader.fade('"+ objID + "','trans80YEL')",2200);
		setTimeout("fader.fade('"+ objID + "','trans80')",2400);
		setTimeout("fader.fade('"+ objID + "','trans80YEL')",2600);
		setTimeout("fader.fade('"+ objID + "','trans80'); ",2800);
	},
	
	fade: function(objName, cls) {
		document.getElementById(objName).className=cls;
	},
	
	fadeIn: function(objID) {
		isOver = 1;
		if ((inFade == 0) && (inDelay == 0)) {
			inFade = 1;
			setTimeout("fader.fade('"+ objID + "','trans85')",100);
			setTimeout("fader.fade('"+ objID + "','trans90')",150);
			setTimeout("fader.fade('"+ objID + "','trans95')",200);
			setTimeout("fader.fade('"+ objID + "','trans100'); inFade = 0;",300);
		}
	},
	
	fadeOut: function(objID) {
		if ((isOver == 1)  && (inDelay == 0)) {
			inDelay = 1;
			setTimeout("if(isOver == 0) {inDelay = 0;  fader.fadeOut('"+ objID + "'); } else {inDelay = 0; }",1000);
		} else {
			if ((inFade == 0) && (inDelay == 0)) {
				inFade = 1;
				setTimeout("fader.fade('"+ objID + "','trans95')",100);
				setTimeout("fader.fade('"+ objID + "','trans90')",150);
				setTimeout("fader.fade('"+ objID + "','trans85')",200);
				setTimeout("fader.fade('"+ objID + "','trans80'); inFade = 0;",300);
			}
		}
		isOver = 0;
	}
}


function ajaxProcessOrderSubmit(prdID, absqty) {
	//window.scrollTo(0,0);						
	try {
		document.getElementById('bottomstatusbar').style.display='block';
		fader.flash('bottomstatusbar');
	}
	catch (e) {
	}
	
	var ordStr = "";
		
	if (prdID > 0) {
		var inputs = document.getElementsByTagName("select")
		var qty = document.getElementById("QTY" + prdID).value;
		
		var dynPrice = 0;
		if (document.getElementById("prdprice")) 
			if (parseInt(document.getElementById("prdprice").value) > 0) {
				dynPrice = document.getElementById("prdprice").value;
			}
		
		var pmmID = 0;
		if (qty != "") {
			if (document.getElementById("PR" + prdID)) {
				var v = document.getElementById("PR" + prdID).value.split("_");
				pmmID = v[0];
			}
			flashCart();
			
			for (var i = 0; i <= inputs.length; i++) {
				if (inputs[i]) {
					if (inputs[i].id.substring(0,3) == "OPT") {
						var ord = inputs[i].id.split("-");
						//OPT171310-1
						if (ord.length > 0) {
							ordStr += inputs[i].value+" ";
						}
					}
					if (inputs[i].name.substring(0,3) == "TXT") {
						if (inputs[i].value.length > 0) {
							ordStr += "Text: " + inputs[i].value+" ";
						}
					}
					
					
					
				}
			}	
			try {
				var txt = document.getElementsByName("TXT" + prdID);
				if (txt[0]) {
					ordStr += "Text: " + txt[0].value +" ";
				}
			
		
				Shadowbox.close();
			} catch (e) {}
			if (absqty)
				ajaxSendRequest("orderstatus","AddOrderLineItem",prdID+","+pmmID+",-"+qty+","+ordStr+",0,"+dynPrice+",");
			else
				ajaxSendRequest("orderstatus","AddOrderLineItem",prdID+","+pmmID+","+qty+","+ordStr+",0,"+dynPrice+",");
		}
	} else {
		var inputs = document.getElementsByTagName("input")

		for (var i = 0; i <= inputs.length; i++) {
			if (inputs[i]) {
				if (inputs[i].id.substring(0,4) == "ORD_") {
					var ord = inputs[i].id.split("_");
					
					//alert (inputs[i].id + ": " +ord.length + " val: " +inputs[i].value)
					if (ord.length == 3) {
						if (inputs[i].value > 0) {
							//alert ("ORDER: " + inputs[i].id + ": " +ord.length + " val: " +inputs[i].value)
							ordStr += ord[1]+"_"+ord[2]+"_"+inputs[i].value+"^";
						}
						inputs[i].value = "";
					}
				}
			}
		}
		//alert(ordStr);
		//ord[1]+","+ord[2]+","+inputs[i].value+"
		
		
		try {

			
			Shadowbox.close();
		} catch (e) {}

		
		if (ordStr != "") {
			flashCart();
			ajaxSendRequest("orderstatus","AddOrderLineItem","0,0,0,,0,0,,"+ordStr);
	
			//ajaxSendRequest("topbar","AddOrderLineItem","0,0,0,,0,0,,"+ordStr);
			}
			


	
	}
	
				
}

// re-run the last AJAX call
function ajaxGoBack() {
	var LastCmd;
	http.open('get', LastCmd);
   http.onreadystatechange = ajaxHandleResponse;
   http.send(null);
}

// Direct AJAX functions

function ajaxCreateRequestObject() {
     var ro;
     var browser = navigator.appName;
     if(browser == "Microsoft Internet Explorer"){
          ro = new ActiveXObject("Microsoft.XMLHTTP");
     }else{
          ro = new XMLHttpRequest();
     }
     return ro;
}

var http = ajaxCreateRequestObject();

function rnd(max) {
	var rndnum = max * Math.random();
	rndnum = Math.ceil(rndnum);
	return rndnum;
}

function InitResale() {
	http.open('get', '/resale/json.aspx&rnd='+rnd(9999999));
   http.send(null);
}
	

function ajaxSendRequest(sid,cmd,args) {
  // document.body.style.cursor = "wait";
   
   if (cmd != 'order')
   	LastCmd = 'content.asp?syscmd=ajaxcommand&sid='+sid+'&cmd='+cmd+'&args='+URL.encode(args);
   	
	//if (typeof(wtPageID) != 'undefined')
	//	http.open('get', '/dynamic/content.asp?syscmd=ajaxcommand&sid='+sid+'&cmd='+cmd+'&args='+args+'&nocontext=1&pageID='+wtPageID+'&rnd='+rnd(9999999));
//	else
	
	http.open('get', '/dynamic/content.asp?syscmd=ajaxcommand&sid='+sid+'&cmd='+cmd+'&args='+URL.encode(args)+'&nocontext=1&rnd='+rnd(9999999));
   http.onreadystatechange = ajaxHandleResponse;
   ajaxIsBusy = 1;
   http.send(null);
}

function ajaxHandleResponse() {
	if(http.readyState == 4){
		var response = http.responseText;
		var update = new Array();
		
		//document.body.style.cursor = "default";
		if(response.indexOf('' != -1)) {
			update = response.split('|');
			try {
				//if (update[0] == "tipclick_div") {
				//	tipclick.show (update[1], tipclickobj, tipclickevent);
				//} else {
					if (document.getElementById(update[0]))
						document.getElementById(update[0]).innerHTML = update[1];
				//}
			}
			catch (e) {
			}
			ajaxIsBusy = 0;
			if (update[0] == "orderstatus") {
				orderState = update[1];
				ajaxSendRequest("sbcontent","StatusBar","");
			}
				
		}
		
	}
}

function ediyOpenWindow(sURL, lWidth, lHeight) {
	var thewindow = window.open(sURL,'thewindow','location=no,status=no,height='+lWidth+',width='+lHeight+',scrollbars=no,resizable=no'); 
	return false;
}

function orderStatusInit() {
	ajaxSendRequest("orderstatus","OrderStatus","999,1");
}

function bookmarkPage(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
var numtimes = 0;

function findInPage(str) { 
	var NS4 = (document.layers); 
	var win = window; 
	//var n = 0; 
	var IE4 = (document.all); 
	var txt, i, found; 
	
	if (str == "") return false; 
	if (NS4) { 
		if (!win.find(str)) while(win.find(str, false, true)) 
			numtimes++; 
		else 
			numtimes++; 
			
		if (numtimes == 0) 
			alert("Could not find "+str+"."); 
	} 
	if (IE4) { 
		txt = win.document.body.createTextRange(); 
		for (i = 0; i <= numtimes && (found = txt.findText(str)) != false; i++) { 
			txt.moveStart("character", 1); txt.moveEnd("textedit"); 
		} 
		if (found) { 
			txt.moveStart("character", -1); 
			txt.findText(str); 
			txt.select(); 
			txt.scrollIntoView(); 
			numtimes++; 
		} else { 
			if (numtimes > 0) { 
				numtimes = 0; findInPage(str); 
			} else 
				alert("Could not find "+str+"."); 
		} 
	} 
	return false; 
}


var tipclick = {
        vertical_offset : '-3px',
        horizontal_offset : '-3px',
        delay_disappear : 500,
        delay_appear : 500,
		  
		  load : function(pageID,obj,e) {
				this.show("Please Wait, Loading...", obj, e);
				//tipclickobj = obj;
				//tipclickevent = e;
				
				ajaxSendRequest("tipclick_div","Panel",pageID);
			},
			

        show : function(content, obj, e) {
                if (window.event) { 
                        event.cancelBubble=true;
                } else if (e.stopPropagation) {
                        e.stopPropagation();
                }
                this._do_hide();
                var tooltip = document.getElementById("tipclick_div");
                tooltip.innerHTML = content;
                if ((e.type == "click") || e.type == "mouseover") {
                        var self = this;
                        this._show_handler = setTimeout(function() {self._do_show();}, this.delay_appear);
                } //else if (e.type=="click") {   && tooltip.style.visibility == 'hidden'
                   //     tooltip.style.visibility = 'hidden';
               // }
                tooltip.x = this._get_pos_offset(obj, true);
                tooltip.y = this._get_pos_offset(obj, false);
                tooltip.style.left = tooltip.x - this._clear_browser_edge(obj, true) + "px";
                tooltip.style.top = tooltip.y - this._clear_browser_edge(obj, false) + obj.offsetHeight + "px";
                return true;
        },

        hide : function() {
                this._must_hide = true;
                var self = this;
                this._hide_handler = setTimeout(function() { self._do_hide(); }, this.delay_disappear);
                return true;
        },
        
        //---Private
        _show_handler : null,
        _hide_handler : null,
        _must_hide : true,

        _clear_tip : function() {
                if (typeof this._hide_handler != "undefined" || this._hide_handler !== null) {
                        clearTimeout(this._hide_handler);
                        delete(this._hide_handler);
                }
                if (typeof this._show_handler != "undefined" || this._show_handler !== null) {
                        clearTimeout(this._show_handler);
                        delete(this._show_handler);
                }
        },
        
        _get_pos_offset : function(what, is_left) {
                var total_offset = (is_left) ? what.offsetLeft : what.offsetTop;
                var parentEl = what.offsetParent;
                while (parentEl !== null) {
                        total_offset = (is_left) ? total_offset + parentEl.offsetLeft : total_offset + parentEl.offsetTop;
                        parentEl = parentEl.offsetParent;
                }
                return total_offset;
        },
        
        _clear_browser_edge : function(obj, is_horizontal) {
                var tooltip = document.getElementById("tipclick_div");
                var edge_offset = (is_horizontal) ? parseInt(this.horizontal_offset, 10)*-1 : parseInt(this.vertical_offset, 10)*-1;
                var is_ie = document.all && !window.opera;
                var window_edge, content_measure;
                if (is_ie) {
                        var ie_body = this._ie_body();
                }
                if (is_horizontal) {
                        window_edge = is_ie ? ie_body.scrollLeft + ie_body.clientWidth-15 : window.pageXOffset+window.innerWidth-15;
                        content_measure = tooltip.offsetWidth;
                        if (window_edge - tooltip.x < content_measure) {
                                edge_offset= content_measure - obj.offsetWidth;
                        }
                } else {
                        window_edge = is_ie ? ie_body.scrollTop + ie_body.clientHeight-15 : window.pageYOffset+window.innerHeight-18;
                        content_measure= tooltip.offsetHeight;
                        if (window_edge - tooltip.y < content_measure) {
                                edge_offset = content_measure + obj.offsetHeight;
                        }
                }
                return edge_offset;
        },
        
        _ie_body : function() {
                return (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body;
         },
         
        _do_show : function() {
                document.getElementById("tipclick_div").style.visibility="visible";
        },
        
        _do_hide : function() {
                if (this._must_hide) {
                        document.getElementById("tipclick_div").style.visibility="hidden";
                }
                this._clear_tip();
        },
        
        _continue : function() {
                this._must_hide = false;
        },
        
        _stop : function() {
                this._must_hide = true;
                this.hide();
        }
};

var URL = {
 	getParam: function (param) {
	    param = param.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
	
	    var regexS  = '[\\?&]' + param + '=([^&#]*)',
	        regex   = new RegExp(regexS),
	        results = regex.exec(window.location.href);
	
	    if (results === null) {
	        return '';
	    } else {
	        return results[1];
	    }
	},

    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

} 


if(typeof com=="undefined"){var com=new Object();}
if(typeof com.deconcept=="undefined"){com.deconcept=new Object();}
if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object();}
if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object();}
com.deconcept.FlashObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
this.useExpressInstall=_7;
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new com.deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.addParam("wmode","transparent");

var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}
};
com.deconcept.FlashObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},createParamTag:function(n,v){
var p=document.createElement("param");
p.setAttribute("name",n);
p.setAttribute("value",v);
return p;
},getVariablePairs:function(){
var _19=new Array();
var key;
var _1b=this.getVariables();
for(key in _1b){_19.push(key+"="+_1b[key]);}
return _19;
},getFlashHTML:function(){
var _1c="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");
}
_1c="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_1c+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1d=this.getParams();
for(var key in _1d){_1c+=[key]+"=\""+_1d[key]+"\" ";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_1c+="flashvars=\""+_1f+"\"";}
_1c+="/>";
}else{
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_1c="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_1c+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _20=this.getParams();
for(var key in _20){_1c+="<param name=\""+key+"\" value=\""+_20[key]+"\" />";}
var _22=this.getVariablePairs().join("&");
if(_22.length>0){_1c+="<param name=\"flashvars\" value=\""+_22+"\" />";
}_1c+="</object>";}
return _1c;
},write:function(_23){
if(this.useExpressInstall){
var _24=new com.deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_24)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}
}else{this.setAttribute("doExpressInstall",false);}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _23=="string")?document.getElementById(_23):_23;
n.innerHTML=this.getFlashHTML();
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}}};
com.deconcept.FlashObjectUtil.getPlayerVersion=function(_26,_27){
var _28=new com.deconcept.PlayerVersion(0,0,0);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_28=new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{
try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=3;axo!=null;i++){
axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
_28=new com.deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_26&&_28.major>_26.major){return _28;}
if(!_26||((_26.minor!=0||_26.rev!=0)&&_28.major==_26.major)||_28.major!=6||_27){
try{
_28=new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
}catch(e){}}}
return _28;
};
com.deconcept.PlayerVersion=function(_2c){
this.major=parseInt(_2c[0])||0;
this.minor=parseInt(_2c[1])||0;
this.rev=parseInt(_2c[2])||0;
};
com.deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}
return true;
};
com.deconcept.util={getRequestParameter:function(_2e){
var q=document.location.search||document.location.hash;
if(q){var _30=q.indexOf(_2e+"=");
var _31=(q.indexOf("&",_30)>-1)?q.indexOf("&",_30):q.length;
if(q.length>1&&_30>-1){
return q.substring(q.indexOf("=",_30)+1,_31);}}return "";
},removeChildren:function(n){
while(n.hasChildNodes()){
n.removeChild(n.firstChild);}}};
if(Array.prototype.push==null){
Array.prototype.push=function(_33){
this[this.length]=_33;
return this.length;};}
var getQueryParamValue=com.deconcept.util.getRequestParameter;
var FlashObject=com.deconcept.FlashObject;


function updateVoucherDelivery(cmb, pid) {
	if ( cmb.value == 'post' ) {
		$('#postaddress_' + pid).show("slow");
	} else {
		$('#postaddress_' + pid).hide("slow");
	}
}



(function($){
		  
	$.fn.imageTick = function(options) {
		
		var defaults = {	
			tick_image_path: "images/radio.gif",
			no_tick_image_path: "no_images/radio.gif",
			image_tick_class: "ticks_" + Math.floor(Math.random()),
			hide_radios_checkboxes: false
		};
	  	
		var opt = $.extend(defaults, options);
		
		this.each(function(){
			
			var obj = $(this);
			var type = obj.attr('type'); // radio or checkbox
			
			// hide them and store an image background
			var id = obj.attr('id');
			var v = obj.attr('value');
			
			var imgHTML = '<img style=" padding: 3px; border: 3px solid #ffffff" src="' + obj.attr('src') + '" alt="" class="' + opt.image_tick_class + '" id="tick_img_' + id + '" />';
			
			obj.before(imgHTML);
			if(!opt.hide_radios_checkboxes){
				obj.css('display','none');
			}
			
			// if something has a checked state when the page was loaded
			//if(obj.attr('checked')){
			//	$("#tick_img_" + id).attr('src', opt.tick_image_path);
			//}
			//;
		
				
			// if we click on the image
			$("#tick_img_"+id).click(function(){
				//$("." + opt.image_tick_class).attr('src', opt.no_tick_image_path);
				//$("." + opt.image_tick_class).css('border', '1px solid #cccccc');
				$("." + opt.image_tick_class).css('border', '3px solid #ffffff');
				$("." + opt.image_tick_class).css('padding', '3px');
				$("#tick_img_" + id).css('border', '3px solid #cccccc');
				$("#tick_img_" + id).css('padding', '3px');
				
				$("#" + id).trigger("click");
				//$(this).attr('src', opt.tick_image_path);
			});
			
			// if we click on the label
			$("label[for='" + id + "']").click(function(){
				//$("." + opt.image_tick_class).attr('src', opt.no_tick_image_path);
				$("." + opt.image_tick_class).css('border', '3px solid #ffffff');
				$("." + opt.image_tick_class).css('padding', '3px');
				
				$("#tick_img_" + id).css('border', '3px solid #cccccc');
				$("#tick_img_" + id).css('padding', '3px');
				
				$("#" + id).trigger("click");
				//$("#tick_img_" + id).attr('src', opt.tick_image_path);									
			});
			
			
		
			
		});
	}
	
})(jQuery);





