
var isIE = navigator.appName.match(/^Microsoft/) ? true : false;

function showImagePopUp(imgData)
{	
	imgD = imgData.split(':');

//	imgD[0]	 -	id
//	imgD[1]	 -	extension
//	imgD[2]	 -	width
//	imgD[3]	 -	heigth
	 
	
	w = parseInt(imgD[2]) + 20;
	h = parseInt(imgD[3]) + 20;
	t = (screen.availHeight - h) / 2;
	l = (screen.availWidth - w) / 2;
	
	basePath	= 'http://'+window.location.host+'/';
	opts		= 'status=0, toolbar=0, scrollbars=0, top='+t+', left='+l+', width='+w+', height='+h+',resizable=1';
	fPop		= basePath+'PopUp.php?show=bigImage&imgId='+imgD[0]+'';
	
	window.open(fPop, 'PopUp', opts);
}

function showDocPopUp(docData)
{	
	var docD, docName, w, h, t, l, s, win;
	docD = docData.split(':');

	docName = docD[0];	//	docName
	w = docD[1];		//	width
	h = docD[2];		//	heigth
	s = docD[3];		//	scrolls
	 
	w = (w == 'x') ? screen.availWidth - 100 : parseInt(w);
	h = (h == 'x') ? screen.availHeight - 100 : parseInt(h);
	t = (screen.availHeight - h) / 2;
	l = (screen.availWidth - w) / 2;
	s = (s) ? '1' : '0';
	
	basePath	= 'http://'+window.location.host+'/';
	opts		= 'status=0, toolbar=0, scrollbars='+s+', top='+t+', left='+l+', width='+w+', height='+h+',resizable=1';
	fPop		= basePath+'PopUp.php?show=doc&docName='+docName+'';
	
	win = window.open(fPop, 'PopUp', opts);
	if (win)
		win.focus();
}

//---------------------------------------------

function mLay(id)
{
	var m;

	if (document.all)
	{
		m = document.all[id];
	}
	else
	{
		if (document.layers)
		{
			m = document.layers[id];
		}
		else
		{
			if (document.getElementById)
			{
				m = document.getElementById(id);
			}
		}
	}
	return m;
}

function mLayName(sName)
{
	var o;
	
	o = null;
	o = document.getElementsByName(sName)

	if (o.length > 0)
		return o[0];
	return null;
}


//---------------------------------------------

var recipientsNum = 2;

function addEcardRecipient(nameFld, emailFld)
{	
	lay =  mLay('moreEcardRecipients');

	if (!lay) 
		return;
	
	HTML_line  = '<div style="margin-bottom:10px;"><div style="float:left;margin-right:6px;">'+nameFld+' '+recipientsNum+'<BR><input name="r_name[]" type="text" style="width:200px"></div>';
	HTML_line += '<div>'+emailFld+' '+recipientsNum+'<BR><input type="text" style="width:200px" name="r_email[]"></div></div>';

	lay.style.display = 'block';
	lay.innerHTML	 += HTML_line;
	
	recipientsNum++;
}

//---------------------------------------------

var oOldField = null;

function ChangeCountry(id)
{
	var oField;

	if (oOldField)
		oOldField.style.display = 'none';
	else
	if (sOldField)
	{
		oOldField = mLayName('country'+sOldField);
		if (oOldField)
			oOldField.style.display = 'none';
	}

	oField = mLayName('country'+id);
	if (oField)
	{
		oOldField = oField;
		oField.style.display = 'block';
	}
}


function SetHomepage(link, obj)
{
	if (isIE)
	{
		obj.style.behavior="url(#default#homepage)";
		obj.setHomePage(link);
	}
	else
	{
	
		var msg = 'Sorry, your browser doesn\'t support setting a homepage this way.\nPlease do it manually';
		alert(msg);
	}
}

function SetFavourite()
{	
	if (isIE)
		window.external.addFavorite(location.href,document.title);
	else
	{
		var msg = 'Sorry, your browser doesn\'t support adding a page to favourites this way.\nPlease do it manually';
		alert(msg);
	}
}

//---------------------------------------------

function CheckElement(sId)
{
	var oId;

	oId = mLay(sId);
	if (oId)
	{
		// alert(oId.checked);
		oId.checked = true;
	}
}

