//SWAP IMAGE
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function swapImage() {
	strImage = (arguments[1]=='on')?'style/images/leftmenu_r.gif':'style/images/leftmenu.gif';
	MM_swapImage(arguments[0],'',strImage,1)
}

function MM_homeMenu(targ,selObj,restore){ //v3.0
	if (selObj.selectedIndex == 4 || selObj.selectedIndex == 0 ) {
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	}else{
		window.open(selObj.options[selObj.selectedIndex].value,'new')
	}
	if (restore) selObj.selectedIndex=0;
	return false;
}



// Exit disclaimer
var popupWidth;
var popupHeight;

// check type size
function textSizeDetect() {
	var intTextSize = (document.layers)?document.layers["textsizedetect"]:(document.all)?document.all["textsizedetect"]:(document.getElementById)?document.getElementById("textsizedetect"):"";
	if (intTextSize) { intTextSize = intTextSize.offsetHeight;}
	if (intTextSize>14){
		//set the height and width of the popup
		popupWidth=220;
		popupHeight=240;
	} else if (intTextSize>12){
		//set the height and width of the popup
		popupWidth=220;
		popupHeight=220;
	} else{
		popupWidth=220;
		popupHeight=200;
	}
}


// get all links with the class name disclaimer and add to them
// an onclick event going to the disclaimer, and an onKeyPress event 
// going to the onClick event

function doPopups() {
	if (!document.getElementsByTagName){
		return false;
	}
	var links = document.getElementsByTagName("a");
	for (var i=0; i < links.length; i++) {
		if (links[i].className.match("disclaimer")) {
			links[i].onclick = function() {
				textSizeDetect();
				window.open(this.href,'disclaimer','width='+popupWidth+',height='+popupHeight+',scrollbars=auto,resizable');
				return false;
			}
			links[i].onkeypress = function(){
				verifyKey(this,'this.onclick();');
			}
		}
	}
}


// opens links in a new window
function externalLinks(){
	if (!document.getElementsByTagName){
		return;
	}
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
		}
		if (anchor.getAttribute("rel") == "external") {
			var strTitle = anchor.getAttribute("title")
			if (strTitle == "" || strTitle == null){
				anchor.title = "Открыть в новом окне";
			}else{
				anchor.title = strTitle+". Открыть в новом окне";
			}
		}
	}
}




// --------------------
// --- KEYPRESS CHECKER
// --------------------
function verifyKey(oElement,oEvent){
	if(oEvent.keyCode==13 && oElement.onclick){
		oEvent();
	}
}






// -------------------------
// --- form button rollovers
// -------------------------
function highlight(element) {
	element.style.textDecoration = 'none';
}
function restore(element) {
	element.style.textDecoration = 'underline';
}






// --------------------------------------------
// --- CHECK COUNTRY ENTRY ON VERIFICATION PAGE
// --------------------------------------------
function checkCountry(){
	var intCountry=document.getElementById("frmcountry").value;
	if(intCountry==97){
		var dayField=document.getElementById("day");
		var monthField=document.getElementById("month");
		var yearField=document.getElementById("year");
		dayField.value="MM";
		monthField.value="DD";
		yearField.value="YYYY";
		dayField.name="month";
		monthField.name="day";
		dayField.onclick = function(){if(this.value=='MM'){this.value='';};};
		monthField.onclick = function(){if(this.value=='DD'){this.value='';};};
	}
}




// SET OVERFLOW ON BODY
// - to stop CSS errors
function controlOverflow(){
	document.overflowY="scroll";
}





// START WINDOW ONLOAD EVENTS
function startEvents(){
	externalLinks();
	controlOverflow();
	//doPopups();
	//ADD YOUR FUNCTION HERE
}
window.onload = startEvents;
