﻿/*
Page Author				: Stefan Kruger
Page Created Date		: 09-Sep-2009
Page Modification Log	:
Person:							Date:		Description:
------------------------------------------------------------------------------------------------------
Stefan Kruger					09-Sep-2009	Created file

To Do:
------
*/
var EAFramework = {};
EAFramework.includedJavascript = new Array();
EAFramework.contentDivisionArray = new Array();

function handleError(message){
    alert("Error occured : " + message);
}

function handleException(ex,source,sourceSub){
    alert("Exception occured : " + source + " - " + sourceSub + ".\n" + ex.message);
}

function parseJSON(JSON){
    try {
        return eval("(" + JSON + ")");
        //return YAHOO.lang.JSON.parse(JSON);
    }
    catch(ex){
        handleException(ex,"parseJSON","Main");
    }
    return null;
}

var displayContent = function(data,loadIn,postLoad,extendedData){
    try {
        document.getElementById(loadIn).innerHTML = data;
        try {
            eval(postLoad);
        }
        catch (ex){
            handleException(ex,"loadContent","Postload");
        }
    }
    catch (ex){
        handleException(ex,"displayContent","Main");
    }
}

var loadPage = function(data,loadIn,postLoad,extendedData,historyObject){
    var pageObj = parseJSON(data);
    if (pageObj) {
        if (pageObj.status == "OK"){
            //Page title
            try {
                document.title = "Rage Nutrition - " + pageObj.pagename;
            }
            catch(ex){
                handleError("Page title update failed.\nSource: [loadPage]");
		    }
		    //History management
		    if (historyObject) {
		        historyObject.pageName = pageObj.pagename;
                $.history(historyObject);
                //Threadbar management
                saveThreadbarInfo(historyObject);
            }
            //Page preload
		    try {
			    if (pageObj.pagepreload){
				    eval(pageObj.pagepreload);
			    }
		    }
		    catch (ex) {
			    handleError("Page preload failed.\nSource: [loadPage]\nTried: " + pageObj.pagepreload + "\nError:" + ex.message);
		    }
		    //Process needed Javascript includes
		    if (pageObj.javascriptincludes) {
			    for(var i = 0; i < pageObj.javascriptincludes.length; i++){
				    includeJavascript(pageObj.javascriptincludes[i].javascriptincludepath,false);
			    }
		    }
		    //Process individual loads for this page
		    if (pageObj.content) {
			    for(var j = 0; j < pageObj.content.length; j++){
			        //Display loadIn
			        manageDisplayWindow(pageObj.content[j].layoutdestination,"show");
			        //Process content item
			        if (pageObj.content[j].componenttypeid == 1){
			            var frameworkData = "framework_componentid=" + pageObj.content[j].componentid + "&framework_componenttypeid=" + pageObj.content[j].componenttypeid;
			            if (extendedData){
			                frameworkData += "&" + extendedData;
			            }
			            //alert(frameworkData);
				        ajaxRequest(pageObj.content[j].componenturl,frameworkData,pageObj.content[j].componentpreload,pageObj.content[j].componentpostload,displayContent,pageObj.content[j].layoutdestination,null);
			        }
			        else if (pageObj.content[j].componenttypeid == 2){
			            //alert("Grid component load definition needed...");
			            createGrid(pageObj.content[j].componentid,pageObj.content[j].layoutdestination,pageObj.content[j].componentname,pageObj.content[j].componenttitle);
			        }
			        else if (pageObj.content[j].componenttypeid == 3){
			            alert("Form component load definition needed...");
			        }
			        else if (pageObj.content[j].componenttypeid == 4){
			            displayContent(pageObj.content[j].componentcmscontent,pageObj.content[j].layoutdestination,pageObj.content[j].componentpostload,frameworkData);
			        }
			        else {
			            handleError("Component type load definition not found.\nSource: [loadPage]");
			        }
			    }
		    }
		}
		else {
		    handleError("AJAX page load reported the following status:\n" + pageObj.status);
		}
    }
    else {
        handleError("AJAX page load returned no data.");
    }
}

var executeAction = function(data,loadIn,postLoad,extendedData){
    //alert(data);
    var actionObj = parseJSON(data);
    if (actionObj) {
        if (actionObj.status == "OK"){
            //Acttion preload
		    try {
			    if (actionObj.actionpreloadjs){
				    eval(actionObj.actionpreloadjs);
			    }
		    }
		    catch (ex) {
			    handleError("Action preload failed.\nSource: [executeAction]\nTried: " + actionObj.actionpreloadjs + "\nError:" + ex.message);
		    }
		    //Page load
		    try {
			    if (actionObj.uniquepageid){
			        getPage(actionObj.uniquepageid,extendedData,actionObj.skiphistorywrite);
			    }
		    }
		    catch (ex) {
			    handleError("Action page load failed.\nSource: [executeAction]\nError:" + ex.message);
		    }
		}
		else {
		    handleError("AJAX page load reported the following status:\n" + actionObj.status);
		}
    }
    else {
        handleError("AJAX action load returned no data.");
    }
}

function getAction(actionname,componentid,extendedData){
    //Fetch action
    //alert("actionname:" + actionname + "\ncomponentid:" + componentid + "\nextendedData:" + extendedData);
    var page = "/frameworkjsonprovider.aspx";
    var data = "action=getactionjson&actionname=" + actionname + "&componentid=" + componentid;
    ajaxRequest(page,data,null,null,executeAction,null,extendedData);
}

function getPage(id,extendedData,skipHistoryWrite){
    if (id) {
        //Clearing variables
        //ClearVariables();
        //alert("getPage:" + id);
        var historyObject = null;
        //alert(skipHistoryWrite);
        if (!(skipHistoryWrite)) {
            historyObject = {"uniqueid" : id,"extendedData" : extendedData}
            //alert("saving history id : " + historyObject.uniqueid + "\nwith data : " + historyObject.extendedData);
        }
        var page = "/frameworkjsonprovider.aspx";
        var data = "action=getpagejson&uniqueid=" + id;
        ajaxRequest(page,data,null,null,loadPage,null,extendedData,historyObject);
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////
//THREADBAR HANDLING
//////////////////////////////////////////////////////////////////////////////////////////////
var threadBarContents = new Array();

function saveThreadbarInfo(historyObject){
    //Add new object
    threadBarContents.push(historyObject);
    //Remove first item if length > 4
    if (threadBarContents.length > 4) {
        threadBarContents.shift();
    }
    updateThreadbarDisplay();
}

function updateThreadbarDisplay(){
    //alert("updating threadbar...");
    window.setTimeout(function(){
        try {
            var outputContent = "";
            for (var i=0; i < threadBarContents.length;i++){
                //alert(threadBarContents[i].pageName);
                outputContent += "<div class=\"float_left\"><a id=\"" + threadBarContents[i].uniqueid + "\" class=\"button_threadbar threadbarajax\" href=\"/home\"><span>" + threadBarContents[i].pageName + "</span></a></div>";
            }
            outputContent += "<div class=\"theplug\"></div>";
            $(document.getElementById("threadbarContainer")).html(outputContent);
            initialiseThreadbarAjax();
        }
        catch(ex) {
            handleException(ex,"updateThreadbarDisplay","Timeout");
        }
    },0);
}

//////////////////////////////////////////////////////////////////////////////////////////////
//FORM INPUT HANDLING
//////////////////////////////////////////////////////////////////////////////////////////////
/*
A generalised form submitting function that returns the contents of a form in URL querystring
jQuery serialize() method could be a replacement for this.
*/
function extractFormData(formToProcess){
	var theform;
	if (formToProcess){
		theform = document.getElementById(formToProcess);
	}
	else {
		theform = null;
	}
	
	var queryString = "";
	var addString = "";
	if (theform){
		try {
			for (var i = 0; i < theform.elements.length; i++){
				if (queryString == ""){
					addString = "";
				}
				else {
					addString = "&";
				}
				if (theform.elements[i].type == "radio"){
					if (theform.elements[i].checked){
						addString += theform.elements[i].name + "=" + encodeURIComponent(theform.elements[i].value);
					}
				}
				else {
					if (theform.elements[i].type == "checkbox"){
						if (theform.elements[i].checked){
							addString += theform.elements[i].name + "=" + 1;
						}
						else {
							addString += theform.elements[i].name + "=" + 0;
						}
					}
					else {
						if (theform.elements[i].type == "select-multiple"){
							for (j = 0; j < theform.elements[i].options.length; j++){
								if (theform.elements[i].options[j].selected){
									if (addString != "" && addString != "&"){
										addString += "&";
									}
									addString += theform.elements[i].name + "=" + encodeURIComponent(theform.elements[i].options[j].value);
								}
							}
						}
						else {
							//Meaning : Hidden, Text or Single-Select : All treated equally without discrimination... :-)
							if (typeof(theform.elements[i].value) != 'undefined' && theform.elements[i].value != null){
							    if(theform.elements[i].type != 'button'){ 
							        //alert(theform.elements[i].type + ': ' + theform.elements[i].id + ': '  + theform.elements[i].value);
							        addString += theform.elements[i].name + "=" + encodeURIComponent(theform.elements[i].value);
							    }
							}
						}
					}
				}
				if (addString != "&"){
					queryString += addString;
				}
			}
		}
		catch (ex){
		    handleError("Error occured processing input form '" + formToProcess + "'.\nSource: [fetchInputFormData].\nDetail: " + ex.message);
		}
	}
	else {
		//alert("Invalid input form specified.");
	}
	//alert(queryString);
	theform = null;
	return queryString;
}

//////////////////////////////////////////////////////////////////////////////////////////////
//DYNAMIC JAVASCRIPT INCLUSION
//////////////////////////////////////////////////////////////////////////////////////////////
function initialiseLoadedJavascript(loadedScripts){
    try {
        var scriptObj = parseJSON(loadedScripts);
        if (scriptObj.scripts){
            for (var i = 0;i< scriptObj.scripts.length; i++){
                includeJavascript(scriptObj.scripts[i],true);
            }
        }
    }
    catch(ex){
        handleError("Error occured processing initially loaded Javascript .\nSource: [initialiseLoadedJavascript].\nDetail: " + ex.message);
    }
}

function checkIncludedJavascript(scriptSource) {
	if (EAFramework.includedJavascript){
		for (var i=0;i < EAFramework.includedJavascript.length;i++){
			if (EAFramework.includedJavascript[i] == scriptSource){
				return true;
			}
		}
	}
	return false;
}

function includeJavascript(scriptSource,addToCollectionWithoutIncluding){
	if (scriptSource.toString().length > 0){
		if (!(checkIncludedJavascript(scriptSource))){
			//Include this script
			EAFramework.includedJavascript.push(scriptSource);
			if (!(addToCollectionWithoutIncluding)){
			    var script = document.createElement("script");
			    script.type = "text/javascript";
			    script.src = scriptSource;
			    document.getElementsByTagName("head")[0].appendChild(script);
			    //alert('Loaded "' + scriptSource +'".');
			}
		}
		else {
			//alert('Script "' + scriptSource +'" is already loaded. Skipping...');
		}
	}
	else {
		handleError("No Javascript file was specified to include.\nSource: [includeJavascript]");
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////
//WINDOW MANAGEMENT
//////////////////////////////////////////////////////////////////////////////////////////////
/*
General display management function
*/
function manageDisplayWindow(objToProcess,manageModifier){
	var thediv = document.getElementById(objToProcess);
	if (thediv){
		if (manageModifier == "show"){
			thediv.style.display = "block";
		}
		if (manageModifier == "hide"){
			thediv.style.display = "none";
		}
		if (manageModifier == "close"){
			thediv.innerText = "";
			manageDisplayWindow(objToProcess,"hide");
		}
		if (manageModifier == "toggle"){
			if (thediv.style.display == "none"){
				thediv.style.display = "block";
			}
			else {
				thediv.style.display = "none";
			}
		}
	}
	else {
		handleError("Division '" + objToProcess + "' was not found in the page.\nSource: [manageDisplayWindow]");
	}
	//thediv = null;
}

function initialiseContent(contentArray){
    //alert(contentArray);
    try {
        EAFramework.contentDivisionArray = parseJSON(contentArray);
    }
    catch(ex){
        handleException(ex,"initialiseContent","Main")
    }
}
/*
A function to hide and clear the regular content display.
*/
function contentHider(){
	//Clear content divisions
	try {
		var useArray = EAFramework.contentDivisionArray;
		for (var i=0;i<useArray.length;i++){
			//alert(useArray[i].division);
			if (useArray[i].allowcontenthide) {
				manageDisplayWindow(useArray[i].division,"close");
			}
		}
	}
	catch (ex){
	    handleError("Error occured while hiding content.\nSource: [contentHider].\nDetail: " + ex.message);
	}
}

function numbersonly(e)
{
	//evt = e || window.event;
	
  	var unicode; //= evt.which || evt.keyCode;
	
	unicode = (window.event) ? event.keyCode : e.which;
	//alert(unicode);
	
	if (unicode!=8 && unicode!=13)
	{ //if the key isn't the backspace key (which we should allow)
		if (unicode > 31 && (unicode < 48 || unicode > 57))//if not a number
		return false; //disable key press
	}
}

function floatnumbersonly(e)
{
  	var unicode; //= evt.which || evt.keyCode;
	
	unicode = (window.event) ? event.keyCode : e.which;
	
	if (unicode!=8 && unicode!=13)
	{ //if the key isn't the backspace key (which we should allow)
		if ((unicode<48||unicode>57) && (unicode > 31) && (unicode != 46)) //if not a number
		return false; //disable key press
	}
}
function fncInputNumericValuesOnly()	
{
    if(!(event.keyCode==45||event.keyCode==46||event.keyCode==48||event.keyCode==49||event.keyCode==50||event.keyCode==51||event.keyCode==52||event.keyCode==53||event.keyCode==54||event.keyCode==55||event.keyCode==56||event.keyCode==57))		
        {
            event.returnValue=false;
        }	
}
function SearchList(ObjInput, ListBox, e)
{
	if(isEnterKey(e) == true)
	{
		var ObjList = document.getElementById(ListBox);
		if(ObjInput.value != '')
		{

			var SearchIn = '';
			var SearchArr;
			var	SearchInArr;
			var Match = false;
			var SearchText = ObjInput.value.toUpperCase();
			var OptionsLen = ObjList.options.length;
            var OptionStart = 0;

            if(eval(ObjList.selectedIndex) == OptionsLen)
            {
               OptionStart = 0;
            }
            else if(ObjList.selectedIndex > -1)
            {
              OptionStart = eval((ObjList.selectedIndex) + 1); 
            } 	
            
			for(var h=0;h<OptionsLen;h++)
			{
				ObjList.options[h].selected = false;	
			}	
			
			for(var k=OptionStart;k<OptionsLen;k++)
			{
				SearchIn = ObjList.options[k].text.toUpperCase();
				SearchInArr = SearchIn.split(/\s/g)
				//SearchArr = SearchText.split(/\s/g)
				for (j=0;j<SearchInArr.length;j++)
				{
					//for (p=0;p<SearchArr.length;p++)
					//{
						var SearchingList = SearchInArr[j].trim();
						if(SearchingList == SearchText.trim())
						{
							ObjList.options[k].selected = true;
							Match = true;
							break;
						}
						else
						{
							var patt = eval('/' + SearchText.trim() + '/g');
							//alert(patt);
							if(SearchingList.match(patt))
							{
								ObjList.options[k].selected = true;
								Match = true;
								break;
							}
						}
					//}
					if (Match) 
						break;
				}
				if(Match == false)
				{
					SearchInArr = SearchIn.split(/->/g)
					for (j=0;j<SearchInArr.length;j++)
					{
						//for (p=0;p<SearchArr.length;p++)
						//{
							var SearchingList = SearchInArr[j].trim();
							if(SearchingList == SearchText.trim())
							{
								ObjList.options[k].selected = true;
								Match = true;
								break;
							}
							else
							{
								var patt = eval('/' + SearchText.trim() + '/g');
								//alert(patt);
								if(SearchingList.match(patt))
								{
									ObjList.options[k].selected = true;
									Match = true;
									break;
								}
							}
						//}
						if (Match) 
							break;
					}				
				}
				if (Match) 
					break;
			}
		}
	}
}
function ClearOptions(len,doc)
{
	for(var i=len-1;i>=0;i--)
	{
		if (doc.options[i].value != 0){
			doc.remove(i);
		}
	}	
}

function MoveListItems(lstAvailable, lstSelected, All)
{
	var LstLeft;
	var LstRight;
	var Removed = '';
	var i;
	
	var LstLeft = eval(document.getElementById(lstAvailable));
	var LstRight = eval(document.getElementById(lstSelected));                
	
	for (i=0; i<LstLeft.options.length; i++)
	{
		if (LstLeft.options[i].value != 0)
		{
			if (LstLeft.options[i].selected && All == false) 
			{
				LstRight[LstRight.options.length] = new Option(LstLeft.options[i].text, LstLeft.options[i].value, true);
				Removed = Removed + LstLeft.options[i].value + ',';
				
			}
			else if(All == true)
			{
				LstRight[LstRight.options.length] = new Option(LstLeft.options[i].text, LstLeft.options[i].value, true);
				Removed = Removed + LstLeft.options[i].value + ',';
			}
		}
	}
	
//	alert(LstRight.options[0].value);
	if (Removed != '')
	{
		RemoveFromList(LstLeft, Removed);
	}
}

function RemoveFromList (Lst, Items)
{
	var Removed = Items.split(',');
	var j;
	var x;
	for (j=0; j<Removed.length; j++)
	{
		for (x=0; x<Lst.options.length; x++)
		{
			if (Lst.options[x] != null && Lst.options[x].value == Removed[j])
			{
				Lst.options[x] = null;
			}
		}
	}
}

function escapeHTML (str)
{
   var div = document.createElement('div');
   var text = document.createTextNode(str);
   div.appendChild(text);
   return div.innerHTML;
}

/*
Standard two decimal number formatting function to emulate the ASP format function in JS
*/
function numberFormatter(value,decimals){

	//alert (value);
	//Default to 2 decimals
	if (!decimals && decimals != 0) {decimals = 2}
	var dotspot,multiplyamount;
	//Remove currency label and decimal comma formatting
	value = value.toString();
	//var valueregex = /^(\D)+|[,]/g;
	var valueregex = /([a-z]|\$|[,])+/gi;
		alert("preconvert:" + value);
	value = value.replace(valueregex,'');
		alert("postconvert:" + value);
	value = parseFloat(value);
		alert("postfloat:" + value);
	//2 digit rounding simulator
	multiplyamount = parseInt(Math.pow(10,decimals));
		alert("multiplyamount:" + multiplyamount);
	value = (Math.round(value * multiplyamount))/multiplyamount;
		alert("postround:" + value);
	value = value.toString();
		alert("poststring:" + value);
	//Add cents if required
	if (value.indexOf(".") == -1) {
		value = value.concat(".00");
	}
	dotspot = value.indexOf(".");
	while (value.substring(dotspot,value.length).length <= decimals) {
		value = value.concat("0");
	}
		alert("postzeroconcat:" + value);
	value = parseFloat(value);
		alert("output:" + value);
	return value;
}


/*
Standard currency formatting function to emulate the ASP format function in JS
*/
function currencyFormatter(value,dropSymbol,includeSymbol){
	//alert(value);
	var dotspot,workspot,output,flag;
	//Remove currency label and decimal comma formatting
	value = value.toString();
	//var valueregex = /^(\D)+|[,]/g;
	var valueregex = /([a-z]|\$|[,])+/gi;
	value = value.replace(valueregex,"");
	//Force number format
	value = parseFloat(value);
	//2 digit rounding simulator
	value = (Math.round(value * 100))/100;
	value = value.toString();
	//Add cents if required
	if (value.indexOf(".") == -1) {
		value = value.concat(".00");
	}
	dotspot = value.indexOf(".");
	workspot = dotspot;
	flag = true;
	//Add comma every 3 digits (space)
	while (flag) {
		workspot = workspot - 3;
		if (workspot > 0) {
			var part1 = value.substring(0,workspot);
			var part2 = value.substring(workspot,value.length);
			//value = part1 + "," + part2
			value = part1 + " " + part2
			//workspot = value.indexOf(",");
			workspot = value.indexOf(" ");
		}
		else {
			flag = false;
		}
	}
	dotspot = value.indexOf(".");
	if (value.substring(dotspot,value.length).length < 3){
		value = value.concat("0");
	}
	value = value.replace("-,","-");
	if (!dropSymbol && includeSymbol){
		//Assumes ZAR output
		output = "R " + value;
	}
	else {
		output = value;
	}
	return output;
}

function getElementText(n)
{
  if('textContent' in n) {
    return n.textContent;
  } else if('innerText' in n) {
    return n.innerText;
  } else {
    // Call a custom collecting function, throw an error, something like that.
    //alert("unhandled");
  }
}

function setElementText(n, text)
{
  if('textContent' in n) {
    n.textContent = text;
  } else if('innerText' in n) {
    n.innerText = text;
  } else {
    // Call a custom collecting function, throw an error, something like that.
    //alert("unhandled");
  }
}

/*
Validation functions
*/
//Returns true if the value supplied is a valid e-mail address
function isValidEmail(val){var re = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;return re.test(val.toString());}
//Returns true if the value supplied is a valid integer
function isInteger(val){var re = /^[-]?\d+$/;return re.test(val.toString());}
//Returns true if the value supplied is a valid decimal
function isDecimal(val){var re = /^[-]?\d+([.]{1})\d+$/;return re.test(val.toString());}
//Returns true if the value supplied is a valid number
function isNumber(val){var re = /^[-]?\d+([.]{1}\d+)?$/;return re.test(val.toString());}
//Returns true if the value supplied is a valid number
function isDate(val){var re = /^[0-9]{1,2}[-]{1}[a-zA-Z]{3}[-]{1}[0-9]{4,}$/;return re.test(val.toString());}
//Reload the home page
function reloadhomepage(){document.getElementById('mainformreload').submit();}

/*
function initModalWindow(){

	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		//$(id).css('top',  winH/2-$(id).height()/2);
		//$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});	 
}*/

function InitColorbox(){
    $(".colorbox").colorbox();
}

function initializeModal(modalbox){
    $('#'+modalbox).jqm({modal: true});
    //var myOpen=function(hash){ hash.w.css('opacity',0.98).fadeIn('2000'); };
    //$('#'+modalbox).jqm({onShow:myOpen}); 
    var myClose=function(hash) { hash.w.fadeOut('2000',function(){ hash.o.remove(); }); };
    $('#'+modalbox).jqm({onHide:myClose});
}

function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function _PrintReport(url, parms){

	if (parms){
		url += parms
	}

//alert (url);
	window.open(url,"_blank","width=800,scrollbars=yes,resizable=yes,toolbar=no,menubar=no,location=no");

}

function InitLightBox(){
//alert ("done")
	$('a[rel*=lightbox]').lightbox(); // Select all links that contains lightbox in the attribute rel
	//$('a.lightbox').lightBox(); // Select all links that contains lightbox in the attribute rel
	//$('a:has(img)').lightbox();
	//alert('initialized');
}
