		

//***************************************************************************
function HtmlControlCollector() 
{
	this.ControlCollection = [];
	this.Report="";
}
	/*--------------------------------------------------------------------------------------------------------*/
	HtmlControlCollector.prototype.GetControlsByType=GetControlsByType;
	HtmlControlCollector.prototype.Add=Add;
	HtmlControlCollector.prototype.ShowReport=ShowReport;
	/*--------------------------------------------------------------------------------------------------------*/	
	function GetControlsByType(type)//------- METHOD TO GET AN ARRAY OF CONTROLS OF A DETERMINATE TYPE
	{
		//alert("long="+document.getElementsByTagN);
		if((type!=null)&&(type!=""))
		{
			this.ControlCollection=document.getElementsByTagName(type);
		}
	}
	function Add(object)//------------------- METHOD TO ADD TYPED OBJECTS INTO THE COLLECTION OF OBJECTS 
	{
		var longit=this.ControlCollection.length;
		this.ControlCollection[longit]=object;
	}
	function ShowReport(option)//------------ METHOD TO SEE THE REPORT OF OBJECTS COLLECTED (opts:msgbox, writed, etc...) 
	{
		this.Report="<br><br> Controls collected:"+this.ControlCollection.length;
		for(i=0;i<this.ControlCollection.length;i++)
		{
			this.Report+="<br>elemento["+i+"]: [ "+this.ControlCollection[i].tagName+" ]";
		}
		switch(option)
		{
			case "msgbox":
				this.Report=this.Report.replace("<br>","\n");
				this.Report=this.Report.replace("<br>","\n");
				this.Report=this.Report.replace("<br>","\n");
				alert("Report:\n"+this.Report);
			break;
			case "wrote":
				document.write("<br>Report:<br>"+this.Report);
			break;
			case "layered":
				document.write("<br><div>"+this.Report+"</div>");
			break;
		}	
	}
	/*--------------------------------------------------------------------------------------------------------*/

//*****************************************************************************
function BrowserInformer() 
{
	this.ActualUrl=parent.location.href;
	this.QueryString="?";
	this.AnonymousQueryString="?prm_id_c=SPED15";
	this.ArrayChecker=[];
	this.KeyValuePairs=[];
	this.SetValuePairs();//set an array the name, value pairs and change the property QueryString each time page loads...

}
	/*--------------------------------------------------------------------------------------------------------*/
	BrowserInformer.prototype.CheckQueryString=CheckQueryString;
	BrowserInformer.prototype.CompleteAnchors=CompleteAnchors;
	BrowserInformer.prototype.GenerateUrlForFlash=GenerateUrlForFlash;
	BrowserInformer.prototype.SetValuePairs=SetValuePairs;
	BrowserInformer.prototype.RequestQueryString=RequestQueryString;
	/*--------------------------------------------------------------------------------------------------------*/	
	function CheckQueryString()//------------ METHOD TO CHECK IF THE VISITOR IS ANONYMOUS, OR HAVE A PROMOTION AND COUPON CODE 
	{
		this.ArrayChecker[0]=false;
		this.ArrayChecker[1]=false;
		
		if(this.ActualUrl.indexOf("?")!="-1")
		{
			
			//check if have the promotion code
			if(this.ActualUrl.indexOf("prm_id_c")!="-1")
			{
				this.ArrayChecker[0]=true;
			}
			//check if have coupon code
			if(this.ActualUrl.indexOf("cop_id_c")!="-1")
			{
				this.ArrayChecker[1]=true;
			}
		}
	}
	function GenerateUrlForFlash(currenturl)
	{
		var newurl=currenturl;
		if((this.ArrayChecker[0])&&(this.ArrayChecker[1])) //have both promotion code and coupon code
		{	
			newurl+=escape(this.QueryString);	//generate with url encoding the new url with parameters
		}
		else if((this.ArrayChecker[0])&&(!this.ArrayChecker[1])) //have promotion code but no coupon code
		{	
			newurl+=escape(this.QueryString);	//generate with url encoding the new url with parameters
		}
		else
		{
			newurl+=escape(this.AnonymousQueryString);	//generate with url encoding the new url with parameters
		}
		
		return newurl;
	}
	function CompleteAnchors(controlcollection) //------------ METHOD TO COMPLETE THE HREF OF THE ANCHOR IF HAVE A PROMOTION CODE AND COUPON CODE
	{
		for(i=0;i<controlcollection.length;i++)
		{
			switch(controlcollection[i].tagName)
			{
				case "A":
					
					var currentanchor=controlcollection[i]; //get the object anchor
					if(currentanchor.href.indexOf("#")==-1)
					{
						if((this.ArrayChecker[0])&&(this.ArrayChecker[1])) //have both promotion code and coupon code
						{	
							currentanchor.href+=this.QueryString;	//put the querystring to the current anchor
						}
						else if((this.ArrayChecker[0])&&(!this.ArrayChecker[1]))
						{
							currentanchor.href+=this.QueryString;
						}
						else
						{
							currentanchor.href+=this.AnonymousQueryString; //put the anonymous querystring to the current anchor
						}
					}
				break;
				case "FORM":
				
					var currentform=controlcollection[i]; //get the object anchor
					
					if((this.ArrayChecker[0])&&(this.ArrayChecker[1])) //have both promotion code and coupon code
					{	
						
						currentform.action+=this.QueryString;	//put the querystring to the current anchor
					}
					else if((this.ArrayChecker[0])&&(!this.ArrayChecker[1]))
					{
						alert(this.QueryString);
						currentform.action+=this.QueryString;
					}
					else
					{
						
						currentform.action+=this.AnonymousQueryString; //put the anonymous querystring to the current anchor
					}
				break;
			}
		}
	}
	function SetValuePairs()//------------ METHOD FILL AN ARRAY OF VALUE PAIRS, SO WE CAN DO A REQUEST QUERYSTRING
	{
		var trashurl1;
		var trashurl2;
		var currentpairvalue;
		if(this.ActualUrl.indexOf("?")!="-1")
		{
			if(this.ActualUrl.indexOf("&")!="-1")//if have more than one parameter
			{
				trashurl1=this.ActualUrl.split("?");
				this.QueryString+=trashurl1[1];
				
				trashurl2=trashurl1[1].split("&");
				
				for(i=0;i<trashurl2.length;i++)
				{
					currentpairvalue=trashurl2[i].split("=");
					var test=new Array();
					this.KeyValuePairs[currentpairvalue[0]]=currentpairvalue[1];
				}
			}
			else //if only have a parameter
			{
				trashurl1=this.ActualUrl.split("?");
				this.QueryString+=trashurl1[1];
			}
		}
	}
	function RequestQueryString(name)//------------ METHOD GET THE VALUE OF A PARAMETER IN THE URL
	{
		return this.KeyValuePairs[name];
	}
//*****************************************************************************

//*******INITIALIZE OBJECTS INSTANCES AND GLOBAL VARIABLES ********************
var controls=new HtmlControlCollector();
var browserinfo=new BrowserInformer();
var url="swf/promo.swf?cadeau=regalo1.aspx&inscription=https://commerce.conseur.org/ce/order_subscription_d15.asp";
browserinfo.CheckQueryString(); 
//*****************************************************************************



