var	RelIconPath = '../LinkImages';
var	WebIconPath =	'http://www.txtit2me.com.au/LinkImages/';
var WebSendPath = 'http://www.txtit2me.com.au/web/cgi-bin/sendtxt.cgi';
var WebJSPath = 'javascript:txtit2me(';
var WebJSIncl = "<script src='http://www.txtit2me.com.au/_Site_js/txtit2me.js' ></script>\r\r";

var ALLPages = new Array('Home', 'Message', 'Display', 'Partners', 'Instruct');
var PageInit = new Array(null, Step1Load, Step2Load, Step3Load, Step4Load);
var PageFlow = ALLPages;
var CurrPage=0;
var	Loops = 0;
var HelpActivePage = '';

function GetClass(xi_Class) 
{ 
	var	sheet;
	var	rules;
	var	rule;
	var	target = xi_Class.toLowerCase();
	//alert("Got sheets " + document.styleSheets.length);
	for(var s = 0; s < document.styleSheets.length; s++)
	{
		sheet = document.styleSheets[s];
		rules = (sheet.rules) ? sheet.rules : sheet.cssRules; // IE others
		//rules = sheet.rules; // IE others
		for(var r=0;r<rules.length;r++)
		{
			//alert(rules[r].selectorText);
			if(rules[r].selectorText.toLowerCase() == target) 
				return rules[r].style 
		}
	}
	return null; 
}

function SourceObject(xi_this)
{
	if(window.event)
		return window.event.srcElement;
	else
		return xi_this;
}

function copy2clip(xi_text2copy)
{
  	if (window.clipboardData)
 	{	    
 	    window.clipboardData.setData("Text", xi_text2copy);
  	}
  	else 
 	{
 	    var flashcopier = 'flashcopier';
	    if (!document.getElementById(flashcopier)) 
	    {
	      var divholder = document.createElement('div');
	      divholder.id = flashcopier;
	      document.body.appendChild(divholder);
	    }
	    document.getElementById(flashcopier).innerHTML = '';
	    var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+escape(xi_text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
	    document.getElementById(flashcopier).innerHTML = divinfo;
	 }
  	document.getElementById('i_LinkCopied').src= 'img/Graphics/LinkCopiedOn.gif';
}		


function ShowFloat(xiPage)
{
	document.getElementById('div_'+xiPage).style.display='';
}

function HideFloat(xiPage)
{
	document.getElementById('div_'+xiPage).style.display='none';
}

function NextPage()
{
	if ( PageFlow[CurrPage] == 'Home' )
		O3_FadeOpacity('BannerEnd',1,500)	
	if(++CurrPage >= ALLPages.length)
	{
		CurrPage = 1;
		Loops++;
	}
	if(PageInit[CurrPage]) PageInit[CurrPage]();
	ShowPage(PageFlow[CurrPage]);
	
}

function PrevPage()
{
	if((CurrPage == 1) && (Loops > 0))
	{
		CurrPage = ALLPages.length;
		Loops--;
	}
	CurrPage--;
	if(PageInit[CurrPage]) PageInit[CurrPage]();
	ShowPage(PageFlow[CurrPage]);
	if ( PageFlow[CurrPage] == 'Home' )
		O3_FadeOpacity('BannerEnd',0,500)
}


function ShowLink(xi_step) 
{
    var PreviewLink_obj = document.getElementById("PreviewLink" + xi_step);
	
	if (document.getElementById("TextLocn").value == "AFTER")
	    PreviewLink_obj.innerHTML = '<img id="PreviewImage' + xi_step + '" style="border:0px" src="../_T2M_img/Graphics/clear_pix.gif" alt="Preview Link Logo" /><span id="PreviewText' + xi_step + '"></span>';
	else
	    PreviewLink_obj.innerHTML = '<span id="PreviewText' + xi_step + '"></span><img id="PreviewImage' + xi_step + '" style="border:0px" src="../_T2M_img/Graphics/clear_pix.gif" alt="Preview Link Logo" />';

	var PreviewImage_obj = document.getElementById("PreviewImage" + xi_step);
	var PreviewText_obj = document.getElementById("PreviewText" + xi_step);


	if(O3_RadioValue('WizardForm', 'UseIcon') != 'No')
		PreviewImage_obj.style.visibility = 'visible';
	else
		PreviewImage_obj.style.visibility = 'hidden';

	PreviewImage_obj.src = RelIconPath + '/' + document.getElementById("IconImage").value;
	IconShowAlign("PreviewImage" + xi_step);
	
	if(O3_RadioValue('WizardForm', 'UseText') != 'No')
		PreviewText_obj.style.visibility = 'visible';
	else
		PreviewText_obj.style.visibility = 'hidden';
    
	TextShowText("PreviewText" + xi_step);
	TextShowFormat("PreviewText" + xi_step);
	TextShowFont("PreviewText" + xi_step);
	TextShowColour("PreviewText" + xi_step);
}
function IconShowAlign(xi_id) {
    document.getElementById(xi_id).style.verticalAlign = document.getElementById("IconAlign").value;
}

function TextShowText(xi_id)
{
	document.getElementById(xi_id).innerHTML = document.getElementById("InputText").value;
}

function TextShowFont(xi_id)
{
	document.getElementById(xi_id).style.fontFamily = document.getElementById("InputFont").value;
}

function TextShowColour(xi_id)
{
	document.getElementById(xi_id).style.color = document.getElementById("InputColour").value;
}


function TextShowFormat(xi_id)
{
	var PreviewText_obj = document.getElementById(xi_id);
	var	value;
	
	value = O3_RadioValue('WizardForm', 'FontWeight');
	if(value == 'default')
		value = '';
	PreviewText_obj.style.fontWeight = value;
	
	value = O3_RadioValue('WizardForm', 'FontStyle');
	if(value == 'default')
		value = '';
	PreviewText_obj.style.fontStyle = value;
	document.getElementById("PaneTextFont").style.fontStyle = value;
	
	value = O3_RadioValue('WizardForm', 'TextDec');
	if(value == 'default')
		value = '';
	PreviewText_obj.style.textDecoration = value;
	document.getElementById("FontTable").className = 'FontPicker ' + value; //workaround

	value = O3_RadioValue('WizardForm', 'FontSizeSpec');
	if(value == 'default')
		value = '';
	else
		value = document.getElementById("FontSize").value + document.getElementById("FontUnit").value;
	
	PreviewText_obj.style.fontSize = value;

}


function HelpShowPage(xiPage) {

    if (HelpActivePage != "") {
        HelpHidePage(ActivePage);
    }

    HelpActivePage = xiPage;
    DisPage();
    document.getElementById('div_' + xiPage).style.display = '';
}

function HelpHidePage(xiPage, xi_Blur) {
    document.getElementById('div_' + xiPage).style.display = 'none';
    EnPage();
    HelpActivePage = "";
}

function PartnerChoice() {
    if (document.getElementById('PartnerYes').checked == true) 
    {
        document.getElementById('SupporterInput').style.display = '';
        document.getElementById('SupplierIDInput').style.display = '';

        if (document.getElementById('SupporterYes').checked == true)
            document.getElementById('SupporterIDInput').style.display = '';
        else {
            document.getElementById('SupporterID').value = '';
            document.getElementById('SupporterIDInput').style.display = 'none';
        }
    }
    else 
    {
        document.getElementById('SupplierIDInput').style.display = 'none';
        document.getElementById('SupporterIDInput').style.display = 'none';

        document.getElementById('SupporterInput').style.display = 'none';
    }
  }

