//this javascript file contains functions that may be useful to all of the instant web templates
//include this file after the <body> tag, with this syntax:
// <script language="javascript" src="basicfuncs.js"></script>

function dontgo (pagestring) {

	//	if (confirm("Are you sure you want to leave this page? You will lose your changes if you haven't saved them. To save your changes click Cancel and click on the Save Changes button")) {
	//	this.document.location.href = pagestring;
	//	} else {
			
	//	}
	
	}

	function dontgo_close(pagestring) {
		//opener.document.location.href = pagestring;
		
			if (confirm(dontgoconfirm)) {
			
				this.close();
				
			}
		

	}


function wait_screen () {
		document.all.waitframe.width= 400;
		document.all.waitframe.height = 150;
		document.all.waitframe.align = 'center';
		document.all.waitframe.style.bgColor = "transparent";
		document.all.waitframe.allowtransparency = true;	

}

// and create the iframe that will show this wait screen:

var waitFrame = document.createElement("IFRAME");
waitFrame.width = 0;
waitFrame.height =0;
waitFrame.src = '/editor/waitscreen.cfm';
waitFrame.id = 'waitframe';
waitFrame.style.position = 'absolute';
waitFrame.style.top = '220px';
waitFrame.style.left = '150px';
waitFrame.style.zIndex = 10;


if (document.body != null)
{


document.body.appendChild(waitFrame);

}




	function logobuilder () {
		
		document.all.LogoBuilder.width= 750;
		document.all.LogoBuilder.height = 400;
		document.submitlogo.submit();
//move the logo builder if it's obscuring something:
		if (parent.spacer && top.spacer != 'undefined')
		{
			parent.spacer.height=100;
		}
		document.all.LogoBuilder.style.bgColor = "transparent";
		document.all.LogoBuilder.allowtransparency = true;	
	}

	function logobuilder2 () {	
		document.submitlogo.submit();
	}
	

	function logochooser () {
		document.all.LogoBuilder.src= 'ChooseLogo.cfm';
		document.all.LogoBuilder.width= 650;
		document.all.LogoBuilder.height = 450;
		document.all.LogoBuilder.style.bgColor = "transparent";
		document.all.LogoBuilder.allowtransparency = true;	
	}
	
	function homeimagechooser () {
		document.all.LogoBuilder.src= 'ChooseHomeImage.cfm';
		document.all.LogoBuilder.width= 490;
		document.all.LogoBuilder.height = 400;
		document.all.LogoBuilder.style.bgColor = "transparent";
		document.all.LogoBuilder.allowtransparency = true;	
	}
	
function homeimageuploader () {
		document.all.LogoBuilder.src= 'viewimages.cfm?addhomeimage=1';
		document.all.LogoBuilder.width= 575;
		document.all.LogoBuilder.height = 300;
		document.all.LogoBuilder.style.bgColor = "transparent";
		document.all.LogoBuilder.allowtransparency = true;	
	}
	


function homeimagechooser2 () {
	document.all.LogoBuilder.src= 'ChooseHomeImage.cfm';
		document.all.LogoBuilder.width= 600;
		document.all.LogoBuilder.height = 400;
		document.all.LogoBuilder.style.bgColor = "transparent";
		document.all.LogoBuilder.allowtransparency = true;	
	}

	function backgroundimagechooser (type) {
	document.all.LogoBuilder.src= 'ChooseHomeImage.cfm?type=' + type;
		document.all.LogoBuilder.width= 490;
		document.all.LogoBuilder.height = 400;
		document.all.LogoBuilder.style.bgColor = "transparent";
		document.all.LogoBuilder.allowtransparency = true;	
	}


function buildstylesheet2 (from) {

//lastsheet was set in the main page, to tell us which stylesheets to submit to the database.

if (!from)
{
	//if(htmlonly)
		from = top.document.frames('mainFrame').document;
	//else
		//from = opener;
	//from =document;
}

var strstylesheet = " ";
for (h=0;h <= 2 ; ++h ) {
	strstylesheet += "<style>\n";
	for (k=0;k < from.styleSheets(h).rules.length; ++k)
	{
		strstylesheet += from.styleSheets(h).rules(k).selectorText + '{';	
		for (var i in from.styleSheets(h).rules(k).style) {
        
			if ( from.styleSheets(h).rules(k).style[i] != "" && i != 'cssText')
			{
				var repl;
				if (i == "scrollbar3dLightColor")
				{
					repl = "scrollbar-3dLight-Color";
				} 
				else if (i == "scrollbarDarkShadowColor")
				{
					repl = "scrollbar-DarkShadow-Color";
				}
				else {
				repl = i.replace(/([a-z])([A-Z])/g,"$1-$2");
				}
				strstylesheet = strstylesheet + repl +':' + from.styleSheets(h).rules(k).style[i] + ';';
					
			}
		}
		strstylesheet = strstylesheet + "}\n";
	}
var t = strstylesheet.replace(/#/g,'');
strstylesheet = t;
strstylesheet += "</style>\n";

}
top.document.frames('mainFrame').document.all.strStyleSheet.value = strstylesheet;
//top.document.all.strStyleSheet.value = strstylesheet;
//if (typeof(waitFrame) != 'undefined')
//{
//	wait_screen();
//}
}

function buildstylesheet (from) {

//lastsheet was set in the main page, to tell us which stylesheets to submit to the database.

if (!from)
{
	from = document;
}

var strstylesheet = " ";

for (h=0;h <= 3 ; ++h ) {
if (h==2)
from =document.frames('blogframe').document;
if (h > 2)
from=document;

strstylesheet += "<style>\n";

	for (k=0;k < from.styleSheets(h).rules.length; ++k)
	{
		
		strstylesheet += from.styleSheets(h).rules(k).selectorText + '{';	

		for (var i in from.styleSheets(h).rules(k).style) {
        
if ( from.styleSheets(h).rules(k).style[i] != "" && i != 'cssText')
			{
				var repl;
				if (i == "scrollbar3dLightColor")
				{
					repl = "scrollbar-3dLight-Color";
				} 
				else if (i == "scrollbarDarkShadowColor")
				{
					repl = "scrollbar-DarkShadow-Color";
				}
				else {
				repl = i.replace(/([a-z])([A-Z])/g,"$1-$2");
				}
				strstylesheet = strstylesheet + repl +':' + from.styleSheets(h).rules(k).style[i] + ';';
					
			}
		}
		strstylesheet = strstylesheet + "}\n";
	}
var t = strstylesheet.replace(/#/g,'');
strstylesheet = t;
strstylesheet += "</style>\n";

}

from.all.strStyleSheet.value = strstylesheet;

//if (typeof(top.waitFrame) != 'undefined')
//{
	//top.wait_screen();
//}
} 
//end of buildstylesheet

function inheritStyleSheets (pops) {
//'pops' is the page to inherit the stylesheets from
	var m = 'accelerator:false';
	
	for (var i = 0; i <= pops.document.styleSheets.length - 1; ++i) 
	{
		for (var j=0; j <= pops.document.styleSheets(i).rules.length -1; ++j)
		{
			if (pops.document.styleSheets(i).rules(j).selectorText)
			{
				document.styleSheets(i).addRule(pops.document.styleSheets(i).rules(j).selectorText, m);
				for (var k in pops.document.styleSheets(i).rules(j).style) 
				{
	        		if (pops.document.styleSheets(i).rules(j).style[k] != "" && k != 'cssText')
					{
						document.styleSheets(i).rules(j).style[k] = pops.document.styleSheets(i).rules(j).style[k];
					}
				}
			}
		}
	}

}


//this function used  by blog-only sites:
function mode1 () {

//no editing, blog mode
if (document.all.blognow)
{
document.all.blognow.style.visibility = 'visible'
}
//no editing, blog mode
	document.all.advdesign.onclick = mode2;
	document.all.advdesign.value = advanceddesign;
	//document.all.floater.style.visibility = 'hidden';
	//if (document.all.floater)
	//{
			//document.all.floater.style.visibility = 'hidden';

	//}
	
	

}

function mode2 () {
	
//no editing, blog mode
//document.all.floater.style.visibility = 'visible'
//no editing, blog mode

	document.all.advdesign.onclick = mode1;
	if (!seepage)
	{
	
		document.all.advdesign.value = seepage;
	} else {
		document.all.advdesign.value = seepage;
	}
	
}










