var Y_p;
var X_p;

var layerToDrag = 0;

var zcounter = 1;
var drag=true;

var oY;
var oX;
var move = true;


var coneDone = false;
var coneMemebers = 20;
var coneopp = 30;
var coneColor = '#99CC33';

var shadowColor = '#333333';

var popDivWidth = 226;
var popDivHeight = 450;

var shadeOffset = 1;
var shadowIncr = 0;
var allCones = new Array();
var popup_win = new Array();

function detectBrowser()
{   
        var sAgent = navigator.userAgent.toLowerCase();
        this.isIE = (sAgent.indexOf("msie")!=-1); //IE6.0-7
        this.isFF = (sAgent.indexOf("firefox")!=-1);//firefox
        this.isSa = (sAgent.indexOf("safari")!=-1);//safari
        this.isOp = (sAgent.indexOf("opera")!=-1);//opera
        this.isNN = (sAgent.indexOf("netscape")!=-1);//netscape
        this.isMa = this.isIE;//marthon
        this.isOther = (!this.isIE && !this.isFF && !this.isSa && !this.isOp && !this.isNN && !this.isSa);//unknown Browser
}
    
function moveCone(obj, child){
	if(move == true){
	//
		eeY = document.getElementById(obj.id).offsetTop;
		eeX = document.getElementById(obj.id).offsetLeft;
		eeY = eeY-document.getElementById(obj.id+'contDiv').offsetTop;
		eeX = eeX-document.getElementById(obj.id+'contDiv').offsetLeft;
		
	if(document.getElementById(child)==null){
		for(var oi = 0; oi < coneMemebers; oi++){

			var ott = (eeY/coneMemebers)*oi;
			var oll = (eeX/coneMemebers)*oi;
			//
			var memberIds = obj.id+'D'+oi;
			//
			document.getElementById(memberIds).style.top = ott+'px';
			document.getElementById(memberIds).style.left = oll+'px';
		}
		
	}else{
		oY = eeY;
		oX = eeX;
		
		for(var oi = 0; oi < coneMemebers; oi++){
			//-startY-startX
			
			var ott = (oY/coneMemebers)*oi;
			var oll = (oX/coneMemebers)*oi;
			
			//
			var memberIds = obj.id+'D'+oi;
			//
			document.getElementById(memberIds).style.top = ott+'px';
			document.getElementById(memberIds).style.left = oll+'px';
			//
			}
			
			if(document.all){
				document.getElementById(child+'contDiv').style.top = obj.offsetTop+198+'px';
				document.getElementById(child+'contDiv').style.left = obj.offsetLeft+215+'px';
			}else{
				document.getElementById(child+'contDiv').style.top = obj.offsetTop+192+'px';
				document.getElementById(child+'contDiv').style.left = obj.offsetLeft+209+'px';
			}
			

			
			var t = document.getElementById(child).offsetTop;
			var l = document.getElementById(child).offsetLeft;
			t = t-document.getElementById(child+'contDiv').offsetTop;
			l = l-document.getElementById(child+'contDiv').offsetLeft;
			//
		for(var o = 0; o < coneMemebers; o++){
			var childMemberIds = child+'D'+o;
			
			var ott = (t/coneMemebers)*o;
			var oll = (l/coneMemebers)*o;
			//
			document.getElementById(childMemberIds).style.top = ott+'px';
			document.getElementById(childMemberIds).style.left = oll+'px';
			
			
			}
		}
	}
}

function stopOpaque(obj){
	if(document.all){
		obj.style.filter='alpha(opacity = 100)'; 
	}else{
		obj.style.MozOpacity = 1; 
	}
}

//make object transparent
function opaque(object){
/**/
	if(document.all){
		object.style.filter='alpha(opacity = '+coneopp+')'; 
	}else{
		var op = coneopp/100;
		object.style.MozOpacity = op; 
	}
	
}
function opaqueWin(object){
/**/
	var opp = 60;
	if(document.all){
		object.style.filter='alpha(opacity = '+opp+')'; 
	}else{
		var op = opp/100;
		object.style.MozOpacity = op; 
	}
	
}
//

var ow;
var oh;


//
var objectZ=1;
var coneC=0;
var a = 0;

function renderTrail(dragBar, draggedObj, sX, sY, zz){


		var endX = draggedObj.offsetLeft;
		var endY = draggedObj.offsetTop;
			endX -= sX;
			endY -= sY;
		//
		var startW = 60;
		var startH = 18; 
		var endW = draggedObj.offsetWidth;
		var endH = draggedObj.offsetHeight;
		//
		var ll = 0;
		var tt = 50;
		var ww = 260;
		var hh = 300;
		var length = coneMemebers;
	//
	var containerDiv = document.createElement("DIV");
		containerDiv.id = draggedObj.id+'contDiv';
		containerDiv.style.position = 'absolute';
		containerDiv.style.left = sX+'px';
		containerDiv.style.top = sY+'px';
		containerDiv.style.height = 50+'px';
		containerDiv.style.width = 50+'px';
		containerDiv.style.border = '0px solid #000000';
		containerDiv.style.zIndex = zz;
		document.body.appendChild(containerDiv);

		zcounter++;
		
	//
	var v = length;//100;
	
	/////////auto transparency/////////
		coneopp = Math.round((30/length)*5);
		if(coneopp<=30){
			posSliders('transparencyWrapRail', 'transparencyWrap');
		}
	var distanceX = Math.abs(endX/length);
	var distanceY = Math.abs(endY/length);
	var dist = Math.abs(distanceX/distanceY);
		//alert(distanceX+' , '+distanceY+' , '+dist);
		
	for(var ii = 0; ii<length; ii++){
		//
		var leftP = ((endX/length)*ii); //-Math.round((distanceX*v)/endX);
		var topP = ((endY/length)*ii); //-Math.round((distanceY*v)/endY);
		//
		ww= startW+Math.abs(((endW-startW)/length*ii)); //-Math.round((distanceX*v)/endX); 
		hh= startH+Math.abs(((endH-startH)/length*ii)); //-Math.round((distanceX*v)/endX); 
		
		var oDiv=document.createElement("DIV");
		oDiv.id=draggedObj.id+'D'+ii;
		oDiv.style.position='absolute';
		//
		oDiv.style.width=ww+'px';
		oDiv.style.height=hh+'px';
		//
		oDiv.style.left=leftP+'px';
		oDiv.style.top=topP+'px';
		//
		oDiv.style.background = coneColor;
		oDiv.style.border = '0px solid black';

		containerDiv.appendChild(oDiv);
		//
		//coneopp -= Math.round(length/);
		
		opaque(oDiv);
		oDiv.style.zIndex = zcounter;
		 

		//drawnCone[ii]={oo:oDiv, oid:oDiv.id, oot:tt, ool:ll, oow:ww, ooh:hh};
		allCones[a]={oo:oDiv, oid:oDiv.id, oot:tt, ool:ll, oow:ww, ooh:hh};
		zcounter++;
		a++;
		v -= ii;
	}

	coneDone=true;
 //coneC++;
}
//var drawnCone = new Array();
//
//
function getElementPosition(elemID) {
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}
//Where to position the new popup in relation to its origin. Offset values
var offsetXX = 65;
var offsetYY = -144;
//
var allobj = new Array();
//
function createpopObj(origId, xx , yy, content_var,titlename){

     var fullStr = content_var;
     var charCount = fullStr.length;
     var rExp = /[^A-Za-z0-9]/gi;
     var spacesStr = fullStr.replace(rExp, " ");
     var cleanedStr = spacesStr + " ";
     do {
           var old_str = cleanedStr;
           cleanedStr = cleanedStr.replace("  ", " ");
        } while(old_str != cleanedStr);
     var splitString = cleanedStr.split(" ");
     var wordCount = splitString.length -1;
     if (fullStr.length <1) {
        wordCount = 0;
      }
     
    var dynamic_height=(wordCount/4+1)*5;
	

		var dragBar = document.createElement("IMG");
			dragBar.id = origId+'Pop';
			dragBar.name = origId+'Pop';
			dragBar.src = 'welcome_images/subheader_bg_solid.gif';
			dragBar.width = 204; //188 - colse button width 14 px // left 4 right 4 bottom bar height 27
			dragBar.height = 20;
			dragBar.style.cursor = 'move';
			dragBar.style.position = 'absolute';
			dragBar.style.left = 4+'px';
			dragBar.style.top = 0+'px';
			dragBar.style.zIndex = 1;
			//dragBar.appendChild(document.createTextNode("aaaa"));
		var title_text= document.createElement("span");
			title_text.appendChild(document.createTextNode(titlename));
			
	  var dragBarText= document.createElement("DIV");
	      //dragBarText.id = origId+'Pop';
			  //dragBarText.name = origId+'Pop';
	      dragBarText.style.zIndex = 5;
			  dragBarText.style.position = 'absolute';
			  dragBarText.style.left = 4+'px';
			  dragBarText.style.fontSize = 11+'px';
			  dragBarText.style.top = 3+'px';

			  //alert("IE:" + oBrowser.isIE + "\nfirefox:" + oBrowser.isFF + "\nsafari:" + oBrowser.isSa + "\nopera:" + oBrowser.isOp + "\nnetscape:" + oBrowser.isNN + "\nmarthon:" + oBrowser.isMa + "\nother browser:" + oBrowser.isOther);
			  //dragBarText.Height = 20;
			  //dragBarText.width = 1000;
			  dragBarText.appendChild(title_text);

		var thisId = origId+'PopWrap';
		
		var popDiv = document.createElement("DIV");
			popDiv.id = thisId;
			//popDiv.style.='halfalpha';
			//popDiv.style.opacity = 'alpha';
			popDiv.className = 'draggable';
			popDiv.style.position = 'absolute';
			popDiv.style.left = xx+offsetXX+'px';
			popDiv.style.top = yy+offsetYY+'px';
			popDiv.style.width = popDivWidth+5+'px';
			popDiv.style.border = '0px solid black';
			popDiv.style.zIndex = zcounter+6000;
			popDiv.style.filter='alpha(opacity=90)';
			popDiv.style.MozOpacity='0.9'; 
			popDiv.overflow = 'visble';
			
			var oBrowser = new detectBrowser();
			if(oBrowser.isIE)
			{
				popDiv.style.height = popDivHeight+8+'px';
			}
			  
			
		var popInnerDiv = document.createElement("DIV");
			popInnerDiv.id = thisId+'inner';
			//popInnerDiv.className = 'draggable';
			popInnerDiv.style.filter='alpha(opacity=90)';
			popInnerDiv.style.position = 'absolute';
			popInnerDiv.style.left = 0+'px';
			popInnerDiv.style.top = 0+'px';
			//popInnerDiv.style.height = popDivHeight+'px';
			popInnerDiv.style.width = popDivWidth+'px';
			popInnerDiv.style.border = '0px solid black';
			popInnerDiv.style.zIndex = zcounter+6000;
			//popInnerDiv.overflow = 'visble';	
		//
		//alert(popInnerDiv.style.filter);
		document.body.appendChild(popDiv);
		
		popDiv.appendChild(popInnerDiv);
		popInnerDiv.innerHTML = '<table id="'+origId+'table'+pcount+'" width="100%" cellpadding="0" cellspacing="0" border="0"><\/table>';
		//alert(popInnerDiv.innerHTML);
		var poptable = document.getElementById(origId+'table'+pcount);
		//alert(poptable.id);
		//alert(popDiv.innerHTML);
		
		var brbuttid = 	popid+'brbutt';
		//alert(brbuttid);
		if(document.getElementById(brbuttid)!=null){
			var ooX = getElementPosition(brbuttid).left;
			var ooY = getElementPosition(brbuttid).top;
		}
		//////////MAKE THE TABLE
		
		
		makePopTable(popDiv, poptable, dragBar,dragBarText, pcount, content_var, titlename, dynamic_height);
		//
		var popid = popDiv.id;
		var ttc = getElementPosition(popid+'closeButton').top;
		var llc = getElementPosition(popid+'closeButton').left;
		
		var closOverid = popid+'closeOver';
		
		var closOverObj = document.getElementById(closOverid);
			closOverObj.style.left = llc+'px';
			closOverObj.style.top = ttc+'px';
		///	
		var cancelbid = popid+'cancelb';
		
		var cancelbObj = document.getElementById(cancelbid);
			cancelbObj.style.left = llc-75+'px';
			cancelbObj.style.top = ttc+392+'px';
		///	
		var okbid = popid+'okb';
		
		var okbObj = document.getElementById(okbid);
			okbObj.style.left = llc-22+'px';
			okbObj.style.top = ttc+392+'px';		
		
		
			//alert(document.getElementById(brbuttid));
		////////////////////////////
		
		var origObj = document.getElementById(origId);
//		alert(popDiv.innerHTML);
//    fso = new ActiveXObject("Scripting.FileSystemObject");
//    fout = fso.CreateTextFile('aa.html', true);
//    fout.write(popDiv.innerHTML);
		//alert('buttX: '+xx+' , ButtY: '+yy+' , popX: '+popDiv.offsetLeft+' , popY:'+popDiv.offsetTop);
		//
		//renderTrail(dragBar, popDiv, xx, yy, pcount);
		move = true;
		allobj[pcount] = {orId:origId, oX:xx, oY:yy, pDiv:thisId, drbar:dragBar, trail:thisId+'contDiv', shade:thisId+'shadow', brbutti:brbuttid, clo:closOverid, cancelbi:cancelbid, okbi:okbid};
		pcount++;
		
		makeShadow(popDiv, popDivWidth, dynamic_height, yy+offsetYY+2, xx+offsetXX+2, zcounter);
		popDiv.style.zIndex = pcount + 6000;
		//moveShadow(popDiv);
		//shadeOffset += 2;
		
}
////////////////////////////////////////


function makeShadow(object, w, h, t, l, Z){
	var tt = 0;
	var ll = 0;
	var zz = 1;
	var shopp = 15;
	if(t!=null && l!=null){
	if(document.all){
	shadeOffset += shadowIncr;
//alert('shadow IE');
	var shadowContDiv = document.createElement("DIV");
		shadowContDiv.id = object.id+'shadow';
		shadowContDiv.style.position = 'absolute';
		shadowContDiv.style.left = 0+shadeOffset+'px';
		shadowContDiv.style.top = 6+shadeOffset+'px';
		shadowContDiv.style.height = h+'px';
		shadowContDiv.style.width = w+'px';
		shadowContDiv.style.border = '0px solid black';
		shadowContDiv.style.zIndex = (zz-1);
		shadowContDiv.className = 'shadowpng';
		//object
		object.appendChild(shadowContDiv);
		//document.body.appendChild(shadowContDiv);

	
		//var op = shopp;
		//shadowContDiv.style.filter='alpha(opacity = 80)'; 
		//shadowContDiv.style.filter='alpha(opacity = 30)'; 
	}else{
	shadeOffset += shadowIncr;
		var shadowContDiv = document.createElement("DIV");
			shadowContDiv.id = object.id+'shadow';
			shadowContDiv.style.position = 'absolute';
			shadowContDiv.style.left = 0+shadeOffset+'px';
			shadowContDiv.style.top = 1+shadeOffset+'px';
			shadowContDiv.style.height = h+'px';
			shadowContDiv.style.width = w+'px';
			shadowContDiv.style.border = '0px solid black';
			shadowContDiv.style.zIndex = (zz-1);
			shadowContDiv.className = 'shadowpng';
		//object
		object.appendChild(shadowContDiv);
		//document.body.appendChild(shadowContDiv);
		//var op = shopp/100;
		var shadowImg = document.createElement("IMG");
			shadowImg.id = object.id+'shadowIMG';
			shadowImg.src = 'welcome_images/shadow30.png';
			shadowImg.height = h+shadeOffset;
			shadowImg.width = w+shadeOffset;
			shadowContDiv.appendChild(shadowImg);
		//shadowContDiv.style.MozOpacity = 0.4; 
	}
	//shadowContDiv.appendChild(shadowImg);
	return(shadowContDiv);
	}
}

///////////////////////////////////////
function popup(obj, orig, content_var,titlename){
///make the popup objects here
	var sX = getElementPosition(orig.id).left-25;
	var sY = getElementPosition(orig.id).top+100;

	
	if(sY > 610)
	sY = 400;
		//sX += obj.offsetWidth-20;
		//
		var duplicate=false;
		for (var i=0;i<=popup_win.length;i++)
		{
			//alert(popup_win[i])
			//alert(titlename)
			//alert(popup_win[i]==titlename);
			if(popup_win[i]==titlename)
			{
				duplicate=true;
			}
		}
		
		if(duplicate==false)
		{
	    popup_win.push(titlename);
	    createpopObj(obj.id, sX, sY, content_var,titlename);
	  }
}
var pcount=0;
function makePopTable(popDiv, table, dragBar,dragBarText, ind, content_var, titlename, dynamic_height){
	var contHeight = 180;
	var contWidth = 250;
		//dragBar.width = contWidth;
		//alert('popcontentCont'+content_num);
	//var popcontentCont = document.getElementById('popcontentCont'+content_num); //.innerHTML
		// alert(popcontentCont.innerHTML);
		 
	var popcontentCont_bugtony_tr = document.createElement("TR");
	var popcontentCont_bugtony_td = document.createElement("TD");
	popcontentCont_bugtony_td.innerHTML = content_var;
	//popcontentCont_bugtony_td.appendChild(document.createTextNode(content_var));
	popcontentCont_bugtony_tr.appendChild(popcontentCont_bugtony_td);
	//alert(popcontentCont_bugtony_tr.innerHTML);
	
 	var newPopContent = popcontentCont_bugtony_td.cloneNode(true);
		newPopContent.style.display = '';
	//alert(dynamic_height);
	
	/////IMAGES/////////////
	var c1 = document.createElement("IMG");
		c1.src = 'welcome_images/subheader_corner_two_l.gif';
		c1.width = 4;
		c1.height = 20;
		
	var c2 = document.createElement("IMG");
		c2.src = 'welcome_images/subheader_corner_two_r.gif';
		c2.width = 4;
		c2.height = 20;

/*	var leftb = document.createElement("IMG");
		leftb.src = 'welcome_images/subheader_leftt_two.gif';
		leftb.width = 4;
		leftb.height = dynamic_height + (dynamic_height/10); 
		
		alert('dynamic height: ' + dynamic_height +'leftb: ' + leftb.height);*/
		//leftb.height = 1000; 
		
	/*var rightb = document.createElement("IMG");
		rightb.src = 'welcome_images/subheader_rigth_two.gif';
		rightb.width = 4;
		rightb.height = dynamic_height + (dynamic_height/10); */
		//rightb.height = 1000; 
		//alert(rightb.innerHTML);
		
		//alert(bottomline.innerHTML);
	var spacer1 = document.createElement("IMG");
		spacer1.src = 'welcome_images/spacer.gif';
		spacer1.width = 50;
		spacer1.height = 16;
	
	var spacer2 = document.createElement("IMG");
		spacer2.src = 'welcome_images/spacer.gif';	
		spacer2.width = 35;
		spacer2.height = 16;
		
	var closOver = document.createElement("DIV");
	var cancelb = document.createElement("DIV");	
	var okb = document.createElement("DIV");
			
	var closeb = document.createElement("IMG");
	var pid = popDiv.id;
		closeb.id = pid+'closeButton';
		closeb.src = 'welcome_images/closeDialog_coc_n.gif';
		closeb.width = 14;
		closeb.height = 20;
		//closeb.align = 'middle';
		closeb.style.cursor = 'pointer';
		closeb.style.zIndex = 1;
		closeb.style.position = 'absolute';
		closeb.style.left = 208+'px';
		closeb.style.top = 0+'px';
		
	closeb.onclick = function(){ 
			deleteAllPops(closOver, ind, titlename);
		};
	//MAKE DIV ON TOP THE CLOSE BUTTON
		
		var popid = popDiv.id;
		
			closOver.style.top = 0+'px';
			closOver.style.left = 0+'px';
			closOver.id = popid+'closeOver';
			closOver.style.position = 'absolute';
			closOver.style.width = 20+'px';
			closOver.style.height = 20+'px';
			closOver.style.zIndex = 1000;
			closOver.style.border = '0px solid #333333';
			//closOver.style.background = '#FFFFFF';
			closOver.style.visibility = 'visible';
			closOver.style.cursor = 'pointer';
			closOver.onclick = function(){ 
				
				deleteAllPops(closOver, ind,titlename);
				
			};
		document.body.appendChild(closOver);
		
		//MAKE DIV ON TOP THE CANCEL BUTTON
		
			cancelb.style.top = 0+'px';
			cancelb.style.left = 0+'px';
			cancelb.id = popid+'cancelb';
			cancelb.style.position = 'absolute';
			cancelb.style.width = 50+'px';
			cancelb.style.height = 16+'px';
			cancelb.style.zIndex = 1001;
			cancelb.style.border = '0px solid #333333';
			//cancelb.style.background = '#FFFFFF';
			cancelb.style.visibility = 'visible';
			cancelb.style.cursor = 'pointer';
			cancelb.onclick = function(){ 
				
				deleteAllPops(cancelb, ind,titlename);
				
			};

		
		//cancelb.appendChild(spacer1);
		document.body.appendChild(cancelb);
		
		//MAKE DIV ON TOP THE OK BUTTON
		
			okb.style.top = 0+'px';
			okb.style.left = 0+'px';
			okb.id = popid+'okb';
			okb.style.position = 'absolute';
			okb.style.width = 35+'px';
			okb.style.height = 16+'px';
			okb.style.zIndex = 1002;
			okb.style.border = '0px solid #333333';
			//okb.style.background = '#FFFFFF';
			okb.style.visibility = 'visible';
			okb.style.cursor = 'pointer';
			okb.onclick = function(){ 
				
				deleteAllPops(okb, ind,titlename);
				
			};
		//okb.appendChild(spacer2);
		document.body.appendChild(okb);		


	////////////////////////pop up button
	/* 
	var button = document.createElement("IMG");
		button.id = 'popbutt'+pcount;
		button.src = 'welcome_images/button.gif';
		button.style.cursor = 'pointer';
		button.width = 60;
		button.height = 16;

	button.onclick = function(){ 
			popup(dragBar, button); 
		};
	*/
			
	var tableBody = document.createElement("TBODY");
		
	var tr1 = document.createElement("TR");
		
	var td1 = document.createElement("TD");	
	var td2 = document.createElement("TD");
	var td3 = document.createElement("TD");
		
		
	var tr2 = document.createElement("TR");
	
	var td21 = document.createElement("TD");
	var td22 = document.createElement("TD");
	
	var string = 'Welcome!!!';
	//var dummytxt = document.createTextNode(string);
		//dummytxt.className = 'text';
	
		
	var td23 = document.createElement("TD");
		
		
	var tr3 = document.createElement("TR");
	
	var td31 = document.createElement("TD");
	var td32 = document.createElement("TD");
	var td33 = document.createElement("TD");
		
		td1.appendChild(c1);
		td2.appendChild(dragBar);
		td2.appendChild(dragBarText);
		td2.appendChild(closeb);
		td3.appendChild(c2);
		
		//td21.appendChild(leftb);
		//
		//td22.appendChild(button);
		//td22.appendChild(popcontentCont);newPopContent
		td22.appendChild(newPopContent);
		//alert(td22.innerHTML);
		//td22.innerHTML += popcontentCont;
//		var tableImgs = newPopContent.getElementsByTagName('IMG');
//		var popbutt;
//		for (var i = 0; i < tableImgs.length; i++){
//			if(tableImgs[i].name == 'brbutton'){
//				//alert(tabImgs[i].id);
//				popbutt = tableImgs[i];
//			}
//		}
//		popbutt.style.cursor = 'pointer';
//		popbutt.id = popid+'brbutt';
//		popbutt.onclick = function(){ 
//			popup(dragBar, popbutt); 
//		};
		//
		//td23.appendChild(rightb);
		
		//alert(1);
		//td31.appendChild(buttoml);
		//alert(td31.innerHTML);
	
		////////////////////////
		
		tr3.appendChild(td31);
		tr3.appendChild(td32);
		tr3.appendChild(td33);
		//alert(tr3.innerHTML);
		tr2.appendChild(td21);
		tr2.appendChild(td22);
		tr2.appendChild(td23);
		
		tr1.appendChild(td1);
		tr1.appendChild(td2);
		tr1.appendChild(td3);
		
		tableBody.appendChild(tr1);
		tableBody.appendChild(tr2);
		tableBody.appendChild(tr3);
		//alert(tableBody.innerHTML)
		table.appendChild(tableBody);
		
		td31.style.background = '#176891';
		td31.height = 1;
		td32.style.background = '#176891';
		td32.height = 1;
		td33.style.background = '#176891';
		td33.height = 1;
		
		td22.style.background = '#FFFFFF'; 
		td22.width = 218;
		td22.height = dynamic_height;
		td22.className = 'contTdclass';
		
		td21.style.backgroundImage = 'url(welcome_images/subheader_leftt_two.gif)';
		td21.width = 4;
		td22.height = dynamic_height;
		
		td23.style.backgroundImage = 'url(welcome_images/subheader_rigth_two.gif)';
		td23.width = 4;
		td23.height = dynamic_height;
		
	 	//alert(table.innerHTML)
		var thisid = table.id; 
		//alert(table.id);
		return(thisid);
		//pcount++;		
}

/////////////DELETING////////////////////

function deleteAnyPop(){
	
		var divid1;
		var trailid1;
		var shadowid1;
		
		alert(allobj.length);
		
		for(var aa=allobj.length-1; aa >= 0; aa--){
		
			alert('aa: '+aa);

			divid1 = allobj[aa].pDiv;
			trailid1 = allobj[aa].trail;
			shadowid1 = allobj[aa].shade;
			closeid1 = allobj[aa].clo;
			cancelid1 = allobj[aa].cancelbi;
			okid1 = allobj[aa].okbi;
			//alert(allobj);
			//cancelbi:cancelbid, okbi:okbid
			
			var divobj1 = document.getElementById(divid1);
			var trailobj1 = document.getElementById(trailid1);
			var shadowobj1 = document.getElementById(shadowid1);
			var closeobj1 = document.getElementById(closeid1);
			var cancelobj1 = document.getElementById(cancelid1);
			var okobj1 = document.getElementById(okid1);
			//alert(divobj+' , '+trailobj+' , '+shadowobj+' , '+pcount);
			//alert('length: '+allobj.length+' , ind: '+ind+' , pcount: '+pcount+' , divobj: '+divobj+' trailobj: '+trailobj+' closeobj: '+closeobj);
			document.body.removeChild(divobj1);
			document.body.removeChild(trailobj1);
			document.body.removeChild(closeobj1);
			document.body.removeChild(cancelobj1);
			document.body.removeChild(okobj1);
		///////////
			
		
		}
		
}

function deleteAllPops(closeOver, ind, titlename){

	
	for (var i=0;i<=popup_win.length;i++)
		{
			if(popup_win[i]==titlename)
			{
				popup_win.splice(i,1);
			}
		}
		
		var divid;
		var trailid;
		var shadowid;
		//var aa = ind;
		//
	for(var aa = ind; aa < allobj.length; aa++){
		
			//alert('aa: '+aa);
			//alert(allobj.length);
			
			divid = allobj[aa].pDiv;
			trailid = allobj[aa].trail;
			shadowid = allobj[aa].shade;
			closeid = allobj[aa].clo;
			cancelid = allobj[aa].cancelbi;
			okid = allobj[aa].okbi;
			//alert(allobj);
			//cancelbi:cancelbid, okbi:okbid
			
			var divobj = document.getElementById(divid);
			var trailobj = document.getElementById(trailid);
			var shadowobj = document.getElementById(shadowid);
			var closeobj = document.getElementById(closeid);
			var cancelobj = document.getElementById(cancelid);
			var okobj = document.getElementById(okid);
			//alert(divobj+' , '+trailobj+' , '+shadowobj+' , '+pcount);
			//alert('length: '+allobj.length+' , ind: '+ind+' , pcount: '+pcount+' , divobj: '+divobj+' trailobj: '+trailobj+' closeobj: '+closeobj);
			document.body.removeChild(divobj);
			document.body.removeChild(closeobj);
			document.body.removeChild(cancelobj);
			document.body.removeChild(okobj);
			document.body.removeChild(trailobj);
	
			alert('ind' + ind + 'now: ' + allobj.length);
			allobj.splice(ind, allobj.length);
			shadeOffset -= shadowIncr;
			pcount --;

		}


		//alert('now: ' + allobj.length);
		
		if(ind == 0){
			//alert('deleting array '+ ind);
			allobj.splice(0);
			pcount = 0;
		}
		if(pcount>0){
		
		}
		
	}
	
function deleteDrawnCones(){
	var trailid; //+1
	for(var aa = 0; aa < allobj.length; aa++){
			trailid = allobj[aa].trail;
			var trailobj = document.getElementById(trailid);
			if(trailobj!=null){
			
				document.body.removeChild(trailobj);
				//alert(trailobj.id);
			}
		}
		allCones.splice(0);
		a = 0;
		//alert('deleting cones length: '+allCones.length);
		redrawCones();
		//alert('new length: '+allCones.length);
	}
function redrawCones(){

	for(var t = 0; t < allobj.length; t++){ //pcount
			
			var startid = allobj[t].orId;
			if(startid == 'subButt'){	
				var startX = getElementPosition(startid).left;
				var startY = getElementPosition(startid).top;
				//alert(startid+' , '+startX+' , '+startY);
			}else if(document.all){
				var startX = getElementPosition(startid).left+215;
				var startY = getElementPosition(startid).top+198;
			}else{
				var startX = getElementPosition(startid).left+209;
				var startY = getElementPosition(startid).top+192;
			}
			var divObj = document.getElementById(allobj[t].pDiv);
			var zind = divObj.style.zIndex;
			//alert('o: '+origId+' sX: '+startX+' sY: '+startY+' Drag Bar: '+allobj[t].brbutti);
			renderTrail(allobj[t].drbar, divObj, startX, startY, zind-1);
		}
		/**/
}		
	///////////////////SLIDER////////////////////////knobId, railId
function getColors(){
	var colorFillObj = document.getElementById('hexColor');
		colorFillObj.style.background = coneColor;
	var colorNameObj = document.getElementById('colordisplay');
		colorNameObj.value = coneColor;
}
	
function positionKnob(){
var alldivs = document.getElementsByTagName('DIV');
	for(var im = 0; im < alldivs.length; im++){
		if(alldivs[im].className == 'slider'){
			
			var knob = alldivs[im];
			var knobId = alldivs[im].id;
			var railId = alldivs[im].firstChild.name+'WrapRail';
			//alert(railId);
			
			posSliders(railId, knobId);
			getColors();
		}
	}
}	
function posSliders(railid, knobId)	{
	var railY = getElementPosition(railid).top;
	var railX = getElementPosition(railid).left;
	var knobObj = document.getElementById(knobId);
	var railObj = document.getElementById(railid);
	var knobWidth = knobObj.style.width;
	var range = railObj.offsetWidth;
	
	if(knobObj.id == 'transparencyWrap'){
			if(coneopp != null || coneopp != 'undefined'){
					knobObj.style.left = railX+'px';
					knobObj.style.top = railY-5+'px';
					
				var onePerc = range/100; 
				var	pixelP = Math.round((coneopp*3)*onePerc);
					knobObj.style.left = knobObj.offsetLeft+pixelP+'px';
					
					var parentname = knobObj.firstChild.name;
					document.getElementById(parentname+'display').value = coneopp+'%';
			}else{
				knobObj.style.left = railX+'px';
				knobObj.style.top = railY-5+'px';
			}
		}else if(knobObj.id == 'conesWrap'){
			if(coneMemebers != 'undefined' ){
					knobObj.style.left = railX+'px';
					knobObj.style.top = railY-5+'px';
					
				var onePerc = Math.round(range/100);
				var	pixelP = coneMemebers*onePerc;
					knobObj.style.left = knobObj.offsetLeft+pixelP+'px';
					
					var parentname = knobObj.firstChild.name;
					document.getElementById(parentname+'display').value = '#'+coneMemebers;
			}else{
				knobObj.style.left = railX+'px';
				knobObj.style.top = railY-5+'px';
			}
		}
	}
function applytranparency(percent){
	coneopp = percent;
	//alert(allCones.length);
	for (var o =0; o < allCones.length; o++){
		var dobj = allCones[o].oo;
		opaque(dobj); 
	}
}
//////////////////COLOR PICKER///////////////////////////
function applynewcolor(col){
	//alert(col);
	for (var o =0; o < allCones.length; o++){
		var dobj = allCones[o].oo;
			dobj.style.background = col; 
	}
}
var cc = 0;
var mainDiv;

function makeColTable(origObj){

	var origObjId = origObj.id;
	var origX = getElementPosition(origObjId).left;
	var origY = getElementPosition(origObjId).top;
	
	var clr = new Array('00','33','66','99','CC','FF');
	var allcolors = new Array();
		mainDiv = document.createElement('DIV');
		mainDiv.id = 'colorpickerDiv';
		mainDiv.style.position='absolute'; 
		mainDiv.style.border="1px solid #333333";
		mainDiv.style.background = '#FFFFFF';
		mainDiv.style.zIndex = zcounter+200;
		
		mainDiv.style.width = (18*15)+6+'px';
		mainDiv.style.height = (12*15)+42+'px';
		var mdh = (12*15)+42;
		mainDiv.style.left = origX+'px';
		mainDiv.style.top = (origY-mdh)-5+'px';
		
		
		document.body.appendChild(mainDiv);
		var currentColor;
		/**/
		var hh = 20;
		var ll = 0;	
			for(k=0;k<6;++k){
			
				for(j=0;j<6;){
				hh += 15;
				ll = 0;
					for(m=0;m<3;++m){
					
						for(i=0;i<6;++i){
						//
						
							var dv = document.createElement('DIV');
								dv.style.position='absolute'; 
								dv.style.width = 15+'px'; 
								dv.style.height = 15+'px';
								//dv.style.top=cc*30+'px';
								//if(i > 18){
									//
								//}
								dv.style.top = hh+'px';
								dv.style.left = ll+'px';
								
								dv.className="copy";
								dv.style.border="3px solid #FFFFFF";
								dv.style.background='#'+clr[k]+clr[j+m]+clr[i];
								dv.style.cursor = 'pointer';
								
								allcolors[cc] = {indx:cc, hex:'#'+clr[k]+clr[j+m]+clr[i]};
								
								var pdv;
								dv.onmouseover = function(){
									currentColor = this.style.backgroundColor;
										pdv = document.createElement('DIV');
										pdv.style.position='absolute';
										pdv.style.width = 110+'px'; 
										pdv.style.height = 15+'px';
										pdv.style.top = 2+'px';
										pdv.style.left = 20+'px';
										pdv.className="copy";
										pdv.style.background = '#FFFFFF';
										pdv.style.border="1px solid #333333";
										
										cdv = document.createElement('DIV');
										cdv.style.position='absolute';
										cdv.style.width = 50+'px'; 
										cdv.style.height = 15+'px';
										cdv.style.top = 2+'px';
										cdv.style.left = 24+110+'px';
										cdv.className="copy";
										cdv.style.background = this.style.backgroundColor;
										cdv.style.border="1px solid #333333";
										
									var txt = document.createTextNode(currentColor);
									pdv.appendChild(txt);
									mainDiv.appendChild(pdv);
									mainDiv.appendChild(cdv);
								};
								dv.onmouseout = function(){
									mainDiv.removeChild(pdv);
									mainDiv.removeChild(cdv);
								};
								dv.onclick = function(){
									currentColor = this.style.backgroundColor;
									//alert(currentColor);
									recolorCones(currentColor);
									//document.body.removeChild(pdv);
									//
									
								};
								mainDiv.appendChild(dv);
								cc++;
								ll += 15;
							}
						}
						
				j+=3;
				
			}
			
		}
		
	}
	function recolorCones(color){
		//var cone = document.getElementById('cone');
		//alert(color+' , '+mainDiv.id);
		applynewcolor(color);
			var MDiv = document.getElementById('colorpickerDiv');
			var colordisplay = document.getElementById('colordisplay');
			var hexColor = document.getElementById('hexColor');
			colordisplay.value = color;
			coneColor = color;
			hexColor.style.background = color;
			document.body.removeChild(MDiv);
			
	}
	/////////////////SET CONE MEMBERS////////////////////////
	
	function applycones(perc){
		//alert(perc);
		coneMemebers = perc;
	
	}
	
//-->
