/*                         Suponix.com (anDeRan)                              */

var is_ie = !!document.uniqueID;
var ie6   = is_ie && navigator.appVersion.match(/MSIE (5.5|6)/);

if (is_ie) {
	var XMLHttpRequest = function () {
		return (new ActiveXObject("Msxml2.XMLHTTP")) || (new ActiveXObject("Microsoft.XMLHTTP")) || false;
	};
}

var request = function () {
	try {
		var link = new XMLHttpRequest();
	} catch (e) {
		alert('Your browser doesn\'t support XMLHttpRequest. Please enable XMLHTTPRequest if disabled or update your browser is old.');
	}

	this.get = function (path, analyze) {
		link.onreadystatechange = function () {
			if (link.readyState == 4 && link.status == 200) {
				if (analyze) {
					analyze(link);
				}
				
			}
		};
		link.open('GET', path, true);

		if (ie6) {
			link.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		}
		link.send('');
	};
};

function email(text, dom) {
	dom = dom || 'com';
	document.write(text + "@suponix." + dom);
}

function mailto(text) {
	window.location.href = "mailto:" + text + "@suponix.com";
}

var display = function (image, width, height) {
	var left       = screen.width / 2 - width / 2;
	var top        = screen.height / 2 - height / 2;
	window.open('/display.php?' + image, '_blank', 'status=no,dependent=yes,modal=yes,height=' + height + ',width=' + width + ',left=' + left + ',top=' + top);
	return false;
};

var showPreview = function (link, width, height, force) {
	var force = force || link.href.replace(/.+\/(.)[^\/]+\/([^\/]+)\/$/, '$1_$2');
	var id = link.href.replace(/[^a-z0-9]/ig, '');
	id = 'id' + id.substring(id.length - 14, id.length);
	var div = document.getElementById(id);
	if (!div) {
		div = document.createElement('DIV');
		div.style.position = 'absolute';
		div.style.width = width + 'px';
		div.id = id;
		div.style.height = height + 'px';
		div.style.background = '#FFFFFF url(/images/loading.gif) no-repeat center';
		div.style.border = '1px solid #999';
		div.style.display = 'none';
		div.innerHTML = '<img src="/images/portfolio/icons/' + force + '.gif" width="' + width + '" height="' + height + '" alt="" />';	
		if (ie6) {
			link.parentNode.appendChild(div);
		} else {
			document.body.appendChild(div);
		}
	}
	link.onmousemove = function (e) {
		e = e || event;
		link = this;
		var id = link.href.replace(/[^a-z0-9]/ig, '');
		id = 'id' + id.substring(id.length - 14, id.length);
		var byTop, div = document.getElementById(id);
		if (div) {
			var byTop = 0;
			if (document.body.scrollTop) {
				byTop = document.body.scrollTop;
			} else if (window.pageYOffset != undefined) {
				byTop = window.pageYOffset;
			}

			var inner = window.innerHeight ? window.innerHeight : document.body.clientHeight;
			byTop = e.clientY < inner - height ? e.clientY + byTop + 20 : e.clientY + byTop - height - 5;

			div.style.display = 'block';
			div.style.top = byTop + 'px';
			div.style.left = e.clientX + 'px';
		}
	};
};

var clearPreview = function (link) {
	var id = link.href.replace(/[^a-z0-9]/ig, '');
	id = 'id' + id.substring(id.length - 14, id.length);
	var div = document.getElementById(id);
	if (div) {
		div.parentNode.removeChild(div);
	}
};

var getSub = function (main) {
	(new request).get('/scripts/requests.php?action=get_sub&sub=' + main.options[main.selectedIndex].value, parseSub);
};

var parseSub = function (link) {
	var sub = document.getElementById('nav-sub');
	sub.innerHTML = '';
	var select = link.responseXML.documentElement;
	var groups = select.childNodes.length;
	var i, j, group, opts, t_group, t_opt;

	for (i = 0; i < groups; i++) {
		group = select.childNodes[i];

		t_group = document.createElement('OPTGROUP');
		t_group.label = group.getAttribute('label');

		for (j = 0; j < group.childNodes.length; j++) {
			t_opt           = document.createElement('OPTION');
			t_opt.value     = group.childNodes[j].getAttribute('value');
			t_opt.innerHTML = group.childNodes[j].firstChild.nodeValue;
			t_group.appendChild(t_opt);
			t_opt = null;
		}
		sub.appendChild(t_group);
		t_group = null;
	}
};


if (typeof sIFR == "object") {  
  	var myriad = {
       src: '/scripts/one.swf'
    };
	sIFR.activate(myriad);
}	

window.onload = function () {
	var nav_go = document.getElementById('nav-go');
	if (nav_go) {
		nav_go.onclick = function () {
			var nav_main = document.getElementById('nav-main');
			var nav_sub  = document.getElementById('nav-sub');
			var main_val = nav_main.options[nav_main.selectedIndex].value;
			var sub_val  = nav_sub.options[nav_sub.selectedIndex].value;

			if (sub_val.indexOf('http:') != -1) {
				this.blur();
				window.open(sub_val, '_blank');
			} else {
				document.location = '/portfolio/' + main_val + '/' + sub_val + '/';
			}
			return false;
		};
	}
	
   


};
if (typeof sIFR == "object") {   

sIFR.replace(myriad, {
     selector: 'h1'
     ,wmode: 'transparent'
     ,fitExactly: false
     ,css: ['.sIFR-root {font-size: 20px; color: #DF5E00; text-align: left; }']
  }); 
  
  sIFR.replace(myriad, {
     selector: 'h3'
     ,wmode: 'transparent'
     ,fitExactly: false
     ,css: ['.sIFR-root { color: #DF5E00; font-size: 17px; width: 150px; }']
  });
  
   sIFR.replace(myriad, {
     selector: 'p.work'
     ,wmode: 'transparent'
     ,fitExactly: false
     ,css: ['.sIFR-root  { font-size: 20px; height: 10px; color: #5390D1; }']
  });
  
};