function strReplace(s, r, w){
     return s.split(r).join(w);
}


function RollButton( butt ) {
	butt.src = strReplace(butt.src , "off_" , "on_");
}

function RestoreButton( butt ) {
	butt.src = strReplace(butt.src , "on_" , "off_");
}




_filluser = 0;
_fillpass = 0
function UnfillLogin(element) {
	if ((element.name == "user") && !_filluser) {
		_filluser = 1;
		element.value = "";
	} 
	
	if ((element.name == "pass") && !_fillpass) {
		_fillpass = 1;
		element.value = "";
	} 	
}

function FillLogin(element) {
		if ((element.name == "user") && (element.value=="")){
			_filluser = 0;
			element.value = "Email address";
		}

		if ((element.name == "pass") && (element.value=="")){
			_fillpass = 0;
			element.value = "password";
		}

}


	function CommercialPrint(page) {
		w = 800;
		h=600;
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,toolbar=no,menubar=no,statusbar=no,status=no,resizable=no'
		window.open(page, "print_order" , winprops);
	}
	function RMVideoCode( width , height , path , autostart , align){
		var audioHTML = ""

		//media player 9 ( for IE and mozilla )
		audioHTML += '<object ' + ( align ? 'align="' + align + '" ' : '' ) + ''+ ( width ? 'width="' + width +'"' : '' ) +' '+ ( height ? 'height="' + height +'"' : '' ) +' classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://www.microsoft.com/Windows/MediaPlayer/">'
		audioHTML += '			<param name="Filename" value="' + path + '">'
		audioHTML += '			<param name="AutoStart" value="' + (autostart == true ? 'true' : 'false') +'">'
		audioHTML += '			<param name="ShowControls" value="true">'
		audioHTML += '			<param name="BufferingTime" value="20">'
		audioHTML += '			<param name="ShowStatusBar" value="true">'
		audioHTML += '			<param name="AutoSize" value="true">'
		audioHTML += '			<param name="InvokeURLs" value="false">'
		audioHTML += '			<param name="uiMode" value="mini">'

/*
		audioHTML += '<object '+ ( width ? 'width="' + width +'"' : '' ) +' '+ ( height ? 'height="' + height +'"' : '' ) +' classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://www.microsoft.com/Windows/MediaPlayer/" type="application/x-oleobject">'
		audioHTML += '			<param name="URL" value="' + path + '">'
		audioHTML += '			<param name="AutoStart" value="' + (autostart == true ? 'true' : 'false') +'">'
		audioHTML += '			<param name="ShowControls" value="true">'
		audioHTML += '			<param name="BufferingTime" value="20">'
		audioHTML += '			<param name="ShowStatusBar" value="true">'
		audioHTML += '			<param name="AutoSize" value="true">'
		audioHTML += '			<param name="InvokeURLs" value="false">'
*/
		audioHTML += '			<embed '
		audioHTML += '				autostart="' + (autostart == true ? '1' : '0') +'" ' 
		audioHTML += '				enabled="1" '
		audioHTML += '				autoSize="1" '
		audioHTML += '				showstatusbar="1" '
		audioHTML += '				showdisplay="0" '
		audioHTML += '				showcontrols="1" '
		audioHTML += '				src="' + path + '" '
		audioHTML += '				type="application/x-mplayer2" '
		audioHTML += '				pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" '
		audioHTML += '				CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,0,0" '
		audioHTML += '				width="'+ width +'" '
		audioHTML += '				height="'+ height +'" ></embed>'
		audioHTML += '</object>'

		return audioHTML;

	}

	function NewWindow(mypage, myname, w, h, scroll) {
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=no,menubar=no,statusbar=no,status=no,resizable=no'
		return window.open(mypage, myname, winprops)
	}

function draw_box ( width , part , title ) {
	if ( part == 1 ) {
		
		var html = "";
		html =	'		<table align="center" width="550" cellspacing="0" cellpadding="4">'
			 +	'			<tr>'
			 +	'				<td><img src="images/forms/' + title + '.gif"></td>'
			 +	'			</tr>'
			 +	'			<tr>'
			 +	'				<td>'
			
			document.write (html);

	} else {

		var html = "";

			html =	'			</td>'
				 +	'		</tr>'
				 +	'	</table>'

		document.write (html);
	}
}


function draw_button(image , href , onclick , title , onmouseover , onmouseout , target){
	var html = "";
		
		html += "<a href=\"" + href + "\" "
		html += "onclick=\"" + onclick + "\" "
		html += (target ? "target=\"" + target + "\" " : "")
		html += "onmouseover=\"" + onmouseover + "\" "
		html += "onmouseout=\"" + onmouseout + "\" >"
		html += "<img hspace=2 src=\"images/forms/buttons/" + image + ".gif\" border=\"0\" title=\"" + title + "\">"
		html += "</a>";

	document.write(html);
}
function FormItemImage( src , element ) {
	var image = new Image();
	image.src = src;


	//check if the image its a valid one ( seems to work only for images uploaded from web					
	if (image.width && image.height){
	//hide the no image file
		document.getElementById(element + "_preview_image").src = src;
		document.getElementById(element + "_preview_image").style.display = "inline";
		document.getElementById(element + "_no_image").style.display = "none";
	} else {
		//show the no image link
		document.getElementById(element + "_preview_image").style.display = "none";
		document.getElementById(element + "_no_image").style.display = "inline";
	}
}


function XMLFormsPhone( part , id , max1 , max2 , max3) {
	var part_1 = document.getElementById(id + "_1");
	var part_2 = document.getElementById(id + "_2");
	var part_3 = document.getElementById(id + "_3");

	if ((part == 1) && (part_2.value.length !=max2) && (part_1.value.length == max1))
		part_2.focus();

	if ((part == 2) && (part_3.value.length !=max3) && (part_2.value.length == max2))
		part_3.focus();
}


	function GetSelectValue(select) {
		for (var i = 0; i < select.options.length; i++) {          
			if ( select.options[i].selected == true )                    
				return select.options[i].value;
		}
	}


	function EnableSelectElement(select , which , val) {

		for (var i = 0; i < select.options.length; i++) {          
			if ( select.options[i].value == which )                    
				select.options[i].disabled = val;
		}

		for ( i in select.options ) {
			if ( GetSelectValue(select, i) == which )                    
					select.options[i].disabled = val;
		}
	}


	function SelectElement(select,which) {
		for (var i = 0; i < select.options.length; i++) {          
			if ( select.options[i].value == which )                    
				select.options[i].selected=true;
		}
	}

/*
	OXYLUS Developement web framweork
	copyright (c) 2002-2005 OXYLUS Developement

	$Id: tabs.js,v 0.0.1 10/05/2005 20:38:15 Exp $

	Note: tested in IE 5.0 , MOZILLA FIREFOX, OPERA

	contact:
		www.oxylus.ro
		devel@oxylus.ro

		office@oxyls.ro

	ALL THIS CODE IS THE PROPERTY OF OXYLUS DEVELOPEMENT. YOU CAN'T USE ANY OF THIS CODE WITHOUT
	A WRITTEN ACCORD BETWEEN YOU AND OXYLUS DEVELOPEMENT. ALL ILLEGAL USES OF CODE WILL BE TREATED
	ACCORDING THE LAWS FROM YOUR COUNTRY.

	THANK YOU FOR YOUR UNDERSTANDING.
	FOR MORE INFORMATION PLEASE CONTACT US AT: office@oxylus.ro
*/

var TPLImagesPath = "images/";

	function draw_tab(firstrow,active,last,afteractive,text,icon,link,width,onmouseover,onmouseout,id) {

		var img_active;
		var img_pre ;
		var img_after

		onmouseover = (onmouseover == "" ? "" : ' onmouseover="' + onmouseover + '" '); 
		onmouseout = (onmouseout == "" ? "" : ' onmouseout="' + onmouseout + '" '); 
		id = (id == "" ? "" : ' id="' + id + '" '); 
		text = (link == "" ? text : '<a class="FormTab' + (active ? "Active" : "") + '" href="' + link + '">' + text + '</a>' )
		firstrow = (firstrow == true ? "" : "2");

		if (icon != ""){
			icon = icon ? '<img src="images/tabs/' + icon + '.gif" />' : '';
			text = "<table cellspacing=0 cellpadding=0><tr><td>" + icon + '</td><td width=5><img width="5" height="0"></td><td class="FormTab' + (active ? "Active" : "") + '">' + text + '</td></tr></table>';
		}
		

		if (active) {
			img_active = "a";
			img_pre = "";

			text = text;
		} else {
			img_active = "i";
			img_pre = afteractive ? "a" : "";			
		}

		var html= ''
			+ '<td width="8"><img src="' + TPLImagesPath + '/tabs/' + firstrow + 'tab_' + img_active + img_pre + '_left.gif"/></td>'
			+ '<td ' + id + onmouseover + onmouseout + 'width="' + width + '" class="FormTab' + (active ? "Active" : "") + '" background="' + TPLImagesPath + '/tabs/' + firstrow + 'tab_' + img_active + '_bg.gif"><nobr>' + text + '</nobr></td>'
			+ '<td	width="16"><img src="' + TPLImagesPath + '/tabs/' + firstrow + 'tab_' + img_active + '_right.gif"></td>'
			+ ( last ? '<td width="8"><img src="' + TPLImagesPath + '/tabs/' + firstrow + 'tab_' + img_active + '2_right.gif"></td>' : "")

		//alert(html)
		document.write(html);		
	}

	function draw_tab_table(part) {
		if (part == 1){
			document.write(
				 '<div align="right"><table cellspacing="0" cellpadding="0">'
				+'	<tr>'				
			);		
		} else {
			document.write(
				'</table></div>'
			);
		}
	}

	function SetSelectOptions( select , opt ) {
		// first of all remove all current options
		select.options.length = 0;
		//populate with the new options
		
		var count = 0;
		for (i in opt){
			select.options[count] = new Option ( opt[i] , i);
			count ++;
		}
	}
