<!-- Hide script from old browsers

// Make sure file is not hosted in a different frameset

if ( top.location.href != window.location.href )
  { top.location.href=window.location.href }

//***********************************************************************


	// **********************************
	// MV Stats
	// **********************************

if (document.location.href.indexOf("www.metavisia.com") >= 0)
{
		// Get statistics information
	var getRef = getQueryVariable("ref");

	var image = new Image;
	var sSrc='http://www.metavisia.com/mvstats/stats.php?sScrRes=' +
		window.screen.width + 'x'+ window.screen.height + '&iColorDepth='+ screen.colorDepth
		+ '&sURL='+document.location.href+'&sReferrer='+ document.referrer+'&ispecref=' + getRef;
	escape(sSrc);
	image.src=sSrc;
}

//***********************************************************************


function openWindow(url, w, h) {
    var windowprops = "width=" + w + ",height=" + h + ",,left=100,top=100,scrollbars=no,status=yes,toolbar=no,location=no,directories=no,resizable=no";
      popup = window.open(url,'newWin',windowprops);
      popup.close();
      popup = window.open(url,'newWin',windowprops);
      popup.focus();
}

function openDetails(url, w, h) {
    var windowdetails = "width=" + w + ",height=" + h + ",,left=100,top=100,scrollbars=no,status=yes,toolbar=no,location=no,directories=no,resizable=no";
      details = window.open(url,'newWinD',windowdetails);
      details.close();
      details = window.open(url,'newWinD',windowdetails);
      details.focus();
}

function openPicture(pic,w,h) {

	var windowprops = "left=160,top=100,scrollbars=no,status=no,toolbar=no,location=no,directories=no,resizable=no,width=" + w + ",height=" + h;

	picture = window.open('','newPicture',windowprops);
	picture.close();
    picture = window.open('','newPicture',windowprops);
    picture.focus();

	picture.document.write("<html><head><title>Picture<\/title><\/head><body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>")
	picture.document.writeln("<table border=0 cellpadding=0 cellspacing=0 width=100% height=100% bgcolor=#E7E9EE><tr><td valign=center align=center>")
	picture.document.writeln("<img src=" + pic + " width=" + w + " height=" + h + ">")
	picture.document.writeln("</td></tr></table>")
	picture.document.write("<\/body><\/html>")
}

function openFlash(pic,w,h) {

	var windowprops = "left=160,top=100,scrollbars=no,status=no,toolbar=no,location=no,directories=no,resizable=yes,width=" + w + ",height=" + h;

	picture = window.open('','newPicture',windowprops);
	picture.close();
    picture = window.open('','newPicture',windowprops);
    picture.focus();

	picture.document.write("<html><head><title>Picture<\/title><\/head><body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>")
	picture.document.writeln("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width=" + w + " height=" + h + ">")
	picture.document.writeln("<PARAM NAME=movie VALUE=" + pic + ">")
	picture.document.writeln("<PARAM NAME=menu VALUE=false>")
	picture.document.writeln("<PARAM NAME=quality VALUE=high>")
	picture.document.writeln("<EMBED src=" + pic + " menu=false quality=high WIDTH=" + w + " HEIGHT=" + h + " TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>")
	picture.document.writeln("</OBJECT>")
	picture.document.write("<\/body><\/html>")
}

function showFlash(pic,w,h) {

	document.writeln("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width=" + w + " height=" + h + ">");
	document.writeln("<PARAM NAME=movie VALUE=" + pic + ">");
	document.writeln("<PARAM NAME=menu VALUE=false>");
	document.writeln("<PARAM NAME=quality VALUE=high>");
	document.writeln("<EMBED src=" + pic + " menu=false quality=high WIDTH=" + w + " HEIGHT=" + h + " TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>");
	document.writeln("</OBJECT>");
}

function openPlayerWindow(url, w, h) {
    var windowprops = "width=" + w + ",height=" + h + ",,left=10,top=10,scrollbars=on,status=no,toolbar=no,location=no,directories=no,resizable=no";
    popup = window.open(url,'PlayerWindow',windowprops);

}

function copyrightYear(startYear)
	{
		d = new Date();

		if (startYear != d.getFullYear())
			{
			return startYear + " - " + d.getFullYear();
			}
		else
			{
			return startYear;
			}
	}


function validEmail(email)
{

	if ((email.length < 3) || (email.length > 50) ||
		(email.charAt(0) == '@') || (email.charAt(email.length-1) == '@') ||
		(email.charAt(0) == '.') || (email.charAt(email.length-1) == '.') ||
		(email.indexOf('.') == -1) || (email.indexOf('@') == -1) ||
		(email.indexOf('@') != email.lastIndexOf('@')) ||
		(email.indexOf(' ') > 0) || (email.indexOf('?') > 0) || (email.indexOf('..') > 0)
		)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function verifyEmailForm(eForm)
{
	if (eForm.name.value=="")
	{
		alert("Please enter your name.");
		eForm.name.focus();
		return false;
	}

	if (eForm.email.value=="")
	{
		alert("Please enter a valid e-mail address.");
		eForm.email.focus();
		return false;
	}

	if (!validEmail(eForm.email.value))
	{
		alert("Please enter a valid e-mail address.");
		eForm.email.focus();
		return false;
	}

	if (eForm.phone.value=="")
	{
		alert("Please enter your phone number.");
		eForm.phone.focus();
		return false;
	}

	if (eForm.budget.value=="")
	{
		alert("Please enter the budget you've allocated for this project. It doesn't have to be exact - an approximate number or a range is fine.");
		eForm.budget.focus();
		return false;
	}

	if (eForm.message.value=="")
	{
		alert("Please describe your project.");
		eForm.message.focus();
		return false;
	}

	if (eForm.SpamFilter.value=="")
	{
		alert("Please enter the code that you see on the image.");
		eForm.SpamFilter.focus();
		return false;
	}

	return true;
}

function verifyRefferForm(form)
{
	if (form.YourName.value == "")
	{
		alert("Please, enter your name.");
		form.YourName.focus();
		return false;
	}

	if (form.YourEmail.value == "")
	{
		alert("Please, enter your e-mail address.");
		form.YourEmail.focus();
		return false;
	}

	if (!validEmail(form.YourEmail.value))
	{
		alert("Your e-mail address you've entered is not valid. Please, make sure you've typed it correctly.");
		form.YourEmail.focus();
		return false;
	}

	var friendInfoEntered = false;

	if (form.FirstName.value != "" || form.FirstEmail.value != "")
	{
		if (form.FirstName.value == "")
		{
			alert("Please, enter your friend's name.");
			form.FirstName.focus();
			return false;
		}

		if (form.FirstEmail.value == "")
		{
			alert("Please, enter your friend's e-mail address.");
			form.FirstEmail.focus();
			return false;
		}

		if (!validEmail(form.FirstEmail.value))
		{
			alert("Your friend's e-mail address you've entered is not valid. Please, make sure you've typed it correctly.");
			form.FirstEmail.focus();
			return false;
		}

		friendInfoEntered = true;
	}

	if (!friendInfoEntered)
	{
		alert("Please, enter contact information for your friend.");
		form.FirstName.focus();
		return false;
	}

	if (form.Message.value == "")
	{
		alert("Please, type your message.");
		form.Message.focus();
		return false;
	}

	if (form.Message.value.length > 3000)
	{
		alert("Your message cen not be longer than 3000 characters. Please, enter shorter message.");
		form.Message.focus();
		return false;
	}

	return true;
}



/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  In seconds from the current moment  (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
	if (expires != "")
	{
		var expiresDate = new Date();
		expiresDate.setTime(expiresDate.getTime()+expires);
		expires = expiresDate.toGMTString();
	}

    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

// *************************************************
// Get variable from query string
// *************************************************
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++)
  {
    var pair = vars[i].split("=");
    if (pair[0] == variable)
    {
      return pair[1];
    }

  }

  return "";

}

function ShowIdeaFlash() {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="293" height="255" id="idea" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="/images/idea.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#87bee3" /><embed src="/images/idea.swf" quality="high" wmode="transparent" bgcolor="#87bee3" width="293" height="255" name="idea" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}



 	// End hiding script from old browsers -->


function checkInput(form)
{
	if(form.fullname.value == "")
	{
		alert("Моля, въведете Вашето име.");
		form.fullname.focus();
		return false;
	}
	if(!validEmail(form.email.value))
	{
		alert("Моля, въведете валиден e-mail адрес.");
		form.email.focus();
		return false;
	}
	if(form.phone.value == "")
	{
		alert("Моля, въведете Вашия дом. телефон.");
		form.phone.focus();
		return false;
	}
	if(form.gsm.value == "")
	{
		alert("Моля, въведете Вашия gsm номер.");
		form.gsm.focus();
		return false;
	}
	if(form.languages.value == "")
	{
		alert("Моля, изредете програмните езици, които владеете.");
		form.languages.focus();
		return false;
	}
	if(form.databases.value == "")
	{
		alert("Моля, изредете системите бази данни, които владеете.");
		form.databases.focus();
		return false;
	}
	if(form.websites.value == "")
	{
		alert("Моля, опишете участвали ли сте в изработката на уеб сайтове.");
		form.websites.focus();
		return false;
	}
	if(form.educationhigh.value == "")
	{
		alert("Моля, попълнете полето за Вашето висше образование.");
		form.educationhigh.focus();
		return false;
	}
	if(form.educationsecondary.value == "")
	{
		alert("Моля, попълнете полето за Вашето средно образование.");
		form.educationsecondary.focus();
		return false;
	}
	if(form.english.value == "")
	{
		alert("Моля, попълнете полето за Вашето ниво на владеене на английски език.");
		form.english.focus();
		return false;
	}
	if(form.pastwork.value == "")
	{
		alert("Моля, опишете подробно професионалния си опит досега.");
		form.pastwork.focus();
		return false;
	}
	if(form.references.value == "")
	{
		alert("Моля, попълнете полето за препоръки.");
		form.references.focus();
		return false;
	}
	if(form.howdidyoulearn.value == "")
	{
		alert("Как научихте за МетаВизия и как разбрахте, че търсим програмисти?");
		form.howdidyoulearn.focus();
		return false;
	}
	return true;
}

function bookmarksite(name, url, el){
	
	if($.browser.mozilla) 
	{
		window.sidebar.addPanel(name, url, "");
	}
	else if($.browser.msie) 
	{
		window.external.AddFavorite(url, name);
	}
	else if($.browser.opera) 
	{
		$(el).attr("href", url);
		$(el).attr("title", name);
		$(el).attr("rel", "sidebar");
	} 
	else 
	{
		alert('Your browser does not support this option!');
	}
	
}


refUrl = getCookie("refererURL");

if(!refUrl)
{
	sRef = document.referrer;
	setCookie("refererURL", sRef);
}

specialRef = getCookie("specialReferer");
getRef = getQueryVariable("ref");

if((!specialRef)&&(getRef != ""))
{
	setCookie("specialReferer", getRef, 31536000);
}

// check for $_GET['en'] and mark it if equal to 1
enFlag = getQueryVariable("en");
if(enFlag != "")
{
	setCookie("enFlag", 1, 31536000);
}





