/*
Rounded Div - Version 2.4 - (I.E & Firefox)
	Properties
		rdid - Field to generate a Unique ID for rounded div 
		top - top position
		left - left position
		width - width of the rounded div 
		height - height of the rounded div
		color - Color to be used
		bgcolor - Back ground color
		insideColor - 
		borders - 
		content -  defines the content of the roundend div
		target
		contentAlign - Content allign
		noTopCorners - bool var to define if it will have top corners
		noBottomCorners   - bool var to define if it will have top corners
		roundFactor - can be 1 or 2 
		position - define the position of the div
		posfloat - to define postion
		zIndex - define zIndex of the DIV
		
	Class Methods
		display - displays rounded div		
		setDisplay - 
		getHTML - getting HTML source code
		setVisibility - setting round div visbility
		setHeight - setting height of the rounded div
		setWidth - setting width of the rounded div
		setPosition - setting position (usefull for using shaddow)
		setShaddow - add shadow
		updateShaddowHeight - updates shaddow height along with rounded div default width
		
	Special Class Methods		
		startRoundedDiv (*) - diferent contructer tecnicque helps building the rounded div ~  <rdiv>
		endRoundedDiv (*) - diferent contructer tecnicque helps building the rounded div  ~  </rdiv>


	//No Shaddow - example:
			div = new roundedDiv('rdiv1no_shaddow',0,0,185,160,'#EC981F','white','#666666' , true, 'content',   '',    'left',false,false,1,'absolute','left',100);		
			div.display();
			div = new roundedDiv('rdiv2no_shaddow',0,230,185,160,'#EC981F','white','#666666' , true, 'content',   '',    'left',false,false,1,'absolute','left',100);
			div.display();
			div = new roundedDiv('rdiv3no_shaddow',0,450,185,160,'#EC981F','white','#666666' , true, 'content',   '',    'left',false,false,2,'absolute','left',100);	
			div.display();
			
	 //Shaddow - example
			div = new roundedDiv('rdiv1',210,0,185,160,'#EC981F','white','#666666' , true, 'content',   '',    'left',false,false,1,'absolute','left',100);
			div.display();
			div.setPosition('absolute');
			div.setShaddow(4,0.4);			

			div = new roundedDiv('rdiv2',210,230,185,160,'#EC981F','white','#666666' , true, 'content',   '',    'left',false,false,1,'absolute','left',100);
			div.display();
			div.setPosition('absolute');
			div.setShaddow(4,0.5);
			
			div = new roundedDiv('rdiv3',210,450,185,160,'#EC981F','white','#666666' , true, 'content',   '',    'left',false,false,2,'absolute','left',100);
			div.display();
			div.setPosition('absolute');
			div.setShaddow(4,0.7);	

			//example with no weight defined
			div = new roundedDiv('rdiv4',210,650,185,'','#EC981F','white','#666666' , true, '<br/><br/>content<br/><br/><br/>',   '',    'left',false,false,2,'absolute','left',100);
			div.display();
			div.setPosition('absolute'); 
			div.setShaddow(5,0.22);	
			div.updateShaddowHeight();
	
*/
function roundedDiv(rdid,top,left,width,height,color,bgcolor,insideColor, borders, content, target, contentAlign ,noTopCorners, noBottomCorners , roundFactor ,position , posfloat, zIndex){
	//Properties
	this.rdid = rdid;
	this.top = top;
	this.left = left;
	this.width = width;
	this.height = height;
	this.color = color;
	this.bgcolor = bgcolor;
	this.content = content;
	this.contentAlign = contentAlign;
	this.noBottomCorners= noBottomCorners;
	this.noTopCorners = noTopCorners;
	this.roundFactor = roundFactor;
	this.position = position;
	this.zIndex =zIndex;
	this.posfloat = posfloat;
	this.target = target;
	this.borders = borders;	
	var strDiv = "";
	this.strDiv =strDiv;
	this.insideColor  = insideColor;
	
	this.topCorners ="";
	this.bottomCorners ="";
	this.mainDiv_open ="";	
	this.mainDiv_close ="";
	this.sDiv = "";
	this.cDiv = "";	
	this.shaddow = false;
	
	//Class Methods
	this.display = display;
	this.startRoundedDiv = startRoundedDiv;
	this.endRoundedDiv   = endRoundedDiv;
	this.setVisibility   = setVisibility;
	this.setDisplay      = setDisplay; 	
	this.getHTML   = getHTML;
	this.setHeight = setHeight;
	this.setWidth = setWidth;
	this.setPosition = setPosition;
	this.setShaddow = setShaddow;
	this.showShaddow = showShaddow;
	this.hideShaddow = hideShaddow;
	this.updateShaddowHeight =updateShaddowHeight;


	//TOP - Rounded Corners
	if(this.noTopCorners == false){
		if(this.roundFactor == 1 ){
			this.topCorners =this.topCorners+'<DIV id="top1'+this.rdid+'-top2" STYLE="position:relative;'+
											'top:  1px;' +
											'_top:  3px;' +										
											'left: 4px;' +
											'_left: 4px;' +
											'width:'+(this.width)+'px;' +
											'_width:'+(this.width+4)+'px;' +
											'height: 1px;' +
											'font-size: 1px;' +
											//'background-color:'+this.bgcolor+';">' +
											'background-color: '+this.color+';">' +
											'</DIV>';						

			this.topCorners =this.topCorners+'<DIV id="top2'+this.rdid+'-top2" STYLE="position:relative;'+
											'top:  1px;' +
											'_top:  2px;' +											
											'left: 3px;' +
											'_left: 3px;' +
											'width:'+(this.width+2)+'px;' +
											'_width:'+(this.width+6)+'px;' +										
											'height: 1px;' +
											'font-size: 1px;' +
	//										'background-color:'+this.bgcolor+';">' +
											'background-color: '+this.color+';">' +
											'</DIV>';
														
				
		}else if(this.roundFactor == 2){
		
			this.topCorners =this.topCorners+'<DIV id="top1'+this.rdid+'-top2" STYLE="position:relative;'+
											'top:  1px;' +
											'_top:  4px;' +										
											'left: 6px;' +
											'_left: 6px;' +
											'width:'+(this.width-4)+'px;' +
											'_width:'+(this.width)+'px;' +
											'height: 1px;' +
											'font-size: 1px;' +
											//'background-color:'+this.bgcolor+';">' +
											'background-color: '+this.color+';">' +
											'</DIV>';						

			this.topCorners =this.topCorners+'<DIV id="top2'+this.rdid+'-top2" STYLE="position:relative;'+
											'top:  1px;' +
											'_top:  3px;' +											
											'left: 5px;' +
											'_left: 5px;' +
											'width:'+(this.width-2)+'px;' +
											'_width:'+(this.width+2)+'px;' +										
											'height: 1px;' +
											'font-size: 1px;' +
	//										'background-color:'+this.bgcolor+';">' +
											'background-color: '+this.color+';">' +
											'</DIV>';	
			this.topCorners =this.topCorners+'<DIV id="top3'+this.rdid+'-top2" STYLE="position:relative;'+
											'top:  1px;' +
											'_top:  2px;' +											
											'left: 4px;' +
											'_left: 4px;' +
											'border-right: 2px solid '+this.color+'; border-left: 2px solid '+this.color+';' +
											'width:'+(this.width-4)+'px;' +
											'_width:'+(this.width)+'px;' +										
											'height: 1px;' +
											'font-size: 1px;' +
	//										'background-color:'+this.bgcolor+';">' +
											'background-color: '+this.bgcolor+';">' +
											'</DIV>';												
			this.topCorners =this.topCorners+'<DIV id="top4'+this.rdid+'-top2" STYLE="position:relative;'+
											'top:  1px;' +
											'_top:  1px;' +											
											'left: 3px;' +
											'_left: 3px;' +
											'border-right: 2px solid '+this.color+'; border-left: 2px solid '+this.color+';' +
											'width:'+(this.width-2)+'px;' +
											'_width:'+(this.width+2)+'px;' +										
											'height: 1px;' +
											'font-size: 1px;' +
	//										'background-color:'+this.bgcolor+';">' +
											'background-color: '+this.bgcolor+';">' +
											'</DIV>';	
										
		
		}
	}
	
	//MAIN DIV
	this.mainDiv_open = this.mainDiv_open+'<DIV id="'+this.rdid+'" STYLE="position:relative;'+
							    'top:1px;'+ 
								'left:2px; '+
								'width:'+(this.width)+'px; '+
								'_width:'+(this.width+4)+'px; '+
								'height:'+this.height+'px; '+
								'background-color:'+this.bgcolor+';'; 
	if (this.borders) { 
			this.mainDiv_open = this.mainDiv_open + 'border-right: 2px solid '+this.color+'; border-left: 2px solid '+this.color+';'; 
			
			if(this.noTopCorners == true){
				this.mainDiv_open = this.mainDiv_open + 'border-top: 2px solid '+this.color+';'
			}
			if(this.noBottomCorners == true){
				this.mainDiv_open = this.mainDiv_open + 'border-bottom: 2px solid '+this.color+';'; 						
			}				 
	}
	if (this.target != "") { 
		this.mainDiv_open = this.mainDiv_open+'cursor:pointer;'; 
	}
	this.mainDiv_open = this.mainDiv_open+'color:'+this.insideColor+';"';

    if (this.target != "") { 
			this.mainDiv_open = this.mainDiv_open+'onclick="javascript: '+ this.target + '"'; 
	}
	this.mainDiv_open = this.mainDiv_open+'>';
	
	this.mainDiv_close = '</DIV>';


	//BOTTOM - Rounded Corners
	if(this.noBottomCorners == false){	
			if(this.roundFactor == 1 ){
			
			this.bottomCorners =this.bottomCorners+'<DIV id="bottom2'+this.rdid+'-top2" STYLE="position:relative;'+
										'top:  1px;' +
										'_top:  1px;' +											
										'left: 3px;' +
										'_left: 3px;' +
										'width:'+(this.width+2)+'px;' +
										'_width:'+(this.width+6)+'px;' +										
										'height: 1px;' +
										'font-size: 1px;' +
										'_overflow: hidden; clip: auto;'+ 
//										'background-color:'+this.bgcolor+';">' +
										'background-color: '+this.color+';">' +
										'</DIV>'				
			this.bottomCorners =this.bottomCorners+'<DIV id="bottom1'+this.rdid+'-top2" STYLE="position:relative;'+
										'top:  1px;' +
										'_top:  0px;' +										
										'left: 4px;' +
										'_left: 4px;' +
										'width:'+(this.width)+'px;' +
										'_width:'+(this.width+4)+'px;' +											
										'height: 1px;' +
										'font-size: 1px;' +
										//'background-color:'+this.bgcolor+';">' +
										'background-color: '+this.color+';">' +
										'</DIV>';		
			
			}else if(this.roundFactor == 2){
						this.bottomCorners =this.bottomCorners+'<DIV id="bottom4'+this.rdid+'-top2" STYLE="position:relative;'+
											'top:  1px;' +
											'_top:  1px;' +											
											'left: 3px;' +
											'_left: 3px;' +
											'border-right: 2px solid '+this.color+'; border-left: 2px solid '+this.color+';' +
											'width:'+(this.width-2)+'px;' +
											'_width:'+(this.width+2)+'px;' +										
											'height: 1px;' +
											'font-size: 1px;' +
	//										'background-color:'+this.bgcolor+';">' +
											'background-color: '+this.bgcolor+';">' +
											'</DIV>';	
											
			this.bottomCorners =this.bottomCorners+'<DIV id="bottom3'+this.rdid+'-top2" STYLE="position:relative;'+
											'top:  1px;' +
											'_top:  0px;' +											
											'left: 4px;' +
											'_left: 4px;' +
											'border-right: 2px solid '+this.color+'; border-left: 2px solid '+this.color+';' +
											'_border-right: 1px solid '+this.color+'; _border-left: 1px solid '+this.color+';' +
											'width:'+(this.width-4)+'px;' +
											'_width:'+(this.width+2)+'px;' +										
											'height: 1px;' +
											'font-size: 1px;' +
	//										'background-color:'+this.bgcolor+';">' +
											'background-color: '+this.bgcolor+';">' +
											'</DIV>';											
							
					

			this.bottomCorners =this.bottomCorners+'<DIV id="bottom2'+this.rdid+'-top2" STYLE="position:relative;'+
											'top:  1px;' +
											'_top:  -1px;' +											
											'left: 5px;' +
											'_left: 5px;' +
											'width:'+(this.width-2)+'px;' +
											'_width:'+(this.width)+'px;' +										
											'height: 1px;' +
											'font-size: 1px;' +
											'_border-right: 1px solid '+this.color+'; _border-left: 1px solid '+this.color+';' +											
	//										'background-color:'+this.bgcolor+';">' +
											'background-color: '+this.color+
											';_background-color: '+this.bgcolor+											
											';">' +
											'</DIV>';	
											
			this.bottomCorners =this.bottomCorners+'<DIV id="bottom1'+this.rdid+'-top2" STYLE="position:relative;'+
											'top:  1px;' +
											'_top:  -2px;' +										
											'left: 6px;' +
											'_left: 6px;' +
											'width:'+(this.width-4)+'px;' +
											'_width:'+(this.width)+'px;' +
											'height: 1px;' +
											'font-size: 1px;' +
											//'background-color:'+this.bgcolor+';">' +
											'background-color: '+this.color+';">' +
											'</DIV>';
										
				  }
			}
			//Construncting Rounded Div	
		   this.strDiv = this.strDiv   + this.topCorners;	
		    this.strDiv = this.strDiv  + this.mainDiv_open;
		     this.strDiv = this.strDiv + this.content;
		    this.strDiv = this.strDiv  + this.mainDiv_close;
		   this.strDiv = this.strDiv   + this.bottomCorners;	
			
			this.sDiv = '<div id="MainVLX'+ this.rdid+'"' +
						    'style="' + 
							'z-index:' + this.zIndex + ';'+
						    'top:0px;' +
						    'width:'+this.width+'px; '+
							'_width:'+(this.width+10)+'px; '+
						    'height:'+this.height+'px; ';				  
						  
						  if(posfloat!= '')
								this.sDiv = this.sDiv + 'float: '+  this.posfloat + '; ';
						  
						 this.sDiv= this.sDiv +  'padding-right: 5px; _padding-right: 5px;' +
									   '">';
									   
						this.cDiv = '</div>';
									   
									   			

			this.htmlSrc = this.sDiv + this.strDiv + this.cDiv;

	//Special Class Methods - Div construction by step
	function startRoundedDiv(){
		document.write(this.sDiv);
		 document.write(this.topCorners);
		 document.write(this.mainDiv_open);
	}	
	function endRoundedDiv(){
		document.write(this.mainDiv_close);
		document.write(this.bottomCorners);
	  document.write(this.cDiv);
	}
	//////////////////////////////////////

	function setVisibility(value){
		//value = 'hidden' or 'visible'  
		document.getElementById('MainVLX'+ this.rdid).style.visibility = value;
	}

	function setDisplay(value){
		//value = 'none' or 'block'  
		document.getElementById('MainVLX'+ this.rdid).style.display = value;
	}
	
	function setHeight(value){
		document.getElementById(this.rdid).style.height = value;
		if(this.shaddow)
			document.getElementById('MainVLX'+ this.rdid + 'shaddow').style.height = value;				
	}
	
	function updateShaddowHeight(){
		document.getElementById('MainVLX'+ this.rdid + 'shaddow').style.height = document.getElementById(this.rdid).offsetHeight;				
	}	
	
	function setWidth(value){ 
		if(this.roundFactor == 1){ //works only on Firefox 
			document.getElementById(this.rdid).style.width = value;	
			document.getElementById('top1'+this.rdid+'-top2').style.width = value ;	
			document.getElementById('top2'+this.rdid+'-top2').style.width = value+2 ;		
			document.getElementById('bottom2'+this.rdid+'-top2').style.width = value+2 ;	
			document.getElementById('bottom1'+this.rdid+'-top2').style.width = value ;
		}
		if(this.roundFactor == 2){ //works only on Firefox 
			document.getElementById(this.rdid).style.width = value;	
			document.getElementById('top1'+this.rdid+'-top2').style.width = value-4 ;	
			document.getElementById('top2'+this.rdid+'-top2').style.width = value-2 ;		
			document.getElementById('top3'+this.rdid+'-top2').style.width = value-4;	
			document.getElementById('top4'+this.rdid+'-top2').style.width = value-2 ;			
			document.getElementById('bottom4'+this.rdid+'-top2').style.width = value-2;
			document.getElementById('bottom3'+this.rdid+'-top2').style.width = value-4 ;			
			document.getElementById('bottom2'+this.rdid+'-top2').style.width = value-2 ;	
			document.getElementById('bottom1'+this.rdid+'-top2').style.width = value-4 ;		
		}
	}
	
	function setPosition(position){
		document.getElementById('MainVLX'+ this.rdid).style.position = position;
		document.getElementById('MainVLX'+ this.rdid).style.top = this.top;
		document.getElementById('MainVLX'+ this.rdid).style.left = this.left;
	}
	
	
	//Shaddow function only will work with Postion Absolute 
	function setShaddow(distance, opacity){
	var ie_opacity;
		ie_opacity=opacity;
		
		if(ie_opacity<=0.2)
			ie_opacity = 0.2;
/*		if(ie_opacity>0.5)
			ie_opacity = ie_opacity - 0.3;	*/			
	
		if(typeof(distance) == 'undefined')
			distance = 4;
		if(typeof(opacity) == 'undefined')
			opacity = '1.00';
			
		shaddowDiv = new roundedDiv('MainVLX'+ this.rdid + 'shaddow',this.top+distance, this.left+distance, this.width, this.height,'rgb(187, 187, 187)','rgb(187, 187, 187)', 'rgb(187, 187, 187)' , this.borders, '',   '',    'left',this.noTopCorners,this.noBottomCorners,this.roundFactor,'absolute','left',1);
		shaddowDiv.display();
		shaddowDiv.setPosition('absolute');
		
		document.getElementById('MainVLX'+ this.rdid + 'shaddow').style.opacity=opacity;
		document.getElementById('MainVLX'+ this.rdid + 'shaddow').style.filter ='Alpha(Opacity='+(ie_opacity * 100)  +')';
		
		if(this.noTopCorners == false){
			document.getElementById('top2MainVLX'+this.rdid+'shaddow-top2').style.opacity = opacity ;
			document.getElementById('top1MainVLX'+this.rdid+'shaddow-top2').style.opacity = opacity ;
			document.getElementById('top2MainVLX'+this.rdid+'shaddow-top2').style.filter ='Alpha(Opacity='+((ie_opacity) * 100)  +')';
			document.getElementById('top1MainVLX'+this.rdid+'shaddow-top2').style.filter ='Alpha(Opacity='+((ie_opacity) * 100)  +')';
			if(this.roundFactor == 2){
						document.getElementById('top3MainVLX'+this.rdid+'shaddow-top2').style.opacity = opacity ;
						document.getElementById('top4MainVLX'+this.rdid+'shaddow-top2').style.opacity = opacity ;
						//IE opacity correction
						document.getElementById('top3MainVLX'+this.rdid+'shaddow-top2').style.filter ='Alpha(Opacity='+((ie_opacity-ie_opacity) * 100)  +')';
						//-------------------------
						document.getElementById('top4MainVLX'+this.rdid+'shaddow-top2').style.filter ='Alpha(Opacity='+((ie_opacity) * 100)  +')';
			}
		}
		if(this.noBottomCorners == false){
			document.getElementById('bottom1MainVLX'+this.rdid+'shaddow-top2').style.opacity = opacity ;
			document.getElementById('bottom2MainVLX'+this.rdid+'shaddow-top2').style.opacity = opacity ;	
			document.getElementById('bottom1MainVLX'+this.rdid+'shaddow-top2').style.filter ='Alpha(Opacity='+((ie_opacity) * 100)  +')';
		    document.getElementById('bottom2MainVLX'+this.rdid+'shaddow-top2').style.filter='Alpha(Opacity='+((ie_opacity) * 100)  +')';
			if(this.roundFactor == 2){
						document.getElementById('bottom3MainVLX'+this.rdid+'shaddow-top2').style.opacity = opacity ;
						document.getElementById('bottom4MainVLX'+this.rdid+'shaddow-top2').style.opacity = opacity ;
						document.getElementById('bottom3MainVLX'+this.rdid+'shaddow-top2').style.filter ='Alpha(Opacity='+((ie_opacity-ie_opacity) * 100)  +')';
						//IE opacity correction
						document.getElementById('bottom4MainVLX'+this.rdid+'shaddow-top2').style.filter='Alpha(Opacity='+((ie_opacity) * 100)  +')';
						//--------------------------
			}
		}
		
		document.getElementById('MainVLXMainVLX'+ this.rdid + 'shaddow').style.top =this.top+distance+'px';
		document.getElementById('MainVLXMainVLX'+ this.rdid + 'shaddow').style.left =this.left+distance+'px';

				
		this.shaddow = true;		
	}	

	function showShaddow(){
	   document.getElementById('MainVLXMainVLX'+ this.rdid + 'shaddow').style.display = "block";
	}	
		
	function hideShaddow(){
	   document.getElementById('MainVLXMainVLX'+ this.rdid + 'shaddow').style.display = "none";
	}	
									   
	function display(){		
		document.write(this.htmlSrc);
	}


	function getHTML(){		
		return this.htmlSrc;
	}

}



