  var MYID=0;
var currentlang="";
 // Navigation variables

var Page;
var FirstPage;
var NextPage;
var Reset=0;
var GoFromQuestion="";
var GoToPage=new Array();
var GoToCondition=new Array();
var GoToCount=0;


//General style
var SSAlign="left";
var SSBorderWidth=1;
var SSWidth="50%";
var SSBgColor="ffffff"
var SSBgPic="";
var SSIBgType="";
var SSButton="";
var BckButton="1";
var AutoNext="1";

// Question Style
var SSQColor="ffffff";
var SSQUnderline=0;
var SSQItalic=0;
var SSQBold=0;
var SSQAlign="left";
var SSQTextSize=12;
var SSQFontName="arial";
var SSQShowName=0;
var SSQBgColor="FFFFFF";
var SSQBgPic="";
var SSQBgType="";
//Item Style
var SSIColor="ffffff";
var SSIItalic=0;
var SSIBold=0;
var SSIUnderline=0;
var SSIAlign="left";
var SSITextSize="+2";
var SSIFontName="arial";
var SSIBgColor="FFFFFF";
var SSIBgPic="";
var SSIBgType="";
//grid style
var SSGHeaderColor;
var SSGHeaderTextColor;
var SSGHeaderTransparent;
var SSGScaleColor;
var SSGScaleTextColor;
var SSGScaleTransparent;
var SSGAlternateRowColor;
var SSGAlternateRowTextColor;
var SSGAlternateRowTransparent;
var SSGAlternateColumnColor;
var SSGAlternateColumnTextColor;
var SSGAlternateColumnTransparent;



//Error Style
var SSEColor="fff000000";
var SSEItalic=0;
var SSEBold=0;
var SSEUnderline=0;
var SSEAlign="left";
var SSETextSize="+2";
var SSEFontName="arial";
var SSEErrorHeader="Form errors!";


// Col Style
SSCItalic=0;
SSCBold=0;
SSCTextSize=2;
SSCFontName="arial";
SSCUnderline=0;



//General


var SRotation=0;
var SRequired=new Array();
var SPic=new Array();
var SPicHeight=new Array();
var SPicWidth=new Array();
var SPicAlign=new Array();
var STypeByIndex=new Array();
var SNotes=new Array();
var SCList=new Array();

var SCount=0;
var SLangSelector=1;

//Components Core

var SItems=new Array();
var SCodes=new Array();
var SItemsCount=new Array();
var SText=new Array();
var SName=new Array();
var SRotation=new Array();
var SCodeLink=new Array();
var SCodeLinkShow=new Array();
var SAutoFill=new Array();
var SOrderPreset=new Array();
var SColOrderPreset=new Array();

//Conditional Gotos
var CondGoto=new Array();
var CondGotoCount=0;
var NEXT_LBL="";

// macros

var Macro=new Array();
var MacroCount=0;

// Attributes

var AttrOptions=new Array();

var FieldType;
if (String(FieldType=="undefined")) FieldType=0;

function FixSize()
	{
	//alert(window.screen.width);
	//alert(window.screen.height);
	/*if (window.screen.height<1000 && window.screen.width<1200)
		{
		FieldType=1;
		SSQTextSize=SSQTextSize+2;
		SSITextSize=SSITextSize+2;
		SSCTextSize=SSCTextSize+2;
		
		document.write("<style type='text/css'>");
		document.write(".bigButton {");
  		document.write("width: 50px; height: 50px;");
		document.write("}</style>");

		
		}*/
	}

function MakeQuitSubmit()
{
//alert("****");

for (i=0;i<=parent.PageStructureCount;i++)
SetValue('PAGE_STRUCTURE_'+String(i),parent.PageStructure[i][1]);

var DATA=GetDataString();
DATA=DATA+parent.GetHistory();

document.write("<html>");
document.write("<head></head>");
document.write("<body>");
document.write("<form method='post' action='../../INTERFACE/QUIT_INPUT.php' name='form1'>");
document.write("<input type='hidden' name='INFO' value=", parent.AnswerPool["INFO"],"/>");
document.write("<input type='hidden' name='DATA' value=", DATA,"/>");
document.write("</form>");
document.write("<script>document.form1.submit();</script>");
document.write("</body>");
document.write("</html>");
}

function SetPage(Page)
	{
	parent.Page=Page;
	//alert("P"+String(Page)+".htm");
	document.location.href="P"+String(Page)+".htm";
	}
function SetLang(lang)
	{
	currentlang=lang;
	if (String(parent.LangIndex[lang])=="undefined") parent.LangIndex[lang]=0;
	parent.LangIndex[lang]++;
	if (parent.LangIndex[lang]<2)
		{
		parent.LangCount++;
		parent.LangPool[parent.LangCount]=lang;
		}
	//alert(LangCount);
	}
function change_lang()
	{

	var agt=navigator.userAgent.toLowerCase();
	var is_mac=(agt.indexOf("mac")!=-1);
	var ie4 = (document.all && !document.getElementById);
	var Net6= (!document.all && document.getElementById);
	var obj
	if ((ie4 || is_mac) && !Net6)
	{
	 obj=document.all["select_lang"];
	}
	else
	{


        obj=document.getElementsByName("select_lang");

	obj=obj[0];
	}
	//alert(obj.value);
	//alert(parent.LangPool[obj.value]);
	//alert(parent.LangPool[intValue(obj[0].value)]+"  "+String(obj[0].value));
	parent.LANG=parent.LangPool[obj.value];
	//alert(parent.frames[2].name);
	parent.frames[2].location.reload();
	}

function PPipe(v)
	{

	if (v.indexOf("]")>0 && v.indexOf("[")==0)
		{
		v=v.replace(" ","");
		v=v.replace("]","");
		v=v.replace("[","");
		return parent.AnswerPool[v];
		}
	else
		return v;
	}

function SetBackButton(BB)
	{
	BckButton=BB;
	}
function SetAutoNext(AN)
	{
	AutoNext=AN;
	}
function IsAutoNext()
	{
	if (AutoNext=="1") return true;
	return false;
	}

function InitPageStructure(TotalPages)
	{
	parent.InitPageStructure(TotalPages);
	}

function OAddGroup(PGroup)
	{
	parent.OAddGroup(PGroup);
	}

function AddGroup(PGroup)
	{
	parent.AddGroup(PGroup);
	}

function RandomizeAllGroups()
	{
	parent.RandomizeAllGroups();
	}

function AddAttrOptions(index,AttrIndex,Bold,Italic,Underlined,Tb,Ex,RMin,RMax,RInc,REx,NoR)
	{

	if (String(AttrOptions[index])=="undefined")
		AttrOptions[index]=new Array();
	if (String(AttrOptions[index][AttrIndex])=="undefined")
		AttrOptions[index][AttrIndex]=new Array();

	AttrOptions[index][AttrIndex][0]=Bold;
	AttrOptions[index][AttrIndex][1]=Italic;
	AttrOptions[index][AttrIndex][2]=Underlined;
	AttrOptions[index][AttrIndex][3]=Tb;
	AttrOptions[index][AttrIndex][4]=Ex;
	AttrOptions[index][AttrIndex][5]=RMin;
	AttrOptions[index][AttrIndex][6]=RMax;
	AttrOptions[index][AttrIndex][7]=RInc;
	AttrOptions[index][AttrIndex][8]=REx;
	AttrOptions[index][AttrIndex][9]=NoR;
	//alert(index);
	}



function NoR(index,AttrIndex)
	{
	//alert(index);
	try{
	if (AttrOptions[index][AttrIndex][9]=="1")
		return true;
	else
		return false;
	}catch(error){}
	return false;
	}

function NoTB(index,AttrIndex)
	{
	try{
	if (AttrOptions[index][AttrIndex][3]=="1")
		return true;
	else
		return false;
	}catch(error){}
	return false;
	}

function Ex(index,AttrIndex)
	{
	try{
	if (AttrOptions[index][AttrIndex][4]!="")
		return AttrOptions[index][AttrIndex][4];
	else
		return ""
	}catch(error){}
	return "";
	}
function RMin(index,AttrIndex)
	{
	try{
	if (AttrOptions[index][AttrIndex][5]!="")
		return AttrOptions[index][AttrIndex][5];
	else
		return "";
	}catch(error){}
	return "";
	}

function RMax(index,AttrIndex)
	{
	try{
	if (AttrOptions[index][AttrIndex][6]!="")
		return AttrOptions[index][AttrIndex][6];
	else
		return "";
	}catch(error){}
	return "";
	}

function RInc(index,AttrIndex)
	{
	try{
	if (AttrOptions[index][AttrIndex][8]!="")
		return AttrOptions[index][AttrIndex][8];
	else
		return "";
	}catch(error){}
	return "";
	}

function REx(index,AttrIndex)
	{
	try{
	if (AttrOptions[index][AttrIndex][7]!="")
		return AttrOptions[index][AttrIndex][7];
	else
		return "";
	}catch(error){}
	return "";
	}

function FAttr(index,AttrIndex,Attr)
	{
	var otag="";
	var ctag="";
	try{
	if (AttrOptions[index][AttrIndex][0]=="1") {otag=otag+"<b>";ctag="</b>"+ctag;}
 	if (AttrOptions[index][AttrIndex][1]=="1") {otag=otag+"<i>";ctag="</i>"+ctag;}
	if (AttrOptions[index][AttrIndex][2]=="1") {otag=otag+"<u>";ctag="</u>"+ctag;}
	}catch(error){}

	return (otag+Attr+ctag);
	}

function AddPageProperties(Rnd,Nextlbl)
	{
	NEXT_LBL=Nextlbl;
	if (Rnd=="") Rnd="0";
	if (Rnd!="0") Rnd="2";

	//SRotation[0]=0;
	SRotation[0]=Rnd;
	}

function NewPage(n)
	{
 	//parent.AnswerPool["debug"]="1";
	AddContinueLaterButton();
	parent.RemoveFromSkipped(n);
	var CondGotoCount=0;
	var MacroCount=0;
	if (String(parent.Page)=="0")
		parent.Page=1;
	//history.forward();

	//CalcAllVars();
	Page=n;


	parent.AddToNHistory("P"+String(n)+".htm")
	if (Page>parent.Page) parent.Page=Page;
	

	if (String(parent.AnswerPool["PAGE"])=="undefined") parent.AddField("PAGE",1001);
	parent.AnswerPool["PAGE"]=parent.Page;
	if (parent==null) return;
	if (parent.CheckQuotas()==1)
		{

                MakeQuotaFull();
                var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome');
                if (is_chrome > 0) {
                location.href='../../INTERFACE/QUOTA_FULL_INPUT.php';
                return;

                }
         }

	if (n==1)
	{
	Time = new Date();
	parent.StartTime= (Time.getHours()*60*60) + (Time.getMinutes()*60) + Time.getSeconds();
	var nav=navigator.userAgent;
	parent.AddField("ENVIRONMENT",1000);
	parent.AnswerPool["ENVIRONMENT"]=nav;
	}
	if (String(parent.AnswerPool["UNIQUE_ID"])=="undefined")
		{
		for(i=0;i<6;i++)
			MYID=MYID+String(Math.random()*9);
		//alert(MYID);
		parent.AddField("UNIQUE_ID",1000);
		parent.AnswerPool["UNIQUE_ID"]=MYID;
	}

	

	// **************************************************************
	
	//SetValue('PAGE_STRUCTURE_'+String(i),parent.PageStructure[i][1]);
	
	var query = window.location.search.substring(1);
	//alert(query);
	//var query = parent.main.location.search.substring(1);
	var pairs = query.split("&");
	var value;
	for (var i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');

		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);

			parent.AddField(argname,1000);
			parent.AnswerPool[argname]=value;
                        parent.StringPool[argname]=value;
			if (argname=="ROBOT_MODE")
			parent.ROBOT_MODE=1;
			//if (argname=="CALLBACK")





		}
	}
parent.submit_page(n-2);
}


function SetLayoutStyle(bgcolor,align,border,width,button,bgpic,bgtype)
        {
        if (String(parent.AnswerPool["SSAlign"])!="undefined" && String(parent.AnswerPool["SSAlign"])!="" ) align=parent.AnswerPool["SSAlign"];
        if (String(parent.AnswerPool["SSBgPic"])!="undefined" && String(parent.AnswerPool["SSBgPic"])!="") bgpic=parent.AnswerPool["SSBgPic"];
        if (String(parent.AnswerPool["SSBgType"])!="undefined"  && String(parent.AnswerPool["SSBgType"])!="") bgtype=parent.AnswerPool["SSBgType"];
        if (String(parent.AnswerPool["SSWidth"])!="undefined" && String(parent.AnswerPool["SSWidth"])!="") width=parent.AnswerPool["SSWidth"];
        if (String(parent.AnswerPool["SSBgColor"])!="undefined" && String(parent.AnswerPool["SSBgColor"])!="") bgcolor=parent.AnswerPool["SSBgColor"];
        if (String(parent.AnswerPool["SSButton"])!="undefined" && String(parent.AnswerPool["SSButton"])!="") button=parent.AnswerPool["SSButton"];

        SSAlign=align;
        SSBgPic=bgpic;
        SSBgType=bgtype;
        SSBorderWidth=0;
        SSWidth=width;
        SSBgColor=bgcolor;
        SSButton=button;
        if (bgcolor!=-1)
        SetBG();
        }

function SetGridStyle(hc,htc,ht,sc,stc,st,arc,artc,art,acc,actc,act)
        {
        if (String(parent.AnswerPool["SSGHeaderColor"])!="undefined" && String(parent.AnswerPool["SSGHeaderColor"])!="" ) hc=parent.AnswerPool["SSGHeaderColor"];
        if (String(parent.AnswerPool["SSGHeaderTransparent"])!="undefined" && String(parent.AnswerPool["SSGHeaderTransparent"])!="") ht=parent.AnswerPool["SSGHeaderTransparent"];
        if (String(parent.AnswerPool["SSGScaleTextColor"])!="undefined"  && String(parent.AnswerPool["SSGScaleTextColor"])!="") stc=parent.AnswerPool["SSGScaleTextColor"];
        if (String(parent.AnswerPool["SSGScaleColor"])!="undefined" && String(parent.AnswerPool["SSGScaleColor"])!="") sc=parent.AnswerPool["SSGScaleColor"];
        if (String(parent.AnswerPool["SSGScaleTransparent"])!="undefined" && String(parent.AnswerPool["SSGScaleTransparent"])!="") st=parent.AnswerPool["SSGScaleTransparent"];
        if (String(parent.AnswerPool["SSGAlternateRowColor"])!="undefined" && String(parent.AnswerPool["SSGAlternateRowColor"])!="") arc=parent.AnswerPool["SSGAlternateRowColor"];
        if (String(parent.AnswerPool["SSGAlternateRowTransparent"])!="undefined" && String(parent.AnswerPool["SSGAlternateRowTransparent"])!="") art=parent.AnswerPool["SSGAlternateRowTransparent"];
        if (String(parent.AnswerPool["SSGAlternateRowTextColor"])!="undefined" && String(parent.AnswerPool["SSGAlternateRowTextColor"])!="") artc=parent.AnswerPool["SSGAlternateRowTextColor"];
        if (String(parent.AnswerPool["SSGAlternateColumnTransparent"])!="undefined" && String(parent.AnswerPool["SSGAlternateColumnTransparent"])!="") act=parent.AnswerPool["SSGAlternateColumnTransparent"];
        if (String(parent.AnswerPool["SSGHeaderTextColor"])!="undefined" && String(parent.AnswerPool["SSGHeaderTextColor"])!="") htc=parent.AnswerPool["SSGHeaderTextColor"];


        SSGHeaderColor=hc;
        SSGHeaderTextColor=htc;
        SSGHeaderTransparent=ht;
        SSGScaleColor=sc;
        SSGScaleTextColor=stc;
        SSGScaleTransparent=st;
        SSGAlternateRowColor=arc;
        SSGAlternateRowTextColor=artc;
        SSGAlternateRowTransparent=art;
        SSGAlternateColumnColor=acc;
        SSGAlternateColumnTextColor=actc;
        SSGAlternateColumnTransparent=act;
        }

function SetPageProperties(rotation)
        {
        //SRotation[0]=rotation;
        }


function SetQuestionStyle(bgcolor,color,italic,bold,underline,align,size,font,sqn,bgpic,bgtype)
        {
        if (String(parent.AnswerPool["SSQColor"])!="undefined" && String(parent.AnswerPool["SSQColor"])!="" ) color=parent.AnswerPool["SSQColor"];
        if (String(parent.AnswerPool["SSQBgPic"])!="undefined" && String(parent.AnswerPool["SSQBgPic"])!="") bgpic=parent.AnswerPool["SSQBgPic"];
        if (String(parent.AnswerPool["SSQBgType"])!="undefined"  && String(parent.AnswerPool["SSQBgType"])!="") bgtype=parent.AnswerPool["SSQBgType"];
        if (String(parent.AnswerPool["SSQItalic"])!="undefined" && String(parent.AnswerPool["SSQItalic"])!="") italic=parent.AnswerPool["SSQItalic"];
        if (String(parent.AnswerPool["SSQBold"])!="undefined" && String(parent.AnswerPool["SSQBold"])!="") bold=parent.AnswerPool["SSQBold"];
        if (String(parent.AnswerPool["SSQAlign"])!="undefined" && String(parent.AnswerPool["SSQAlign"])!="") align=parent.AnswerPool["SSQAlign"];
        if (String(parent.AnswerPool["SSQTextSize"])!="undefined" && String(parent.AnswerPool["SSQTextSize"])!="") size=parent.AnswerPool["SSQTextSize"];
        if (String(parent.AnswerPool["SSQFontName"])!="undefined" && String(parent.AnswerPool["SSQFontName"])!="") font=parent.AnswerPool["SSQFontName"];
        if (String(parent.AnswerPool["SSQBgColor"])!="undefined" && String(parent.AnswerPool["SSQBgColor"])!="") bgcolor=parent.AnswerPool["SSQBgColor"];
        if (String(parent.AnswerPool["SSQUnderline"])!="undefined" && String(parent.AnswerPool["SSQUnderline"])!="") underline=parent.AnswerPool["SSQUnderline"];
        if (String(parent.AnswerPool["SSQShowName"])!="undefined" && String(parent.AnswerPool["SSQShowName"])!="") sqn=parent.AnswerPool["SSQShowName"];



        SSQColor=color;
        SSQBgPic=bgpic;
        SSQBgType=bgtype;
        SSQItalic=italic
        SSQBold=bold;
        SSQAlign=align;
        SSQTextSize=size;
        SSQFontName=font;
        SSQShowName=sqn;
        SSQBgColor=bgcolor;
        SSQUnderline=underline;
        }
function SetItemStyle(bgcolor,color,italic,bold,underline,align,size,font,bgpic,bgtype)
        {
        if (String(parent.AnswerPool["SSIColor"])!="undefined" && String(parent.AnswerPool["SSIColor"])!="" ) color=parent.AnswerPool["SSIColor"];
        if (String(parent.AnswerPool["SSIBgPic"])!="undefined" && String(parent.AnswerPool["SSIBgPic"])!="") bgpic=parent.AnswerPool["SSIBgPic"];
        if (String(parent.AnswerPool["SSIBgType"])!="undefined"  && String(parent.AnswerPool["SSIBgType"])!="") bgtype=parent.AnswerPool["SSIBgType"];
        if (String(parent.AnswerPool["SSIItalic"])!="undefined" && String(parent.AnswerPool["SSIItalic"])!="") italic=parent.AnswerPool["SSIItalic"];
        if (String(parent.AnswerPool["SSIBold"])!="undefined" && String(parent.AnswerPool["SSIBold"])!="") bold=parent.AnswerPool["SSIBold"];
        if (String(parent.AnswerPool["SSIAlign"])!="undefined" && String(parent.AnswerPool["SSIAlign"])!="") align=parent.AnswerPool["SSIAlign"];
        if (String(parent.AnswerPool["SSITextSize"])!="undefined" && String(parent.AnswerPool["SSITextSize"])!="") size=parent.AnswerPool["SSITextSize"];
        if (String(parent.AnswerPool["SSIFontName"])!="undefined" && String(parent.AnswerPool["SSIFontName"])!="") font=parent.AnswerPool["SSIFontName"];
        if (String(parent.AnswerPool["SSIBgColor"])!="undefined" && String(parent.AnswerPool["SSIBgColor"])!="") bgcolor=parent.AnswerPool["SSIBgColor"];
        if (String(parent.AnswerPool["SSIUnderline"])!="undefined" && String(parent.AnswerPool["SSIUnderline"])!="") underline=parent.AnswerPool["SSIUnderline"];


        SSIColor=color;
        SSIBgPic=bgpic;
        SSIBgType=bgtype;
        SSIItalic=italic;
        SSIBold=bold;
        SSIAlign=align;
        SSITextSize=size;
        SSIFontName=font;
        SSIBgColor=bgcolor;
        SSIUnderline=underline;
        }

function SetColStyle(italic,bold,underline,size,font)
        {
        if (String(parent.AnswerPool["SSCItalic"])!="undefined" && String(parent.AnswerPool["SSCItalic"])!="") italic=parent.AnswerPool["SSCItalic"];
        if (String(parent.AnswerPool["SSCBold"])!="undefined" && String(parent.AnswerPool["SSCBold"])!="") bold=parent.AnswerPool["SSCBold"];
        if (String(parent.AnswerPool["SSCTextSize"])!="undefined" && String(parent.AnswerPool["SSCTextSize"])!="") size=parent.AnswerPool["SSCTextSize"];
        if (String(parent.AnswerPool["SSCFontName"])!="undefined" && String(parent.AnswerPool["SSCFontName"])!="") font=parent.AnswerPool["SSCFontName"];
        if (String(parent.AnswerPool["SSCUnderline"])!="undefined" && String(parent.AnswerPool["SSCUnderline"])!="") underline=parent.AnswerPool["SSCUnderline"];


        SSCItalic=italic;
        SSCBold=bold;
        SSCTextSize=size;
        SSCFontName=font;
        SSCUnderline=underline;
        }

function SetErrorStyle(italic,bold,underline,size,font,color,error)
        {

        if (String(parent.AnswerPool["SSEColor"])!="undefined" && String(parent.AnswerPool["SSEColor"])!="" ) color=parent.AnswerPool["SSEColor"];
        if (String(parent.AnswerPool["SSEItalic"])!="undefined" && String(parent.AnswerPool["SSEItalic"])!="") italic=parent.AnswerPool["SSEItalic"];
        if (String(parent.AnswerPool["SSEBold"])!="undefined" && String(parent.AnswerPool["SSEBold"])!="") bold=parent.AnswerPool["SSEBold"];
        if (String(parent.AnswerPool["SSETextSize"])!="undefined" && String(parent.AnswerPool["SSETextSize"])!="") size=parent.AnswerPool["SSETextSize"];
        if (String(parent.AnswerPool["SSEFontName"])!="undefined" && String(parent.AnswerPool["SSEFontName"])!="") font=parent.AnswerPool["SSEFontName"];
        if (String(parent.AnswerPool["SSEUnderline"])!="undefined" && String(parent.AnswerPool["SSEUnderline"])!="") underline=parent.AnswerPool["SSEUnderline"];
        if (String(parent.AnswerPool["SSEErrorHeader"])!="undefined" && String(parent.AnswerPool["SSEErrorHeader"])!="") error=parent.AnswerPool["SSEErrorHeader"];

        SSEColor=color;
        SSEItalic=italic;
        SSEBold=bold;
        SSEUnderline=underline;;
        SSETextSize=size;
        SSEFontName=font;
        SSEErrorHeader=error;
        }

function SIsIn(index,count,number)
	{
	var i;
	for(i=0;i<count;i++)
		{

		if (parent.SPos[index][i]==number)
			return 1;
		}
	return 0;
	}




function ReDimSPos(index,count,index2)
	{
	if (parent.SPosOK[index]=="OK")
		{

		if (SItemsCount[index2]>parent.SPos[index].length)
			{
			parent.SPos[index]=new Array();
			parent.SPosOK[index]="OK";
			return true;
			}
		}
	return false;
	}

function SCreateRotationalList(index,index2,count)
        {

        if (count<2) return;
        var i;
        var n=0;
        var m=0;
        var j=0;
        var z=0;
        var attr_start_index=0;
        if (String(parent.AnswerPool["SERVER_ID"])=="undefined")
                {
                parent.AnswerPool["SERVER_ID"]=Math.round(Math.random()*(1000));

                }
        n=parent.AnswerPool["SERVER_ID"];
       // alert(n);

        //alert(index);

        for (i=0;i<count;i++)
                {
                parent.SPos[index][i]=0;
                var C=SCodes[index2][i];
                if (C=="999" || C=="888" || C=="555" || C=="666" || NoR(index2,i+1)==true )
                        {

                        //alert(String(parent.SPos[SName[index2]+"b"][0]));
                        try{
                        if (String(parent.SPos[SName[index2]+"b"][0])=="undefined")
                        {
                        z=0;
                        }
                        else
                        {
                        z=1;
                        }
                        }
                        catch(e){z=0;}


                        if ((index!=SName[index2]+"b" && z==0) ||(index==SName[index2]+"b" && z==1))
                                {
                                parent.SPos[index][i]=i+1;
                                //alert(index+" = " + SName[index2]);
                                m=m+1;
                                }

                        }
                }

        z=0;
        //alert(parent.SPos[index][attr_start_index]);
        while((parent.SPos[index][attr_start_index]!=0 && z<100) || z==0)
                {
                z++;
                attr_start_index=n%(count-m);
                }
        //alert(attr_start_index)
        j=attr_start_index;
        if (j==0) j=count-m;
        attr_start_index=j;
        for (i=0;i<count;i++)
                {

                if (parent.SPos[index][i]==0)
                        {
                        //alert(j);
                        if (!SIsIn(index,count,j))
                                {

                                parent.SPos[index][i]=j;
                                }
                        else
                                {

                                }
                        }


                j=j+1;
                z=0;
                while(SIsIn(index,count,j) && i<count && z<100 )
                                {
                                z++;
                                j=j+1;
                                }
                if (j>count) j=1;

                }



        }




function SCreateRandomList(index,count,index2)
	{
	if (SRotation[index]=="Alphabetical") SRotation[index]=1;
	if (SRotation[index]=="Random") SRotation[index]=2;
	if (SRotation[index]=="Rotation") SRotation[index]=4;
	//alert(index);
	var OK=0;
	if (index!=0 && index2!=0)
	{
	try
	{
	if (String(parent.SPosOK[index])=="undefined")
		{
		OK=0;
		}
	else
		{
		OK=1;
		}
	}
	catch (error)
	{
		OK=0;
	}
	}
	if (OK==1)
		{
		//alert("OK");
		if (ReDimSPos(index,count,index2)==false) return;
		}
	else
		{
		//alert("NOT_OK");
		parent.SPos[index]=new Array();
		parent.SPosOK[index]="OK";
		}


	for(i=0;i<=count;i++)
		{
		if (SRotation[index]>=1 || String(SRotation[index])=="Random")
			parent.SPos[index][i]=0;
		else
			parent.SPos[index][i]=i+1;

		}
	if (index!=0)
	if (SRotation[index]==1 || String(SRotation[index])=="Alphabetical" )
		{
		SCreateSortedList(index,index2,count);
		}

	//alert(SRotation[index]);
	if (SRotation[index]==2 || String(SRotation[index])=="Random")
		{

		if (parent.HasRandomInfo(index))
			{
			parent.SetRandomInfo(index,count);
			}
		else
			{
		try{
		for(j=0;j<=count;j++)
			{
			//alert(NoR(index2,j));
			try{
			var C=SCodes[index2][j];}
			catch(e){C=0;}
			if (C=="999" || C=="888" || C=="555" || C=="666" || NoR(index2,j+1)==true )
				{
				//alert(j+1);
				parent.SPos[index][j]=j+1;
				}
			else
				parent.SPos[index][j]=0;
			}
		}catch(e){}





		for(j=0;j<=count;j++)
			{
			var ran_unrounded=Math.random()*(count);
			if (parent.SPos[index][j]==0)
			{
  			var number=Math.round(ran_unrounded);
			while(SIsIn(index,count,number)==1)
				{

				ran_unrounded=Math.random()*(count);
  			 	number=Math.round(ran_unrounded);

				}

				parent.SPos[index][j]=number;
				//alert(number);


			}
			}
			parent.AddRandomInfo(index,count);

		}}
	 if (SRotation[index]==4 || String(SRotation[index])=="Rotation" )
		{

		SCreateRotationalList(index,index2,count);

		}
	if (SRotation[index]==5 || String(SRotation[index])=="Preset")
		{
		SCreatePresetList(index,index2,count);
		}

	}


function SCreateSortedList(index,index2,count)
	{
	//alert("XXXX");
	var tmp=new Array();


	try{
	for (i=0;i<count;i++)
		{
		var C=SCodes[index2][i];
		if (C=="999" || C=="888" || C=="555" || C=="666" || NoR(index2,i+1)==true )
			{
			SItems[index2][i]="z?|"+SItems[index2][i]
			}
		tmp[i]=SItems[index2][i];
		}}catch(e){}

	tmp.sort();
	for (i=0;i<count;i++)
		for(j=0;j<count;j++)
			{

			if(tmp[i]==SItems[index2][j])
				{
				parent.SPos[index][i]=j+1;

				}
			}
	try{
	for (i=0;i<count;i++)
		{
		var C=SCodes[index2][i];
		if (C=="999" || C=="888" || C=="555" || C=="666" || NoR(index2,i+1)==true)
			{
			SItems[index2][i]=SItems[index2][i].replace("z?|","");
			}

		}}catch(e){}
	}


function SCreatePresetList(index,index2,count)
        {
	try{
        var i=0;
        var key2="";
        //alert(index.length);
        if (index.indexOf("b")==index.length-1)
                {
                key2=SColOrderPreset[SName[index2]];
                key2=key2.replace("[","");
                key2=key2.replace("]","");
                try{if (count+1!=parent.SPos[key2].length) return;}catch(e){}
                for (i=0;i<count;i++)
                        {
                        try{parent.SPos[index][i]=parent.SPos[key2][i];}catch(e){}

                        }
                }
        else
                {
                key2=SOrderPreset[SName[index2]];
                key2=key2.replace("[","");
                key2=key2.replace("]","");

                try{if (count+1!=parent.SPos[key2].length) return;}catch(e){}
                for (i=0;i<count;i++)
                        {
                        try{parent.SPos[index][i]=parent.SPos[key2][i];}catch(e){}

                        }
                }
	}catch(e){}
        }


function SPipe(S,op)
	{
	try{
	S=S.replace("&nbsp;"," ");
	var exp_s="";
	var txt="";
	var ref="";
	var ii=0;
	var flag=-1;
	var ext="";


	for(j=0;j<parent.VarCount;j++)
	{
		for (jj=0;jj<20;jj++)
			S=S.replace("["+parent.VarNames[j]+"]",parent.AnswerPool[parent.VarNames[j]]);

	}

	if (S==null) S="WHAT IS THE QUESTION?";
	for (ii=0;ii<=S.length;ii++)
		{
		if (S.charAt(ii)=='{')
			flag=2;
		if (S.charAt(ii)=='}')
			flag=3;
		if (S.charAt(ii)=='[' && flag!=2)
			flag=1;
		if (S.charAt(ii)==']' && flag!=2)
			flag=0;
		if ((S.charAt(ii)!='[' && S.charAt(ii)!=']' && flag!=2 ) || ( S.charAt(ii)!='{' && S.charAt(ii)!='}' && flag==2))
			{
			if (flag<0)
				txt=txt+S.charAt(ii);

			if (flag==1)
				ref=ref+S.charAt(ii);

			if (flag==0)
				{


				if (op!=1)
					{
					//alert(ref+" - "+parent.StringPool[ref]);
					ext=get_extension(parent.StringPool[ref]);

					if (ext=="gif" || ext=="jpg" || ext=="jpeg" || ext=="bmp" || ext=="jpe")
						txt=txt+"</DIV><DIV><img src="+parent.StringPool[ref] +" width="+parent.StringPool[ref+"_width"]+" height="+parent.StringPool[ref+"_height"]+" border=0></DIV>"+S.charAt(ii);

					else
						txt=txt+parent.StringPool[ref]+S.charAt(ii)+"";
					}
				else
					{
					if (isNaN(parent.AnswerPool[ref]))
						{
						AP=parent.AnswerPool[ref];
						//if (String(AP)!="undefined")
						//	AP=AP.substr(1);

						txt=txt+"'"+AP+"'"+S.charAt(ii);
						}
					else
						{
						txt=txt+parent.AnswerPool[ref]+S.charAt(ii);
						}
					}
				ref="";
				flag=-1;

				}
			if (flag==2)
				{
				exp_s=exp_s+S.charAt(ii);
				}
			if (flag==3)
				{
				//exp_s=exp_s+S.charAt(ii);


				exp_s=exp_s.replace("&nbsp;","");
				exp_s=SPipe(exp_s,1);
				for(jj=0;jj<30;jj++)
				{
				exp_s=exp_s.replace("&nbsp;","");
				exp_s=exp_s.replace("undefined","0");

				exp_s=exp_s.replace(" ","");
				exp_s=exp_s.replace("  ","");
				exp_s=exp_s.replace(String.fromCharCode(34),"'");
				exp_s=exp_s.replace("''","'");
				}
				try {
                                        //alert(exp_s);

                                        txt=txt+" "+eval(exp_s)+" ";

					flag=-1;
				    }
				catch (error)
				   {
					return "ERROR";
				   }

				}


			}

		}
	txt.replace("&nbsp;","");

	return txt;
	}catch(e){return ""}
	}
function ReInitHiddenList()
        {
        parent.ExecutePresetGroups();
        var j=1;


        while (String(STypeByIndex[j])!="undefined")
                        {
                        if (String(STypeByIndex[j])=="HiddenList")
                                {
                                SCList[j].Write();
                                SCList[j].Write();
                                }
                        if (String(STypeByIndex[j])=="GenericSlider")
                                {
                                SCList[j].Validate();
                                }
                        j++;
                        }

        if (String(STypeByIndex[j-1])=="HiddenScript")
                        {

                        SCList[j-1].Write();
                        }

        }



function SurveyWrite()
	{
	FixSize();
	if (parent.ROBOT_MODE==1 && String(NextPage)=="undefined") return;
	var B=new Array();
	B[0]="";
	B[1]="";
	var I=new Array();
	I[0]="";
	I[1]="";
	var S=new Array();
	S[0]="";
	S[1]="";
	var U=new Array();
	U[0]="";
	U[1]="";
	if (SSEItalic==1)
		{
		I[0]="<I>";
		I[1]="</I>";
		}
	if (SSEBold==1)
		{
		B[0]="<B>";
		B[1]="</B>";
		}
	if (SSEUnderline==1)
		{
		U[0]="<U>"
		U[1]="</U>"
		}


	var j=1;

	parent.parent.SPos[0]=new Array();
	if (parent.AnswerPool["debug"]=="1")
		{
		document.write("<input type='submit'  value='Debug'' onclick='debug();'>");

		}
	SCreateRandomList(0,SCount,SRotation[0]);
	if (parent==null) return;
	if ( parent.Page!=0 )
		{
		WriteErrors();
		parent.AnswerPool["CALLBACK"]=0;
		//alert(STypeByIndex[j]);
		while (String(STypeByIndex[j])!="undefined")
			{
			//alert(GetErrorCount());
			if (GetErrorCount()!=0)
				{
				if (SCList[parent.SPos[0][j-1]]!=null)
				if (SCList[parent.SPos[0][j-1]].Validate()==0)
					{
					document.write("<p><font color=",SSEColor," face='",SSEFontName,"' size=",SSETextSize,">",B[0],I[0],U[0],GetError(j),U[1],I[1],B[1],"</p>");
					SCList[parent.SPos[0][j-1]].Write();
					parent.AnswerPool[SName[j]+"_ERROR"]=0;

					}
				if ( parent.ROBOT_MODE==1) SCList[parent.SPos[0][j-1]].Robot();
				}
			else
				{
				if (SCList[parent.SPos[0][j-1]]!=null)
				SCList[parent.SPos[0][j-1]].Write();
				if ( parent.ROBOT_MODE==1) SCList[parent.SPos[0][j-1]].Robot();
				parent.AnswerPool[SName[j]+"_ERROR"]=0;

				}
                        		j++;
			}
		FlushErrors();
		}
	else
		{



			document.write("<p>You have just hit Refresh!!</p>");
			document.write("<p>you must take the survey from the start:(");
			Reset=1;
			parent.Page=1;

		}

	if (BckButton!="1")
		{
		window.history.forward(1);

		}

	}




// Navigation functions

function AddGoTo(question,condition,page)
	{
	args=AddGoTo.arguments;

	GoFromQuestion=question;
	for (i=1;i<(args.length-1);i=i+2)
		{
		GoToCount++;
		GoToCondition[GoToCount]=args[i];
		GoToPage[GoToCount]=args[i+1];
		}
	}
function GetNextPage()
	{
	//alert(NextPage+" "+FindNextPage(Page)+" "+Page);
		var FN=FindNextPage(Page);
		GoToFromQuestion=NextPage.replace("P","");
		GoToFromQuestion=GoToFromQuestion.replace(".htm","");
		GoToFromQuestion=parseInt(GoToFromQuestion);
		//alert(String(GoToFromQuestion)+" "+String(Page+1));
		//alert(FN);


		for (i=1;i<=GoToCount;i++)
		{
		var GT=GoToCondition[i];
		var GT=GT.replace("/*/","");
		//alert(parent.StringPool[GoFromQuestion]+" "+GoToCondition[i]);
		//alert(parent.StringPool[GoFromQuestion+"_1"]+"="+GoToCondition[i]);
		if (parent.StringPool[GoFromQuestion]==GT)
			{
			//parent.Page++;
			//return GoToPage[i];
			}
		if (parent.AnswerPool[GoFromQuestion]==GT)
			{
			//parent.Page++;
			return GoToPage[i];
			}
		if (parent.StringPool[GoFromQuestion+"_1"]==GT)
			{
			//parent.Page++;
			//return GoToPage[i];
			}
		if (parent.AnswerPool[GoFromQuestion+"_1"]==GT)
			{
			//parent.Page++;
			return GoToPage[i];
			}

		}

			var COND="";
			//alert(CondGotoCount);
			for(j=0;j<CondGotoCount;j++)
			{
			 COND=CondGoto[j][2];

				for (k=0;k<=parent.FieldListCount;k++)
					{
					//alert(parent.VarNames[k]);
					for (l=1;l<20;l++)
						{
						if (String(parent.AnswerPool[parent.FieldList[k]])!="undefined")
						COND=COND.replace("["+parent.FieldList[k]+"]",parent.AnswerPool[parent.FieldList[k]]);
						else
						COND=COND.replace("["+parent.FieldList[k]+"]","0");

						}
					}
					//alert(COND);
					try{

					if (String(eval(COND))=="true")
					{
						return CondGoto[j][1];
					}
					} catch(error){}

			}

		if (NextPage=="Exit.htm") return "TERMINATION";
		//alert(FN);
		if (GoToFromQuestion!=parseInt(Page+1))
		{

			return NextPage;
		}

		//if (parent.CondCount>0)
		//alert(NextPage);
		if (NextPage!=FN && NextPage!="ThankYou.htm")
			{
			//alert(NextPage);
			//alert(FN);
			//alert("COND");
			return(FN);
			}

		return NextPage;

	}


function AddSubmitButton(next_page,first_page)
	{
        if (parent.AnswerPool['NAVIGATION_BUTTONS']=='0')
        {
        FirstPage=first_page;
        NextPage=next_page;

         return;
         }
	var BACK_LBL="<<Back";
	if (window.screen.height<1000 && window.screen.width<1200)
		{
		//var f1="style='font-size:200%'";
		var f="";
		}
	else
		{
		var f1="";
		
		}
        try{
        if (DefaultError!="" && DefaultError!="english" && NEXT_LBL=="")
                {
                NEXT_LBL=GetMLError(41,DefaultError,"");
                BACK_LBL=GetMLError(40,DefaultError,"");
                }
        }catch(e){}
        if (NEXT_LBL=="") NEXT_LBL="Next>>";

	document.write("<hr><p align=left>");
	document.write("<table width=50%  align=left border=0>");
	//document.write("<tr align=left>");
	document.write("<td align=left valign=top>");
	//document.write("<p align=center>");

	if (SSButton=="" || SSButton==null)
	{
	if (Page>1)
		{
		if (BckButton=="1" || parent.AnswerPool["debug"]=="1" )
		document.write("<input type='submit' ",f1," value='"+BACK_LBL+"' onclick=document.location.href=parent.GoBack(1);></td><td valign=top");
		//document.write("</td><td valign=top>");
		}
	document.write("<div id='next'><input type='submit' ",f1," value='",NEXT_LBL,"' onclick=bclick('",next_page,"');></div>");
	}
	else
	{
	if (Page>1)
		{
               if (BckButton=="1")
                document.write("<input type='image' name='back'   value='Back' src='back.gif' onclick=document.location.href=parent.GoBack(1);></td><td valign=top>");
                }
                document.write("<div id='next'><input type='Image' name='Submit' value='Next' src='next.gif' onclick=bclick('",next_page,"');></div>");

	}
	document.write("</p></td>");
	document.write("</tr>");
	document.write("</table>");
	//document.write("</p>");
	FirstPage=first_page
	NextPage=next_page;
	if (parent.ROBOT_MODE==1) SurveyWrite();

	}
function  bclick(next_page)
	{
	//alert(next_page);
        parent.QUOTA_RESTART=0;
	ReInitHiddenList();
	CalcAllVars();
	ExecuteAllMacro();
	var GN=GetNextPage();
	parent.SkipData(Page,GN);
        var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome');
                if (is_chrome > 0)
                 {
                        if (parent.CheckQuotas()==1)
                                {

                                MakeQuotaFull();

                                location.href='../../INTERFACE/QUOTA_FULL_INPUT.php?INFO='+parent.AnswerPool['INFO']+'&ID='+parent.AnswerPool['ID'];
                                return;

                                 }
                }



	if (Validate()==1 || Reset==1)
		if (Reset!=1)
		{
		//alert(next_page);
		if (next_page=="../../INTERFACE/ThankYou.php3")
		{
		MakeSubmit();
		return;
		}

		if (GN=="TERMINATION")
			{
			//document.location.href="../../INTERFACE/termination.php?JOB_NAME="+parent.AnswerPool["JOB_NAME"]+"&JOB_ID="+parent.AnswerPool["JOB_ID"]+"&USER_NAME="+parent.AnswerPool["USER_NAME"]+"&PHONE_NO="+parent.AnswerPool["PHONE_NO"]+"&MODE="+parent.AnswerPool["MODE"]+"&ACTION=TERMINATION_DATA&ID="+parent.AnswerPool["ID"];
			//document.location.href="termination.html"
			MakeTermination();
			return;
			}
		else
			{

			document.location.href=GN;
			}

		//alert("1"+document.SURVEY.action);
		}
		else
		{
		 document.location.href=FirstPage;
		Reset=0;
		Page=1;
		FlushErrors();
		}
	else
		{
		if (Page=parent.Page)
			 document.location.href=document.location.href;
		else
			{
			//document.SURVEY.reset();

                        document.location.href=GN;

			}
		}

	//alert(document.SURVEY.action);


	//document.location=next_page;



	}

function Validate()
	{
	var v;
	var validate=1;
	var j=1;
	if (Reset==1) return 0;
	while(String(STypeByIndex[j])!="undefined")
		{
			if (SCList[j]!=null && SRequired[j]==0)
				v=SCList[j].Validate();
			if (v==0) validate=0;

                 j++;
		}
	if (validate==1) FlushErrors();
	return validate;
	}

function ConvertBR(input)
{
return input;
var output = "";
for (var i = 0; i < input.length; i++)
{

if ((input.charCodeAt(i) == 13) && (input.charCodeAt(i + 1) == 10))
        {
        i++;
        output += ";";
        }
        else
        {
        output += input.charAt(i);
        }
}
return output;
}


function GetDataString(CALL_TYPE)
	{
	var Q=""
	var ii=0;
        var s="";
	CalcAllVars();

	if (String(parent.AnswerPool["UNIQUE_ID"])=="undefined")
		{
		for(i=0;i<6;i++)
			MYID=MYID+String(Math.random()*9);
		//alert(MYID);
		parent.AddField("UNIQUE_ID",1000);
		parent.AnswerPool["UNIQUE_ID"]=MYID;
		}


	Time = new Date();
       // parent.ClearSkippedData();
	parent.AddField("REVISED_FIELDS",0,0);
	parent.MAKE_REVISED_FIELD();
	//alert("XX");
	parent.EndTime= (Time.getHours()*60*60) + (Time.getMinutes()*60) + Time.getSeconds();
	TimeTaken=parent.EndTime - parent.StartTime;
	Q="TIME|"+String(TimeTaken)+"|";
	for(ii=0;ii<parent.FieldListCount;ii++)
		{
			if (parent.AnswerPool[parent.FieldList[ii]]!=null)
			{
                        s=parent.AnswerPool[parent.FieldList[ii]];
                        s=ConvertBR(s);

                        Q=Q + parent.FieldList[ii] + "|" + encodeURIComponent(s) + "|";
			//Q=Q + parent.FieldList[ii] + "|" + escape(parent.AnswerPool[parent.FieldList[ii]]) + "|";
			}
		}
	  if (String(parent.AnswerPool["ID"])!="undefined")
	  Q=Q + "ID|" + escape(parent.AnswerPool["ID"]) + "|";
	//alert(Q);
	//ShowAllVars();
	return(Q);
	}

function GetCBString()
	{
	var Q="";
	for(i=4;i<parent.FieldListCount;i++)
		{

			if (parent.AnswerPool[parent.FieldList[i]]!=null)
			{
			Q=Q + parent.FieldList[i] + "|" + parent.AnswerPool[parent.FieldList[i]] + "|";
			}
		}
	return(Q);
	}

function CodeLink(code,question,show)
	{

	if (question=="") return true;
	for (i=4;i<parent.FieldListCount;i++)
		{
		var codeval=parent.AnswerPool[parent.FieldList[i]];
		var name=parent.FieldList[i];
		//alert(name);
		var del=name.indexOf("_");
		//alert(del);
		if (del==0)
			qid=question;
		else
			qid=parent.FieldList[i].substr(0,del);

		if (show==1)
			{
			//alert(qid+' '+question);
			if ((codeval==code) && (qid==question))
				return true;
			}
		else
			{

			//alert(qid+' '+question);
			if ((codeval==code) && (qid==question))
				return false;
			}
		}
	if (show==0)
		return true;
	else
		return false;

	}

function MakeSubmit()
{
//alert("****");
var DATA=GetDataString();
document.write("<html>");
document.write("<head></head>");
document.write("<body>");
document.write("<form method='post' action='../../INTERFACE/INPUT.php' name='form1'>");
document.write("<input type='hidden' name='INFO' value=", parent.AnswerPool["INFO"],"/>");
document.write("<input type='hidden' name='DATA' value=", DATA,"/>");
if (parent.AnswerPool["ID"]!="")
document.write("<input type='hidden' name='ID' value=", parent.AnswerPool["ID"],">");
document.write("</form>");
document.write("<script>document.form1.submit();</script>");
document.write("</body>");
document.write("</html>");
}

function StoreData()
{
//alert(String(parent.AnswerPool["JOB_NAME"]));


if (String(parent.AnswerPool["JOB_NAME"])=="undefined")
	{
	document.location.href="end.html";
	}
else
	{
	return "../INTERFACE/input.php";
	}

}

function MakeTermination()
	{
	parent.AddField('BATCH_ID',1,1000);
	parent.AnswerPool['BATCH_ID']="TERMINATION";
	var DATA=GetDataString();
	document.write("<html>");
	document.write("<head></head>");
	document.write("<body>");
	document.write("<form method='post' action='../../INTERFACE/TERMINATED_INPUT.php'name='form1'>");
	document.write("<input type='hidden' name='INFO' value=", parent.AnswerPool["INFO"],"/>");
	document.write("<input type='hidden' name='DATA' value=", DATA,"/>");
	if (parent.AnswerPool["ID"]!="")
	document.write("<input type='hidden' name='ID' value=", parent.AnswerPool["ID"],">");
	document.write("</form>");
	document.write("<script>document.form1.submit();</script>");
	document.write("</body>");
	document.write("</html>");
	}

function MakeQuotaFull()
	{
	parent.AddField('BATCH_ID',1,1000);
	parent.AnswerPool['BATCH_ID']="QUOTA_FULL";
	var DATA=GetDataString();
	document.write("<html>");
	document.write("<head></head>");
	document.write("<body>");
        document.write("<form method='post' action='../../INTERFACE/QUOTA_FULL_INPUT.php' name='form1' >");
	document.write("<input type='hidden' name='INFO' value=", parent.AnswerPool["INFO"],"/>");
	document.write("<input type='hidden' name='DATA' value=", DATA,"/>");
	if (parent.AnswerPool["ID"]!="")
	document.write("<input type='hidden' name='ID' value=", parent.AnswerPool["ID"],">");
	document.write("</form>");
        document.write("<script>");
        document.write("document.form1.submit();");
        document.write("var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome'); ");
        document.write("if (is_chrome > 0) {document.location.href='../../INTERFACE/QUOTA_FULL_INPUT.php';} ");


        document.write("</script>");
	document.write("</body>");
	document.write("</html>");
	}

function StoreRejectData()
	{
	//alert("XX");

	//document.location.href="../INTERFACE/termination.php?JOB_NAME="+parent.AnswerPool["JOB_NAME"]+"&USER_NAME="+parent.AnswerPool["USER_NAME"]+"&PHONE_NO="+parent.AnswerPool["PHONE_NO"]+"&MODE="+parent.AnswerPool["MODE"]+"&ACTION=TERMINATION_DATA";
	document.location.href="termination.html";
	}



function WriteErrors()
	{
	var B=new Array();
	B[0]="";
	B[1]="";
	var I=new Array();
	I[0]="";
	I[1]="";
	var S=new Array();
	S[0]="";
	S[1]="";
	var U=new Array();
	U[0]="";
	U[1]="";
	if (SSEItalic==1)
		{
		I[0]="<I>";
		I[1]="</I>";
		}
	if (SSEBold==1)
		{
		B[0]="<B>";
		B[1]="</B>";
		}
	if (SSEUnderline==1)
		{
		U[0]="<U>"
		U[1]="</U>"
		}

	if (parent.FieldListCount!=0)
		{
		if (GetErrorCount()>0)
			document.write("<p><font face='",SSEFontName,"' size=",SSETextSize," color=",SSEColor,">",B[0],I[0],U[0],SSEErrorHeader,U[1],I[1],B[1],"</font></P>");
		}

	//FlushErrors();
	}

function GetError(index)
	{
	return parent.GetError(index)
	}
function GetErrorCount()
	{
	return parent.ErrorListIndex;
	}
function FlushErrors()
	{
	parent.FlushErrors();
	for (i=0;i<SCount;i++)
		parent.AnswerPool[SName[i]+"_ERROR"]=0;

	}
function AddError(err,index)
	{

	parent.AddError(err,index);
	parent.AnswerPool[SName[index]+"_ERROR"]=1;
	}

function LegalMove()
	{
	if (parent==null) return (-1);
	if (Page<parent.Page) return 0;
	return 1;
	}
function AddCondition(ParentQuestion,Attr,AttrValue,Action,Page,Operation,Scale)
	{
	parent.AddCondition(ParentQuestion,Attr,AttrValue,Action,Page,Operation,Scale);
	}

function AddAttrCondition(ParentQuestion,ParentAttr,ChildQuestion,ChildAttr,AttrValue,Action,operation,Scale)
	{
	parent.AddAttrCondition(ParentQuestion,ParentAttr,ChildQuestion,ChildAttr,AttrValue,Action,operation,Scale);
	}

function AddColCondition(ParentQuestion,ParentAttr,ChildQuestion,ChildAttr,AttrValue,Action,operation,Scale)
	{
	parent.AddColCondition(ParentQuestion,ParentAttr,ChildQuestion,ChildAttr,AttrValue,Action,operation,Scale);
	}

function AddAttrAdvCondition(Question,Attribute,Condition,Action)
	{
	parent.AddAttrAdvCondition(Question,Attribute,Condition,Action);
	}

function AddColAdvCondition(Question,Attribute,Condition,Action)
	{
	parent.AddColAdvCondition(Question,Attribute,Condition,Action);
	}


function AddConditionalGoto(ParentQuestion,GotoPage,Condition)
	{
	CondGoto[CondGotoCount]=new Array();
	CondGoto[CondGotoCount][0]=ParentQuestion;
	CondGoto[CondGotoCount][1]=GotoPage;
	CondGoto[CondGotoCount][2]=Condition;
	CondGotoCount++;
	}




function AddAdvCondition(Page,Condition,Action)
	{
	parent.AddAdvCondition(Page,Condition,Action);
	}
function AddVariable(VarName,VarExp)
	{
	parent.AddVariable(VarName,VarExp);
	}

function IsAttrHidden(ParentQuestion,ParentAttr)
	{
	return parent.IsAttrHidden(ParentQuestion,ParentAttr);
	}

function IsColHidden(ParentQuestion,ParentAttr)
	{
	return parent.IsColHidden(ParentQuestion,ParentAttr);
	}
function CalcAllVars()
	{
	//alert(Page);
	//alert(parent.Page);
	//alert("XX");
	var jj;
	for(jj=0;jj<parent.FieldListCount;jj++)
		{

			if (parent.FieldList[jj]==parent.VariableList[0][parent.FieldList[jj]] )
			{
			//alert(parent.FieldList[jj]);
			if (parent.AnswerPool[parent.FieldList[jj]]<=0 || parent.AnswerPool[parent.FieldList[jj]]=="ERROR" || Page<parent.Page)
				CalcVar(parent.FieldList[jj]);
			}
		}
	}

function ShowAllVars()
	{
	//alert("XX");
	var jj;
	var s="";
	for(jj=0;jj<parent.FieldListCount;jj++)
		{

			if (parent.FieldList[jj]==parent.VariableList[0][parent.FieldList[jj]])
			{
			//alert(parent.FieldList[jj]);
			if (parent.AnswerPool[parent.FieldList[jj]]==0 || parent.AnswerPool[parent.FieldList[jj]]=="ERROR")
				CalcVar(parent.FieldList[jj]);
			s=s+parent.FieldList[jj]+"="+parent.AnswerPool[parent.FieldList[jj]]+"\n";
			}
		}


	}

function CalcVar(VarName)
	{
	var S= "{"+parent.VariableList[1][VarName]+"}" ;
	var S2="0";
	var V=0;
	S=SPipe(S);
	S=S.replace(" ","");
	S=S.replace(" ","");
	S=S.replace("  ","");
	if (String(S)=="ERROR")
	{
	S2="ERROR";
	parent.AnswerPool[VarName]=S2;
	}
	if (S=="false")
		{
		S2="2";
		parent.AnswerPool[VarName]=S2;
		}
	if (S=="true")
		{
		S2="1";
		parent.AnswerPool[VarName]=S2;
		}
	if (S!="true" && S!="false")
		{
		parent.AnswerPool[VarName]=S;
		parent.StringPool[VarName]=S;
		}

	//alert(parent.AnswerPool['Q20517u_1']);


	}

function AddMacro(Condition,Var,Value)
	{
	Macro[MacroCount]=new Array();
	Macro[MacroCount][0]=Condition;
	Macro[MacroCount][1]=Var;
        parent.AddField(Var,1001);
	Macro[MacroCount][2]=Value;
	MacroCount++;
	}

function ExecuteAllMacro()
	{
	parent.StringPool["macro_debug"]="";
	for(i=0;i<MacroCount;i++)
		ExecuteMacro(i);

	}
function ExecuteMacro(MacroIndex)
	{
	var md=parent.StringPool["macro_debug"];
        var S= "{"+Macro[MacroIndex][0]+"}" ;

        var SB=S;
	var S2="0";
	var V=0;
	md=md+S+" = ";
        md=md+S;
        S=S.replace(" ="," ==");

        S=SPipe(S,1);
        S=S.replace(" ","");
	S=S.replace(" ","");
        S=S.replace("  ","");

        if (String(S)=="ERROR")
	{

	}
	else
	{
                //if (parent.AnswerPool["debug"]=="1") alert(String(S));

		if (String(S)=="true")
		{
                        //if (parent.AnswerPool["debug"]=="1") alert(S);

			md=md+" -> ";
			S=Macro[MacroIndex][1];
			md=md+S+" = ";
			S=S.replace("[","");
			S=S.replace("]","");

                        //if (parent.AnswerPool["debug"]=="1") alert(S);

			try{S2=SPipe(Macro[MacroIndex][2]);}catch(error){S2=Macro[MacroIndex][2];}
			S2=S2.replace(";","");

                        try{
			if (String(eval(S2))!="NaN") S2=eval(S2);

			}catch(error){}
			try{
			S2=S2.replace(";","");}catch(e){}
			md=md+S2;
                        //if (parent.AnswerPool["debug"]=="1") alert("["+S+"]");
                        //parent.AddField(S,1001);
                        parent.AnswerPool[S]=S2;
			parent.StringPool[S]=S2;

		}
                else
                {
                //if (parent.AnswerPool["debug"]=="1") alert(S);

                }

	}
md=md+"<br>";
parent.StringPool["macro_debug"]=md;
}

function FindNextPage(FromPage)
	{
	return parent.FindNextPage(FromPage);
	}

function SetBG()
	{
	if (SSBgType=="1")
		document.bgColor=(SSBgColor);
	else
		{
		document.body.background=SSBgPic;
		}
	}
function SetNumber(name)
	{
	parent.SetNumber(name);
	}
function GetNumber(name)
	{
	return parent.GetNumber(name);
	}


function GetItem(s)
{
var pair=s.split("|");
return(pair[0]);
}
function GetCode(s)
{
var pair=s.split("|");
return(pair[1]);
}
function ISDC(s)
{
var pair=s.split("/");
if (pair[1]=="*") return true;
return false;
}


function QueryString_Parse()
{
	var query = window.location.search.substring(1);
	var pairs = query.split("&");
	alert(query);
	for (var i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');

		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			if (argname=="DB")
			{

			parent.AddField("DB");

			parent.AnswerPool["DB"]==value;
			}
			if (argname=="PHONE") var PHONE=value;
			if (argname=="USR") var USR=value;

		}
	}

}



function PurgeString(STR)
{
STR=ReplaceString(STR,"+","%20");
STR=ReplaceString(STR,"'","%30");
STR=ReplaceString(STR," ","%20");
STR=ReplaceString(STR,"`","%30");
STR=ReplaceString(STR,"/","-");
return STR;
}
function ReplaceString(str,SubStrOld,SubStrNew)
	{
	if (parseInt(str)>0) return str;
	var OldStr="";
	var NewStr=str;
	while (OldStr!=NewStr)
		{
		OldStr=NewStr;
		NewStr=str.replace(SubStrOld,SubStrNew);
		str=NewStr;
		}
	return(str);

}

function Heading(index)
{
	var ext ="";
	var star="";
	//if (SRequired[index]==1) star="*";
	var B=new Array();
	B[0]="";
	B[1]="";
	var I=new Array();
	I[0]="";
	I[1]="";
	var S=new Array();
	S[0]="";
	S[1]="";
	var U=new Array();
	U[0]="";
	U[1]="";
	if (SSQItalic==1)
		{
		I[0]="<I>";
		I[1]="</I>";
		}
	if (SSQBold==1)
		{
		B[0]="<B>";
		B[1]="</B>";
		}
	if (SSQUnderline==1)
		{
		U[0]="<U>"
		U[1]="</U>"
		}
	if (SNotes[index]!="")
		NOTES="<br><font size=",SSQTextSize," color=#FF0000 face=",SSQFontName,"><B>",SNotes[index],"</B>";
	else
		NOTES="";

	document.write("<p align=",SSAlign,">");
	var BG="";
	document.write("<table width=90% border=",SSBorderWidth," cellpadding=0 cellspacing=0>");
	if (SSQBgType=="0")
		BG="";
	if (SSQBgType=="1")
		BG=" bgcolor='"+SSQBgColor+"' ";

	if (SSQBgType=="2")
		BG=" background="+SSQBgPic+" ";
		//alert(BG);
	document.write("<tr >");
    	if (String(parent.SQNum[SName[index]])=="undefined") parent.SQNum[SName[index]]="";
    	if (  parent.AnswerPool["HideQNum"]!=1)
		document.write("<td ",BG," valign=top width=8%><font size=",SSQTextSize," color=",SSQColor," face=",SSQFontName,">",B[0],I[0],U[0],parent.SQNum[SName[index]],U[1],I[1],B[1],".<B> ",star,"</B></td>");
	else
		document.write("<td ",BG," width=8%><font size=",SSQTextSize," color=",SSQColor," face=",SSQFontName,"><B> ",star,"</B></td>");
	var NOTES="";
	if (parent.AnswerPool["debug"]=="1" || parent.AnswerPool["HideNotes"]!="1")
	if (SNotes[index]!="") NOTES="<br><font size="+SSQTextSize+" color=#FF0000 face="+SSQFontName+">"+SNotes[index]+"</td>";

	document.write("<td width=92% ",BG,"><font size=",SSQTextSize," color=",SSQColor," face=",SSQFontName,">",B[0],I[0],U[0],SPipe(SText[index]),U[1],I[1],B[1],NOTES);

  	document.write("</tr>");
	var BG="";
	SPic[index]=SPic[index].replace('%20',' ');
	if (SSIBgType=="1")
		BG="bgcolor='"+SSIBgColor+"'";
	if (SSIBgType=="2")
		BG="Background='"+SSIBgPic+"'";
  	if (SPic[index]!="")
	{
        ext=get_extension(SPic[index]);
        SPic[index]=SPic[index].replace("FILES","FILES/");
	
	if (ext=="gif" || ext=="jpg" || ext=="bmp" || ext=="jpeg" || ext=="jpe")
		{
		document.write("<tr>");
    		document.write("<td ",BG," width=8% nowrap>&nbsp;</td>");
		document.write("<td ",BG," width=92%>");
		
		document.write("<P align=",SPicAlign[index],"><img src=",SPic[index] ," width=",SPicWidth[index]," height=",SPicHeight[index]," border=0></a></p>");
		document.write("</td>");
  		document.write("</tr>");
		}

	if (ext=="swf")
		{

		document.write("<tr>");
		document.write("<td ",BG," width=8% nowrap>&nbsp;</td>");
		document.write("<td ",BG," width=92%>");
		document.write("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'");
 		document.write("codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'");
 		document.write("Height=",SPicHeight[index]," width=",SPicWidth[index],">");
    		document.write("<PARAM NAME=movie VALUE='",SPic[index],"'>");
    		document.write("<PARAM NAME=quality VALUE=high>");
    		document.write("<PARAM NAME=bgcolor VALUE=#FFFFFF>");
    		document.write("<EMBED src='",SPic[index],"' quality=high bgcolor=#FFFFFF  height=",SPicHeight[index]," width=",SPicWidth[index]," TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED>");
  		document.write("</OBJECT>");
		document.write("</td>");
		document.write("</tr>");
		}
	if (ext=="mpg" || ext=="avi" || ext=="mov" || ext=="mp4" || ext=="mpeg" || ext=="ram" || ext=="ra" || ext=="asf")
		{
		document.write("<tr>");
		document.write("<td ",BG," width=8% nowrap>&nbsp;</td>");
		document.write("<td ",BG," width=92%>");
		document.write("<object data='",SPic[index],"' type='video/x-ms-wmv' width=",SPicWidth[index]," height=",SPicHeight[index]," >");
		document.write("<param name='ShowStatusBar' value='1'>");
		document.write("<param name='src' value='",SPic[index],"'>");
		document.write("<param name='autostart' value='1'>");
		document.write("<param name='volume' value='4'>");
		document.write("</object>");
		document.write("</td></tr>");
		}
	}
  	document.write("<tr>");

	document.write("<td ",BG," width=8% nowrap ></td>");
    	document.write("<td ",BG," width=92% nowrap >");

	document.write("<table ",BG," border=0 cellspacing=0 cellpadding=2 align=default  >");

}

function get_extension(s)
	{
	var e="";
	var flag=0;
	var c="";
	if (String(s)=="undefined") return "";
	for(var i=0;i<s.length;i++)
		{
		c=s.charAt(i);
		if (c==".")
			flag=1;
		if (flag==1 && c!=".")
			e=e+c;
		}

	return e.toLowerCase();
	}
function right(e) {
	if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) return false;
	else if (navigator.appName == 'Microsoft Internet Explorer' && 	(event.button == 2 || event.button == 3)) {
	alert("I'm sorry, The Right click option on your mouse has been disabled for the download window pages.");
	return false;
	}
	return true;
	}
function COPY_PROTECT()
	{
	return;
	document.onmousedown=right;
	document.onmouseup=right;
	if (document.layers) window.captureEvents(Event.MOUSEDOWN);
	if (document.layers) window.captureEvents(Event.MOUSEUP);
	window.onmousedown=right;
	window.onmouseup=right;

	}
function AddField(name,index,pge)
	{
	parent.AddField(name,index,pge);
	}

function SetValue(FIELD_NAME,FIELD_VALUE)
	{
	FIELD_VALUE=unescape(FIELD_VALUE);
	if (FIELD_NAME=="PAGE")
	{
		parent.AddToNHistory(FIELD_VALUE);
	}
	else
		{
		parent.AddField(FIELD_NAME);
		parent.AnswerPool[FIELD_NAME]=unescape(FIELD_VALUE);
		parent.StringPool[FIELD_NAME]=unescape(FIELD_VALUE);
		}
}



function debug()
	{
	ExecuteAllMacro();
	oFullTitle = window.open('','fullTitle',"width=600, height=600");

	oFullTitle.document.write(parent.StringPool["macro_debug"]);
	oFullTitle.focus();

	}

function AutoFill(index,dim,cols,col_arr)
        {
           var nums="0123456789";
	var isval=0;
	var aval=0;
	var c=0;
	var key1=SName[index];
	var OP=0;
	var key2=SAutoFill[key1];
	if (key2.indexOf("[")==-1)
		{
                isval=1;

		 if (nums.indexOf(key2)>-1)
			{
                        aval=parseInt(key2);
			}
                else
                        aval=key2;
		}
	key2=key2.replace("[","");
	key2=key2.replace("]","");
	if (key2.indexOf("!")>-1)
		{
		OP=1;
		key2=key2.replace("!","");
		}

	if (key2=="") return;

	if (dim==1)
		{
		if (isval==1)
			{
			if (String(parent.AnswerPool[key1])=="undefined")
				{
				parent.AnswerPool[key1]=aval;
				parent.StringPool[key1]=aval;
				}
			}
                        else
                        {

                                parent.AnswerPool[key1]=parent.AnswerPool[key2];
                                parent.StringPool[key1]=parent.AnswerPool[key2];

                         }
		if (isval!=1)
		{
		if (String(parent.AnswerPool[key2])!="undefined")
			{
			if (String(parent.AnswerPool[key1])=="undefined")
				{
				parent.AnswerPool[key1]=parent.AnswerPool[key2];
				parent.StringPool[key1]=parent.AnswerPool[key2];
				}


			}
		else
			{
			if (String(parent.StringPool[key2])!="undefined")
				{
				if (String(parent.AnswerPool[key1])=="undefined")
					{
					parent.AnswerPool[key1]=parent.StringPool[key2];
					parent.StringPool[key1]=parent.StringPool[key2];
					}
				}
			}
		}
		}
	if (dim==2)
                {


                for (i=1;i<=SItemsCount[index];i++)
                        {
                        var1=key1+"_"+String(i);
                        var2=key2+"_"+String(i);
                        if (isval==1)
                        {
                                if (String(parent.AnswerPool[var1])=="undefined")
                                {
                                if (SItems[index][i-1]!="")
                                        {
                                        parent.AnswerPool[var1]=aval;
                                        parent.StringPool[var1]=aval;
                                        }
                                }
                        }
                        if (isval!=1)
                        {
                        if (OP==0)
                                {
                                if (String(parent.AnswerPool[var2])!="undefined")
                                        {
                                        c++;
                                        if (String(parent.AnswerPool[var1])=="undefined")
                                                {
                                                if (SItems[index][i-1]!="")
                                                        {
                                                        parent.AnswerPool[var1]=parent.AnswerPool[var2];
                                                        parent.StringPool[var1]=parent.StringPool[var2];
                                                        }
                                                }
                                        }
                                }
                        else
                                {
                                if (String(parent.AnswerPool[var2])=="undefined" || parent.AnswerPool[var2]==0)
                                        {
                                        c++;
                                        if (String(parent.AnswerPool[var1])=="undefined")
                                                {
                                                if (SItems[index][i-1]!="")
                                                        {
                                                        parent.AnswerPool[var1]=SCodes[index][i-1];
                                                        parent.StringPool[var1]=SCodes[index][i-1];
                                                        }
                                                }
                                        }
                                }
                        }
                        }
                if (c==0)
                        {
                        for (i=1;i<=SItemsCount[index];i++)
                                {
                                var1=key1+"_"+String(i);
                                var2=key2;
                                if (isval==1)
                                {
                                        if (String(parent.AnswerPool[var1])=="undefined")
                                                {
                                                if (SItems[index][i-1]!="")
                                                        {
                                                        parent.AnswerPool[var1]=aval;
                                                        parent.StringPool[var1]=aval;
                                                        }
                                                }
                                }
                                if (isval!=1)
                                {
                                if (OP==0)
                                        {
                                        if (parent.AnswerPool[var2]==SCodes[index][i-1])
                                                {
                                                if (String(parent.AnswerPool[var1])=="undefined")
                                                {
                                                        if (SItems[index][i-1]!="")
                                                        {
                                                        parent.AnswerPool[var1]=parent.AnswerPool[var2];
                                                        parent.StringPool[var1]=parent.AnswerPool[var2];
                                                        }
                                                }
                                                c++;

                                                }
                                        }
                                else
                                        {
                                        if (String(parent.AnswerPool[var2])!=SCodes[index][i-1])
                                                {
                                                if (String(parent.AnswerPool[var1])=="undefined")
                                                        {
                                                        if (SItems[index][i-1]!="")
                                                                {
                                                                parent.AnswerPool[var1]=SCodes[index][i-1];
                                                                parent.StringPool[var1]=SCodes[index][i-1];
                                                                }
                                                        }
                                                c++;

                                                }
                                        }
                                }
                                }


                        }
                }
                if (dim==3)
                {
                for (i=1;i<=SItemsCount[index];i++)
                        {
                        for (j=1;j<=cols;j++)
                                {
                                var1=key1+"_"+String(j)+"_"+String(i);
                                var2=key2+"_"+String(j)+"_"+String(i);
                                if (isval==1)
                                {
                                        if (String(parent.AnswerPool[var1])=="undefined")
                                                {
                                                if (SItems[index][i-1]!="" && col_arr[index][j-1]!="")
                                                        {
                                                        parent.AnswerPool[var1]=aval;
                                                        parent.StringPool[var1]=aval;
                                                        }
                                                }
                                }
                                if (isval!=1)
                                {
                                if (OP==0)
                                        {
                                        if (String(parent.AnswerPool[var2])!="undefined")
                                                {
                                                if (String(parent.AnswerPool[var1])=="undefined")
                                                        {
                                                        if (SItems[index][i-1]!="" && col_arr[index][j-1]!="")
                                                                {
                                                                parent.AnswerPool[var1]=parent.AnswerPool[var2];
                                                                parent.StringPool[var1]=parent.StringPool[var2];
                                                                }
                                                        }
                                                c++;
                                                }
                                        }
                                else
                                        {
                                        if (String(parent.AnswerPool[var2])=="undefined" || parent.AnswerPool[var2]==0)
                                                {
                                                if (String(parent.AnswerPool[var1])=="undefined")
                                                        {
                                                        if (SItems[index][i-1]!="" && col_arr[index][j-1]!="")
                                                                {
                                                                parent.AnswerPool[var1]=SCodes[index][j-1];
                                                                parent.StringPool[var1]=SCodes[index][j-1];
                                                                }
                                                        }
                                                c++;
                                                }

                                        }

                                }
                                }
                        }

                if (c==0)
                        {

                        }

                }
        }


// SCRIPT functions

function ListOrder(List)
	{
	SRotation["alist"]=1;
	var NewList=new Array();
	SCreateRandomList("alist",List.length,999);
	for (var i=0;i<List.length;i++)
		{
		NewList[i]=List[parent.SPos["alist"][i]-1];
		}
	return NewList;
	}

function ListShuffle(List)
	{
	SRotation["alist"]=2;
	var NewList=new Array();
	SCreateRandomList("alist",List.length,999);
	for (var i=0;i<List.length;i++)
		{
		NewList[i]=List[parent.SPos["alist"][i]-1];
		}
	return NewList;
	}

function ListDiSPlay(List)
	{
	document.write("<br>");
	for (var i=0;i<List.length;i++)
		{
		document.write(List[i],"<br>");
		}
	}

function GetValue(FieldName)
	{
	try{
	var v=parent.AnswerPool[FieldName];
	if (String(v)=="undefined")
		return "undefined";
	else
		return v;
	}catch(e){return "undefined";}
	}

function AddContinueLaterButton()
{
	if (InStr(parent.AnswerPool["ID"],"@")>0 || parseInt(parent.AnswerPool["ID"])>0)
		{
		if (parent.AnswerPool["NOQUIT"]!="1")
			{
			parent.AddField("ID",1001);
			document.write("<P align=left><input type='submit'  value='Quit & resume later' onclick='MakeQuitSubmit();'></P>");
			}
		}
}


function InStr(strSearch, charSearchFor)
{
if (strSearch=="") return -1;
if (String(strSearch)=="undefined") return -1;
var i=0;
	for (i=0; i < strSearch.length; i++)
	{
	if (charSearchFor == strSearch.charAt(i))
		{
		return i;
		}
	}
	return -1;
}


   function sleep(naptime){
        naptime = naptime * 1000;
        var sleeping = true;
        var now = new Date();
        var alarm;
        var startingMSeconds = now.getTime();
        //alert("starting nap at timestamp: " + startingMSeconds + "\nWill sleep for: " + naptime + " ms");
        while(sleeping){
            alarm = new Date();
            alarmMSeconds = alarm.getTime();
            if(alarmMSeconds - startingMSeconds > naptime){ sleeping = false; }
        }
        //alert("Wakeup!");
   }


//*************************************************************************************************************
//*************************************************************************************************************
//************************************ LAST UPDATED on the 26/5/2008*******************************************
//*************************************************************************************************************
//*************************************************************************************************************


