﻿// <![CDATA[

var dcs = new dcs();


function dcs() {
    this.third_party = 'DCS';
    this.dsp_host = 'christies.com';
    this.dsp_script = '/dsp/client/actions/index.aspx';
    this.truque_client = 'CHRISTIES';
    this.dsp_path = '';

    this.selectedTabIndex = 1;

    this.eye_context = '';
    this.eye_context_params = '';

    //Set this to true to block the popup from disappearing onmouseout
	this.block_hide_truque = false;
	

    this.loadTruqueContent = function(truqueID, ref_type, ref_id, tab_index) 
    {
        if ($('truqueDiv' + truqueID).style.display == 'block') 
        {
        	dcs.block_hide_truque = false;
            var cookie = dcs.GetCookie('DCSTRUQUEGUID');

            new Ajax.Updater('truqueDiv' + truqueID, dcs.dsp_path + dcs.dsp_script,
		 		{
		 		    parameters: 'script=index.php' +
		 						'&dsp_host=' + dcs.dsp_host +
		 						'&tabIndex=' + tab_index +
		 						'&truque_id=' + truqueID +
		 						'&third_party=' + dcs.third_party +
		 						'&truque_client=' + dcs.truque_client +
		 						'&ref_type=' + ref_type +
		 						'&ref_id=' + ref_id +
		 						'&eye_context=' + dcs.eye_context +
								'&dcs_guid=' + cookie +
		 						dcs.eye_context_params,
		 		    onComplete: function(r) { dcs.truqueContentLoaded(truqueID, ref_type, ref_id); }
		 		});
        }
    }


    this.truqueContentLoaded = function(truqueID, ref_type, ref_id) 
    {
    }


    this.Login = function(truqueID, ref_type, ref_id) 
    {
        new Ajax.Updater('truqueDiv' + truqueID, dcs.dsp_path + dcs.dsp_script,
			{
			    parameters: 'script=login.php' +
							'&dsp_host=' + dcs.dsp_host +
							'&login=' + encodeURIComponent(wdg('dcs_login_' + truqueID).value) +
							'&password=' + encodeURIComponent(wdg('dcs_password_' + truqueID).value) +
							'&truque_id=' + truqueID +
							'&ref_type=' + ref_type +
							'&ref_id=' + ref_id +
							'&third_party=' + dcs.third_party +
							'&truque_client=' + dcs.truque_client,
			    onComplete: function(r) {
			        if ($('dcs_guid'))
			        {
			        	dcs.SetCookie('DCSTRUQUEGUID', $('dcs_guid').value, 180, '/', '.'+dcs.dsp_host, 0);
			        }
			    }
			});
    }

    
    this.Logout = function(truqueID, ref_type, ref_id) {
        new Ajax.Updater('truqueDiv' + this.currentTruqueID, dcs.dsp_path + dcs.dsp_script,
			{
			    parameters: 'script=logout.php' +
							'&dsp_host=' + dcs.dsp_host,
			    onComplete: function() {
			        dcs.SetCookie('DCSTRUQUEGUID', '', 180, '/', '.' + dcs.dsp_host, 0);
			        $('dcs_guid').value = '';
			        dcs.switchTab(1, '', truqueID, ref_type, ref_id);
			    }
			});
    }


    this.SetCookie = function(name, value, expires, path, domain, secure) {
        // set time, it's in milliseconds
        var today = new Date();
        today.setTime(today.getTime());

        /*
        if the expires variable is set, make the correct 
        expires time, the current script below will set 
        it for x number of days, to make it for hours, 
        delete * 24, for minutes, delete * 60 * 24
        */
        if (expires) {
            expires = expires * 1000 * 60 * 60 * 24;
        }
        var expires_date = new Date(today.getTime() + (expires));

        document.cookie = name + "=" + escape(value) +
		((expires) ? ";expires=" + expires_date.toGMTString() : "") +
		((path) ? ";path=" + path : "") +
		((domain) ? ";domain=" + domain : "") +
		((secure) ? ";secure" : "");
    }


    this.GetCookie = function(check_name) {
        // first we'll split this cookie up into name/value pairs
        // note: document.cookie only returns name=value, not the other components
        var a_all_cookies = document.cookie.split(';');
        var a_temp_cookie = '';
        var cookie_name = '';
        var cookie_value = '';
        var b_cookie_found = false; // set boolean t/f default f

        for (i = 0; i < a_all_cookies.length; i++) {
            // now we'll split apart each name=value pair
            a_temp_cookie = a_all_cookies[i].split('=');


            // and trim left/right whitespace while we're at it
            cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

            // if the extracted name matches passed check_name
            if (cookie_name == check_name) {
                b_cookie_found = true;
                // we need to handle case where cookie has no value but exists (no = sign, that is):
                if (a_temp_cookie.length > 1) {
                    cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
                }
                // note that in cases where cookie is initialized but no value, null is returned
                return cookie_value;
                break;
            }
            a_temp_cookie = null;
            cookie_name = '';
        }
        if (!b_cookie_found) {
            return null;
        }
    }

    
    
    
    /** 
    *
    *		===== Display functionality =====
    *
    */

    //Timer for hiding the truque div
    this.truqueTimer = null;

    //currently active truque div
    this.currentTruqueID = null;


    this.scheduleShowTruque = function(truqueID, ref_type, ref_id, eye_context, eye_context_param, tab_index) {
        if (wdg('truqueDiv' + truqueID).style.display == 'block') {
            this.cancelHideTruque();
            return;
        }

        this.truqueTimer = setTimeout("dcs.showTruque('" + truqueID + "', '" + ref_type + "', '" + ref_id + "', '" + tab_index + "')", 500);
        this.eye_context = eye_context;
        this.eye_context_params = eye_context_param;
    }

    /**
    * Displays the functionality div with a loading message and triggers the loading of the actual content
    *
    */
    this.showTruque = function(truqueID, ref_type, ref_id, tab_index) {
        $('truqueDiv' + truqueID).style.display = 'block';

        //make http request to load the content
        this.loadTruqueContent(truqueID, ref_type, ref_id, tab_index);
    }


    /**
    * Schedules the hiding of the truque div if the mouse leaves it
    *
    */
    this.scheduleHideTruque = function(truqueID) 
    {
    	if (dcs.block_hide_truque != true)
		{
			//if onmouseout on a yet invisible item, cancel display timer
			if ($('truqueDiv'+truqueID).style.display == 'none')
			{
				window.clearTimeout(this.truqueTimer);
				return;
			}
			this.truqueTimer = setTimeout("dcs.hideTruque('"+truqueID+"')", 3000);
		}
    }


    /**
    * Hides the truque div 
    *
    */
    this.hideTruque = function(truqueID) {
        $('truqueDiv' + truqueID).style.display = 'none';
    }



    this.cancelHideTruque = function() {
        window.clearTimeout(this.truqueTimer);
    }


    this.switchTab = function(tabIndex, tabAction, truqueID, ref_type, ref_id, accountProjectID, accountPackageID, designLibrarySectionID, previousTabAction) {
    	
    	var cookie = dcs.GetCookie('DCSTRUQUEGUID');
    	
        new Ajax.Updater('truqueDiv' + truqueID, dcs.dsp_path + dcs.dsp_script,
			{
			    parameters: 'script=index.php' +
							'&dsp_host=' + dcs.dsp_host +
							'&dcs_guid=' + cookie +
							'&tabIndex=' + tabIndex +
							'&tabAction=' + tabAction +
							'&truque_id=' + truqueID +
							'&ref_type=' + ref_type +
							'&ref_id=' + ref_id +
							'&third_party=' + dcs.third_party +
							'&truque_client=' + dcs.truque_client +
		 					'&eye_context=' + dcs.eye_context +
		 					dcs.eye_context_params +
							'&accountProjectID=' + accountProjectID +
							'&accountPackageID=' + accountPackageID +
							'&designLibrarySectionID=' + designLibrarySectionID +
							'&previousTabAction=' + previousTabAction
			});

        this.selectedTabIndex = tabIndex;
    }

    this.getTabIndexAction = function(tabIndex) {
        if (tabIndex == 1)
            return 'add';
        else if (tabIndex == 2)
            return 'email';
        else if (tabIndex == 3)
            return 'print';
    }

    this.goToAccount = function(guid) {
        window.open("http://dsp.us.com/account_admin/?guid=" + guid, '_blank', 'status=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,titlebar=yes,scrollbars=yes,resizable=yes');
    }


    this.goToWeb = function(url) {
        window.open(url, '_blank', 'status=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,titlebar=yes,scrollbars=yes,resizable=yes');
    }


    this.collapse = function(img_id, div_id, new_div_id) {
        if (wdg(img_id).src.indexOf("/artwork/arrow_ASC.gif") != -1) {
            wdg(img_id).src = "http://images1.designcentersearch.com/artwork/arrow_DESC.gif";
            wdg(div_id).style.display = "block";
        }
        else {
            wdg(img_id).src = "http://images1.designcentersearch.com/artwork/arrow_ASC.gif";
            wdg(div_id).style.display = "none";
            if (wdg(new_div_id))
                wdg(new_div_id).style.display = "none";
        }

    }

    this.collapseWithNew = function(img_id, div_id, new_div_id, new_img_id) {
        if (wdg(img_id).src.indexOf("http://images1.designcentersearch.com/artwork/arrow_ASC.gif") != -1) {
            wdg(img_id).src = "http://images1.designcentersearch.com/artwork/arrow_DESC.gif";
            wdg(div_id).style.display = "block";
            wdg(new_div_id).style.display = "block";
        }
        else {
            wdg(new_div_id).style.display = "block";
        }
    }
    
    
    this.toggleDisplayDiv = function(div_name)
	{
		if ($(div_name).style.display == 'none')
			$(div_name).style.display = 'block';
		else
			$(div_name).style.display = 'none';
	}
    
    
    




    /**
    *	Add or remove an item to/from a design library section
    *
    */
    this.toggleDesignLibraryItemAccess = function(truqueID, ref_type, ref_id, dcs_ref_id, designLibrarySectionID, mainDesignLibrarySectionID) {
        $('dcs_designLibrarySectionSaved' + designLibrarySectionID + '_' + truqueID).style.display = 'none';
        $('dcs_designLibrarySectionIndicator' + designLibrarySectionID + '_' + truqueID).style.display = 'block';

        if ($('check_design_library_tab_' + designLibrarySectionID + '_' + truqueID).checked) {
            if (designLibrarySectionID != mainDesignLibrarySectionID)
                $('check_design_library_tab_' + mainDesignLibrarySectionID + '_' + truqueID).checked = true;

            new Ajax.Request(dcs.dsp_path + dcs.dsp_script,
				{
				    parameters: 'script=actions/design_library_ref_add.php' +
								'&dsp_host=' + dcs.dsp_host +
								'&action=ADD' +
								'&designLibrarySectionID=' + designLibrarySectionID +
								'&ref_type=' + ref_type +
								'&ref_id=' + dcs_ref_id +
								'&third_party=' + dcs.third_party +
								'&truque_client=' + dcs.truque_client,
				    onComplete: function(r) {

				        $('dcs_designLibrarySectionIndicator' + designLibrarySectionID + '_' + truqueID).style.display = 'none';
				        $('dcs_designLibrarySectionSaved' + designLibrarySectionID + '_' + truqueID).style.display = 'block';
				    }
				});
        }
        else {
            new Ajax.Request(dcs.dsp_path + dcs.dsp_script,
				{
				    parameters: 'script=actions/design_library_ref_add.php' +
								'&dsp_host=' + dcs.dsp_host +
								'&action=DELETE' +
								'&designLibrarySectionID=' + designLibrarySectionID +
								'&ref_type=' + ref_type +
								'&ref_id=' + dcs_ref_id +
								'&third_party=' + dcs.third_party,
				    onComplete: function(r) {
				        //uncheck the main section, only if this was the last section the item belonged to 
				        if (r.responseText == 'LAST') {
				            $('check_design_library_tab_' + mainDesignLibrarySectionID + '_' + truqueID).checked = false;
				        }

				        $('dcs_designLibrarySectionIndicator' + designLibrarySectionID + '_' + truqueID).style.display = 'none';
				        $('dcs_designLibrarySectionSaved' + designLibrarySectionID + '_' + truqueID).style.display = 'block';
				    }
				});
        }
    }



    /**
    *	Add or remove an item to/from the main design library section
    *
    */
    this.toggleDesignLibraryItemAccessAndClose = function(truqueID, ref_type, ref_id, dcs_ref_id, designLibrarySectionID, mainDesignLibrarySectionID) {
        $('dcs_designLibrarySectionSaved' + designLibrarySectionID + '_' + truqueID).style.display = 'none';
        $('dcs_designLibrarySectionIndicator' + designLibrarySectionID + '_' + truqueID).style.display = 'block';

        if ($('quick_check_design_library_tab_' + designLibrarySectionID + '_' + truqueID).checked) {
            if (designLibrarySectionID != mainDesignLibrarySectionID)
                $('check_design_library_tab_' + mainDesignLibrarySectionID + '_' + truqueID).checked = true;

            new Ajax.Request(dcs.dsp_path + dcs.dsp_script,
				{
				    parameters: 'script=actions/design_library_ref_add.php' +
								'&dsp_host=' + dcs.dsp_host +
								'&action=ADD' +
								'&designLibrarySectionID=' + designLibrarySectionID +
								'&ref_type=' + ref_type +
								'&ref_id=' + dcs_ref_id +
								'&third_party=' + dcs.third_party +
								'&truque_client=' + dcs.truque_client,
				    onComplete: function(r) {

				        $('dcs_designLibrarySectionIndicator' + designLibrarySectionID + '_' + truqueID).style.display = 'none';
				        $('dcs_designLibrarySectionSaved' + designLibrarySectionID + '_' + truqueID).style.display = 'block';
				        dcs.hideTruque(truqueID);
				    }
				});
        }
        else {
            new Ajax.Request(dcs.dsp_path + dcs.dsp_script,
				{
				    parameters: 'script=actions/design_library_ref_add.php' +
								'&dsp_host=' + dcs.dsp_host +
								'&action=DELETE' +
								'&designLibrarySectionID=' + designLibrarySectionID +
								'&ref_type=' + ref_type +
								'&ref_id=' + dcs_ref_id +
								'&third_party=' + dcs.third_party,
				    onComplete: function(r) {
				        //uncheck the main section, only if this was the last section the item belonged to 
				        if (r.responseText == 'LAST') {
				            $('check_design_library_tab_' + mainDesignLibrarySectionID + '_' + truqueID).checked = false;
				        }

				        $('dcs_designLibrarySectionIndicator' + designLibrarySectionID + '_' + truqueID).style.display = 'none';
				        $('dcs_designLibrarySectionSaved' + designLibrarySectionID + '_' + truqueID).style.display = 'block';
				        dcs.hideTruque(truqueID);
				    }
				});
        }
    }



    /*
    *	Add/remove an item to/from a client project room
    *
    */
    this.toggleClientProjectItemAccess = function(truqueID, ref_type, ref_id, dcs_ref_id, accountPackageID, mainAccountPackageID) {
        $('dcs_clientPackageSaved' + accountPackageID + '_' + truqueID).style.display = 'none';
        $('dcs_clientPackageIndicator' + accountPackageID + '_' + truqueID).style.display = 'block';

        if (accountPackageID != mainAccountPackageID) {
            if ($('check_project_room_' + accountPackageID + '_' + truqueID).checked) {
                $('check_project_room_' + mainAccountPackageID + '_' + truqueID).checked = $('check_project_room_' + accountPackageID + '_' + truqueID).checked;
            }
        }

        if ($('check_project_room_' + accountPackageID + '_' + truqueID).checked) {
            new Ajax.Request(dcs.dsp_path + dcs.dsp_script,
				{
				    parameters: 'script=actions/account_package_ref_add.php' +
								'&dsp_host=' + dcs.dsp_host +
								'&action=ADD' +
								'&accountPackageID=' + accountPackageID +
								'&ref_type=' + ref_type +
								'&ref_id=' + dcs_ref_id +
								'&third_party=' + dcs.third_party +
								'&truque_client=' + dcs.truque_client,
				    onComplete: function(r) {
				        $('dcs_clientPackageIndicator' + accountPackageID + '_' + truqueID).style.display = 'none';
				        $('dcs_clientPackageSaved' + accountPackageID + '_' + truqueID).style.display = 'block';
				    }
				});
        }
        else {
            new Ajax.Request(dcs.dsp_path + dcs.dsp_script,
				{
				    parameters: 'script=actions/account_package_ref_add.php' +
								'&dsp_host=' + dcs.dsp_host +
								'&action=DELETE' +
								'&accountPackageID=' + accountPackageID +
								'&ref_type=' + ref_type +
								'&ref_id=' + dcs_ref_id +
								'&third_party=' + dcs.third_party,
				    onComplete: function(r) {
				        //uncheck the main section, only if this was the last section the item belonged to 
				        if (r.responseText == 'LAST') {
				            $('check_project_room_' + mainAccountPackageID + '_' + truqueID).checked = false;
				        }

				        $('dcs_clientPackageIndicator' + accountPackageID + '_' + truqueID).style.display = 'none';
				        $('dcs_clientPackageSaved' + accountPackageID + '_' + truqueID).style.display = 'block';
				    }
				});
        }
    }



    this.sendEmail = function(truqueID, ref_type, ref_id, dcs_ref_id) {

    	var cookie = dcs.GetCookie('DCSTRUQUEGUID');
    	 
        var recipient = $('dcs_recipient_' + truqueID).value;
        var destination = 'new_destination';

        if ($('dcs_saved_address_' + truqueID).checked) {
            recipient = $('dcs_email_history_' + truqueID).options[$('dcs_email_history_' + truqueID).selectedIndex].value;
            destination = 'saved_destination';
        }

        var subject = encodeURIComponent($('dcs_subject_' + truqueID).value);

        new Ajax.Request(dcs.dsp_path + dcs.dsp_script,
			{
			    parameters: 'script=actions/send_email.php' +
							'&dsp_host=' + dcs.dsp_host +
							'&dcs_guid=' + cookie+
							'&ref_type=' + ref_type +
							'&ref_id=' + dcs_ref_id +
							'&third_party=' + dcs.third_party +
							'&recipient=' + encodeURIComponent(recipient) +
							'&destination=' + encodeURIComponent(destination) +
							'&cc=' + $('dcs_cc_' + truqueID).value +
							'&subject=' + subject +
							'&message=' + encodeURIComponent($('dcs_message_' + truqueID).value) +
							'&add_cc=' + ($('dcs_add_cc_' + truqueID).checked ? $('dcs_add_cc_' + truqueID).value : '') +
							'&truque_client=' + dcs.truque_client,
			    onComplete: function(r) {
			        if (r.responseText == '') {
			        	wdg('emailFeedback_' + truqueID).innerHTML = "<b>Your email has been sent. Thank you.</b>";
			            wdg('emailFeedback_' + truqueID).style.color = '#108CDA';
			        }
			        else {
			            wdg('emailFeedback_' + truqueID).innerHTML = "There was an error while sending your e-mail.<br/>Please contact the system administrator.<br/>" + r.responseText;
			            wdg('emailFeedback_' + truqueID).style.color = 'red';
			        }
			    }
			});
    }



    
    
    this.addDesignLibrarySection = function(designLibraryID, truqueID, ref_type, ref_id, new_div_id)
	{
	 	new Ajax.Request(dcs.dsp_path + dcs.dsp_script, 
			{
				parameters:	'script=actions/design_library_section_save.php'+
							'&dsp_host='+dcs.dsp_host+
							'&action=SAVE'+
							'&designLibraryID='+designLibraryID+
							'&name='+encodeURIComponent(wdg('new_design_library_tab_name_'+truqueID).value)+
							'&truque_id='+truqueID+
							'&ref_type='+ref_type+
							'&ref_id='+ref_id+
							'&third_party='+dcs.third_party, 
				onComplete:function(r){
					var tr = $('table_library_tabs_'+truqueID).insertRow(0);
					var td = tr.insertCell(0);

					td.innerHTML = r.responseText;
					
					$(new_div_id).style.display = 'none';
					$('new_design_library_tab_name_'+truqueID).value = '';
				}
			});
	}
    
    
    
    this.register = function(truqueID, ref_type, ref_id, tabIndex)
	{
		if (wdg('registration_indicator_'+truqueID))
			wdg('registration_indicator_'+truqueID).style.display = 'block';
		
		if (wdg('request_trade_'+truqueID))
			dcs.registerTrade(truqueID, ref_type, ref_id, tabIndex);
		else
			dcs.registerConsumer(truqueID, ref_type, ref_id, tabIndex);
	}
	
	this.registerConsumer = function (truqueID, ref_type, ref_id, tabIndex)
	{
		dcs.truqueID = truqueID;
		dcs.ref_type = ref_type;
		dcs.ref_id = ref_id;
		
		new Ajax.Updater('truqueDiv'+truqueID, dcs.dsp_path + dcs.dsp_script, 
				{
					parameters:'script=index.php'+
								'&dsp_host='+dcs.dsp_host+
								'&tabIndex='+tabIndex+
								'&truque_id='+truqueID+
								'&third_party='+dcs.third_party+
								'&truque_client='+dcs.truque_client+
								'&register_do='+encodeURIComponent(wdg('register_do_'+truqueID).value)+
								'&first_name='+encodeURIComponent(wdg('first_name_'+truqueID).value)+
								'&last_name='+encodeURIComponent(wdg('last_name_'+truqueID).value)+
								'&email='+encodeURIComponent(wdg('email_'+truqueID).value)+
								'&password='+encodeURIComponent(wdg('password_'+truqueID).value)+
								'&confirm_password='+encodeURIComponent(wdg('confirm_password_'+truqueID).value)+
								'&referral='+encodeURIComponent(wdg('referral_'+truqueID).options[wdg('referral_'+truqueID).selectedIndex].value)+
								'&agree='+encodeURIComponent(wdg('agree_'+truqueID).checked ? "Y" : "N"),
					onComplete:function(r)
					{
						if (r.responseText.indexOf("Registration complete!") >= 0)
						{
							dcs.block_hide_truque = false;
							dcs.showTruque(dcs.truqueID, dcs.ref_type, dcs.ref_id, 1);
						}
					}
				});
	}
	
	
	this.registerTrade = function (truqueID, ref_type, ref_id, tabIndex)
	{
		dcs.truqueID = truqueID;
		dcs.ref_type = ref_type;
		dcs.ref_id = ref_id;
		
		new Ajax.Updater('truqueDiv'+truqueID, dcs.dsp_path + dcs.dsp_script, 
				{
					parameters:'script=index.php'+
								'&dsp_host='+dcs.dsp_host+
								'&tabIndex='+tabIndex+
								'&truque_id='+truqueID+
								'&third_party='+dcs.third_party+
								'&truque_client='+dcs.truque_client+
								'&register_do='+encodeURIComponent(wdg('register_do_'+truqueID).value)+
								'&first_name='+encodeURIComponent(wdg('first_name_'+truqueID).value)+
								'&last_name='+encodeURIComponent(wdg('last_name_'+truqueID).value)+
								'&email='+encodeURIComponent(wdg('email_'+truqueID).value)+
								'&password='+encodeURIComponent(wdg('password_'+truqueID).value)+
								'&confirm_password='+encodeURIComponent(wdg('confirm_password_'+truqueID).value)+
								'&referral='+encodeURIComponent(wdg('referral_'+truqueID).options[wdg('referral_'+truqueID).selectedIndex].value)+
								'&agree='+encodeURIComponent(wdg('agree_'+truqueID).checked ? "Y" : "N")+
								'&request_trade=Y'+
								'&tr_occupation='+encodeURIComponent(wdg('tr_occupation_'+truqueID).options[wdg('tr_occupation_'+truqueID).selectedIndex].value)+
								'&tr_company='+encodeURIComponent(wdg('tr_company_'+truqueID).value)+
								'&tr_address='+encodeURIComponent(wdg('tr_address_'+truqueID).value)+
								'&tr_city='+encodeURIComponent(wdg('tr_city_'+truqueID).value)+
								'&tr_zip='+encodeURIComponent(wdg('tr_zip_'+truqueID).value)+
								'&tr_state='+encodeURIComponent(wdg('tr_state_'+truqueID).options[wdg('tr_state_'+truqueID).selectedIndex].value)+
								'&tr_country='+encodeURIComponent(wdg('tr_country_'+truqueID).options[wdg('tr_country_'+truqueID).selectedIndex].value)+
								'&tr_phone='+encodeURIComponent(wdg('tr_phone_'+truqueID).value)+
								'&tr_fax='+encodeURIComponent(wdg('tr_fax_'+truqueID).value)+
								'&tr_web='+encodeURIComponent(wdg('tr_web_'+truqueID).value)+
								'&tr_email='+encodeURIComponent(wdg('tr_email_'+truqueID).value)+
								'&tr_resale_number='+encodeURIComponent(wdg('tr_resale_number_'+truqueID).value)+
								'&tr_resale_state='+encodeURIComponent(wdg('tr_resale_state_'+truqueID).value)+
								'&tr_ref_name='+encodeURIComponent(wdg('tr_ref_name_'+truqueID).value)+
								'&tr_ref_phone='+encodeURIComponent(wdg('tr_ref_phone_'+truqueID).value)+
								'&tr_ref_name1='+encodeURIComponent(wdg('tr_ref_name1_'+truqueID).value)+
								'&tr_ref_phone1='+encodeURIComponent(wdg('tr_ref_phone1_'+truqueID).value),
					onComplete:function(r)
					{
						if (r.responseText.indexOf("Registration complete!") >= 0)
						{
							dcs.block_hide_truque = false;
							dcs.showTruque(dcs.truqueID, dcs.ref_type, dcs.ref_id, 1);
						}
					}
				});
	}
   
}



function wdg(id) { return window.document.getElementById(id); };

// ]]>
