/* Disable right click */
///////////////////////////////////
/* Arrow down and up actions */
function processKey(evt)
{
	evt = (evt) ? evt : (window.event ? window.event : null);
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	if (charCode == 37)
	{
		//getlefturl();
		moveprevimg();
	}
	else if (charCode == 39)
	{
		//getrighturl();
		movenextimg();
	}
} 
// Load next page
function getlefturl()
{
	var index_param = parseInt(gup( 'index' ));
	surl = String(window.location.href);
	if (document.getElementById('lef') != null) {
		sarr = surl.split("&");
		nurl = sarr[0]+"&index="+(index_param-1)+"#bottom";
		window.location.href=nurl;
	}
}
// Load previous page
function getrighturl()
{
	var index_param = parseInt(gup( 'index' ));
	surl = String(window.location.href);
	if (document.getElementById('rig') != null) {
		sarr = surl.split("&");
		nurl = sarr[0]+"&index="+(index_param+1)+"#bottom";
		window.location.href=nurl;
	}
}
// Get URL param value-->
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
// Load next image id
function movenextimg()
{
	//alert(document.getElementById("imt").src);
	for(i=0;i<10;i++){
		if(document.getElementById("img"+i).src == document.getElementById("imt").src) {
			var method=document.getElementById("img"+(i+1)).onclick+"";
			method=method.substring(26,method.length-3);
			var arr = method.split(",");
			document.getElementById("imt").src = document.getElementById("img"+(i+1)).src;
			document.getElementById("imt").width = parseInt(arr[2]);
			document.getElementById("imt").height = parseInt(arr[3]);
			if(parseInt(arr[3]) < 400) {
				document.getElementById("imttd").height = 200+parseInt(arr[3])/2;
			}else{
				document.getElementById("imttd").height = parseInt(arr[3]);
			}
			document.getElementById("imgname").innerHTML = document.getElementById("lb"+parseInt(arr[1])).innerHTML;
			document.getElementById("imtlbl").width = parseInt(arr[2]);
			break;
		}
	}
}
// Load previous image id
function moveprevimg()
{
	//alert(document.getElementById("imt").src);
	for(i=0;i<10;i++){
		if(document.getElementById("img"+i).src == document.getElementById("imt").src) {
			if((i-1) >= 0) {
				var method=document.getElementById("img"+(i-1)).onclick+"";
				method=method.substring(26,method.length-3);
				var arr = method.split(",");
				document.getElementById("imt").src = document.getElementById("img"+(i-1)).src;
				document.getElementById("imt").width = parseInt(arr[2]);
				document.getElementById("imt").height = parseInt(arr[3]);
				if(parseInt(arr[3]) < 400) {
					document.getElementById("imttd").height = 200+parseInt(arr[3])/2;
				}else{
					document.getElementById("imttd").height = parseInt(arr[3]);
				}
				document.getElementById("imgname").innerHTML = document.getElementById("lb"+parseInt(arr[1])).innerHTML;
				document.getElementById("imtlbl").width = parseInt(arr[2]);
				break;
			}
		}
	}
}
// -->

document.onkeydown=processKey;

document.oncontextmenu=new Function("return false")

// -->

/* FOR info.php */
function upbutt(a)
{
	if(a=="1")
	{
		document.getElementById("lef").src="img/fy12.jpg";
	}
	else
	{
		document.getElementById("rig").src="img/fy22.jpg";
	}
}

function showid(my,cid,w,h)
{
	document.getElementById("imt").src = my.src;
	document.getElementById("imt").width = w;
	document.getElementById("imt").height = h;
	if(h < 400) {
		document.getElementById("imttd").height = 200+h/2;
	}else{
		document.getElementById("imttd").height = h;
	}
	imgname.innerHTML = document.getElementById("lb"+cid).innerHTML;
	/* To left align image label text and image in portfolio */
	document.getElementById("imtlbl").width = w;
}

function showflv(my,cid,w,h)
{
	var flvVideo = '<object id=\"player\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" name=\"player\" width=\"'+w+'\" height=\"'+h+'\"><param name=\"movie\" value=\"player-viral.swf\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"flashvars\" value=\"file='+my+'.flv&autostart=true&icons=false&dock=false&skin=simple.swf\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"player-viral.swf\" width=\"'+w+'\" height=\"'+h+'\" id=\"player\" name=\"player\"><param name=\"movie\" value=\"player-viral.swf\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"flashvars\" value=\"file='+my+'.flv&autostart=true&icons=false&dock=false&skin=simple.swf\" /></object><!--<![endif]--></object>';

loadEmbeddedVideo('embflv', flvVideo);
	if(h < 400) {
		document.getElementById("imttd").height = 200+h/2;
	}else{
		document.getElementById("imttd").height = h;
	}
document.getElementById("imgname").innerHTML = document.getElementById("lb"+cid).innerHTML;
	/* To left align image label text and image in portfolio */
	document.getElementById("imtlbl").width = w;

}

var loadEmbeddedVideo = function(id, embeddedCode) {
	document.getElementById(id).innerHTML = fixEmbeddedVideo(embeddedCode);
}

var fixEmbeddedVideo = function(embedCode) {
	if(embedCode && embedCode.toLowerCase().indexOf('classid') == -1) {
		var objPos = embedCode.toLowerCase().indexOf('object ') + 'object '.length;
		return embedCode.substr(0, objPos) + 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' + embedCode.substr(objPos);
	} else {
		return embedCode;
	}
}

function dubutt(a)
{
	if(a=="1")
	{
		document.getElementById("lef").src="img/fy11.jpg";
	}
	else
	{
		document.getElementById("rig").src="img/fy21.jpg";
	}
}

function getPara(paraName){ 
var reg = new RegExp("[&|?]"+paraName+"=([^&$]*)", "gi"); 
var a = reg.test(urlPara); 
return a ? RegExp.$1 : ""; 
} 

function buildmenu(MID)
{
	switch(MID.id)
	{
		case "subm1":
		if(arc1.style.display=="none")
		{
			arc1.style.display="";
			jt11.src="img/jt12.jpg";
		}
		else
		{
			arc1.style.display="none";
			jt11.src="img/jt11.jpg"
		}
		break;
		case "subm2":
		if(real.style.display=="none")
		{
			real.style.display="";
			jt12.src="img/jt12.jpg";
		}
		else
		{
			real.style.display="none";
			jt12.src="img/jt11.jpg"
		}
		break;
				case "subm3":
		if(sub3.style.display=="none")
		{
			sub3.style.display="";
			jt21.src="img/jt22.jpg";
		}
		else
		{
			sub3.style.display="none";
			jt21.src="img/jt21.jpg"
		}
		break;
				case "subm4":
		if(sub4.style.display=="none")
		{
			sub4.style.display="";
			jt22.src="img/jt22.jpg";
		}
		else
		{
			sub4.style.display="none";
			jt22.src="img/jt21.jpg"
		}
		break;
	}
}

function mouseon(MID)
{
	MID.className="submenu4";
}

function mousedown(MID,a)
{
	if(a=="1")
	{
	MID.className="submenu2";
	}
	else
	{
		MID.className="submenu3";
	}
}

/* FOR all portfolio files */
function SetM2(MID)
{
	switch(MID.id)
	{
		case "m21":
		m21.src="img/en/m2112.jpg";
		m22.src="img/en/m2121.jpg";
		m23.src="img/en/m2131.jpg";
		m24.src="img/en/m2141.jpg";
		break;
				case "m22":
		m21.src="img/en/m2111.jpg";
		m22.src="img/en/m2122.jpg";
		m23.src="img/en/m2131.jpg";
		m24.src="img/en/m2141.jpg";
		break;
				case "m23":
		m21.src="img/en/m2111.jpg";
		m22.src="img/en/m2121.jpg";
		m23.src="img/en/m2132.jpg";
		m24.src="img/en/m2141.jpg";
		break;
				case "m24":
		m21.src="img/en/m2111.jpg";
		m22.src="img/en/m2121.jpg";
		m23.src="img/en/m2131.jpg";
		m24.src="img/en/m2142.jpg";
		break;
				case "m25":
		m25.src="img/en/m2212.jpg";
		m26.src="img/en/m2221.jpg";
		m27.src="img/en/m2231.jpg";
		break;
				case "m26":
		m25.src="img/en/m2211.jpg";
		m26.src="img/en/m2222.jpg";
		m27.src="img/en/m2231.jpg";
		break;
				case "m27":
		m25.src="img/en/m2211.jpg";
		m26.src="img/en/m2221.jpg";
		m27.src="img/en/m2232.jpg";
		break;
	}
}

function showtitle(cid)
{
	if(cid == -1)
	{
document.getElementById('lb').style.display  ="";
	}
	else
	{
		document.getElementById('lb'+cid).style.display  ="";
	}
}
function distitle(cid)
{
	if(cid == -1)
	{
document.getElementById('lb').style.display  ="none";
	}
	else
	{
		document.getElementById('lb'+cid).style.display  ="none";
	}
}

/* FOR all common files */
function SetMenu(MenuID)
{ 
if(lan.value = "en")
{
	switch(MenuID.id)
	{
		case "m2":
		m1.src ="img/en/c1whg/1.png";
		m2.src ="img/en/c1hg/2.png"; 
		m3.src ="img/en/c1whg/3.png"; 
		m4.src ="img/en/c1whg/4.png"; 
		m5.src ="img/en/c1whg/5.png"; 
		m6.src ="img/en/c1whg/6.png"; 
		m2_1.style.display=""; 
		m2_2.style.display="none";
		break;
		
		case "m4":
		m1.src ="img/en/c1whg/1.png";
		m2.src ="img/en/c1whg/2.png"; 
		m3.src ="img/en/c1whg/3.png"; 
		m4.src ="img/en/c1hg/4.png"; 
		m5.src ="img/en/c1whg/5.png"; 
		m6.src ="img/en/c1whg/6.png"; 
		m2_1.style.display="none"; 
		m2_2.style.display="";
		break;
	}
}
} 

/* FOR PORFOLIO ajax tree menu section */
var open_obj = new Array()

function expand(obj,checkbox) {

    var obj2 = obj;
    var img_obj = "img_" + obj;
    var div_obj = "div_" + obj;
    var check_obj = "check_" + obj;

	if (open_obj[obj] == true) {

		if (checkbox != "1") {

			document.getElementById(div_obj).style.display = "none";
			document.getElementById(img_obj).src = "/img/collapsed.gif";
			open_obj[obj] = false;

		}

	} else {

		document.getElementById(div_obj).style.display = "block";
		document.getElementById(img_obj).src = "/img/expanded.gif";
		open_obj[obj] = true;

	}

	if (checkbox == "1") {

		var checkboxes = document.forms["form"].elements[check_obj];
		for (var i = 0; i < checkboxes.length; i++) {

			if (checkboxes[i].checked == true) {

				checkboxes[i].checked = false;

			} else {

				checkboxes[i].checked = true;

			}
		}

	}

}

/* for contact get hour function so that it displays the hour with a 0 when it's less than 10 */

function checkTime(i)
{
if (i<10) 
  {
  i="0" + i;
  }
return i;
}
