function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 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];}
}

// GET X COORDINATE
function getRealLeft(id) { 
	var el = document.getElementById(id);
	if (el) { 
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		} 
		return xPos;
	} else {
		return 0;
	}
} 

// GET Y COORDINATE
function getRealTop(id) {
	var el = document.getElementById(id);
	if (el) { 
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return (yPos+1);
	} else {
		return 0;
	}
}

// get the index page Y scroll offset
function GetIndexYOffset() {
	var x,y;
	if (parent.window.pageYOffset) // all except Explorer
	{
		x = parent.window.pageXOffset;
		y = parent.window.pageYOffset;
	}
	else if (parent.window.document.documentElement && parent.window.document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		x = parent.window.document.documentElement.scrollLeft;
		y = parent.window.document.documentElement.scrollTop;
	}
	else if (parent.window.document.body) // all other Explorers
	{
		x = parent.window.document.body.scrollLeft;
		y = parent.window.document.body.scrollTop;
	}
	return y;
}

// get the client inner height of the browser
function GetPageClientHeight() {
	var x,y;
	if (parent.window.innerHeight) // all except Explorer
	{
		x = parent.window.innerWidth;
		y = parent.window.innerHeight;
	}
	else if (parent.window.document.documentElement && parent.window.document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = parent.window.document.documentElement.clientWidth;
		y = parent.window.document.documentElement.clientHeight;
	}
	else if (parent.window.document.body) // other Explorers
	{
		x = parent.window.document.body.clientWidth;
		y = parent.window.document.body.clientHeight;
	}
	return y;
}

// get the client inner width of the browser
function GetPageClientWidth() {
	var x,y;
	if (parent.window.innerHeight) // all except Explorer
	{
		x = parent.window.innerWidth;
		y = parent.window.innerHeight;
	}
	else if (parent.window.document.documentElement && parent.window.document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = parent.window.document.documentElement.clientWidth;
		y = parent.window.document.documentElement.clientHeight;
	}
	else if (parent.window.document.body) // other Explorers
	{
		x = parent.window.document.body.clientWidth;
		y = parent.window.document.body.clientHeight;
	}
	return x;
}

function checkcontactform() {
	if (document.getElementById('email').value == '') {
		alert('    Email        .');
		return false;
	}
	return true;
}

function togglediv(d) {
	var c = document.getElementById(d);
	if (c.style.display=='none') {
		c.style.display = 'inline';
	} else {
		c.style.display = 'none';
	}
}

function toggledivonoff(d, state) {
	var c = document.getElementById(d);
	if (state) {
		c.style.display = 'inline';
	} else {
		c.style.display = 'none';
	}
}

function showCabelPreview(imgtag, event) {
	var x, y;
	var divprev = document.getElementById('divCabelPreview');
	var imgthumb = document.getElementById(imgtag);
	var imgsrc = imgthumb.src.replace(/_thumb.jpg/gi, '.gif');
	var imgprev = document.getElementById('imgCabelPreview');
	imgprev.src = imgsrc;
//	x = getRealLeft(imgtag);
//	y = getRealTop(imgtag);
//	x += document.getElementById(imgtag).width;
//	divprev.style.left = x+'px';
//	divprev.style.top = y+'px';
	var m_x = event.clientX+14;
	var m_y = event.clientY+14;
	
	if ( (imgprev.width+6) > (GetPageClientWidth()-m_x) ) {
		m_x -= imgprev.width;
		m_x -= 28;
	}
	if ( (imgprev.height+6) > (GetPageClientHeight()-m_y) ) {
		m_y = GetPageClientHeight() - imgprev.height - 6;
	}

	divprev.style.left = m_x+'px';
	divprev.style.top = m_y+GetIndexYOffset()+'px';
	
	divprev.style.display = 'inline';
}

function hideCabelPreview() {
	var divprev = document.getElementById('divCabelPreview');
	var imgprev = document.getElementById('imgCabelPreview');
	imgprev.src = 'img/transp10x10.gif';
	divprev.style.display = 'none';
	divprev.style.left = -1000;
	divprev.style.top = -1000;
}

function moveCabelPreview(event) {
	var divprev = document.getElementById('divCabelPreview');
	var imgprev = document.getElementById('imgCabelPreview');
	var m_x = event.clientX+14;
	var m_y = event.clientY+14;
	
	if ( (imgprev.width+24) > (GetPageClientWidth()-m_x) ) {
		m_x -= imgprev.width;
		m_x -= 28;
	}
	if ( (imgprev.height+6) > (GetPageClientHeight()-m_y) ) {
		m_y = GetPageClientHeight() - imgprev.height - 6;
	}

	divprev.style.left = m_x+'px';
	divprev.style.top = m_y+GetIndexYOffset()+'px';
	
	return true;
}


