// Script Created by Christian Barfoot for the MotorDriven Website.  Tweaked Version 1.1 25th/Jan/2006
//New amendments includes capacity for more information in RequestedField1&2;
//Also more efficient array creation.


//Variables for StrSplit() Functions.

var new_url = window.location;
var StrCon = new String(new_url);


//Function Displays Table of Motor Quotes Requested.

function DisplayRes(){
         //Create Textareas for Car Make and Model to be updated
         document.write("<div STYLE='display: block;'><INPUT TYPE=text ID='text1' name='RequestedField1' cols='30' rows='1' wrap='soft'></text></div>");
         document.write("<INPUT TYPE=text ID='text2' name='RequestedField2' cols='30' rows='1'></text></div>");
         document.form.RequestedField1.value="";
         }

//Function which breaks down the URL content into useable Strings.

function  StrSplit(){
                if (StrCon.indexOf("+")==-1)  {
                        document.form.RequestedField1.value+="!-No Make of Car selected for Quotes-!";
                        document.form.RequestedField2.value+="!-No Car Models were selected for Quotes-!";
                }
                else
      		{
                          spl = StrCon.split("+");
//If command to allow additional information to be used in RequestedField1.  Informatin must correspond correctly to statement below:-
//<A HREF="#" onClick="this.href='[FormPageName]' + '?+[data1][space][data2][space][data3] etc..+[RequestedField2]'">[LabelName]</A>
                                              //      |-----------------Requestedfield1---------|



                                for (i=1;i<spl.length;i++){ //i=0 would mean spl[1] which is garbage text
                                        if (spl[i].indexOf("%20")==-1){
                                           document.form.elements[i-1].value=spl[i]+" ";   //elements[i-1]
                                        }
                                        else
                                        {
                                           fieldtext1=" ";
                                           parts=spl[i].split("%20");
                                           fieldtext1 = parts.join(" ");
                                           document.form.elements[i-1].value=fieldtext1+" ";    //elements[i-1]
                                        }
                                        }
                }
        }
