function doAction01(obj, color) {
	obj.style.backgroundColor = color;
}

function doAction02(id) {
	window.location = '?content=catalog&id=' + id;
}

function doAction03(id) {
	window.location = '?id=' + id;
}

// JavaScript Document

function doVisibleOn($s) {
	document.getElementById($s).style.display = "block";
}

function doVisibleOff($s) {
	document.getElementById($s).style.display = "none";
}

function doVisible($s) {
	if (document.getElementById($s).style.display=="block") {
		document.getElementById($s).style.display = "none";
	} else {
		document.getElementById($s).style.display = "block";
	}
}

// Check
function checkNumber(text) {
	var checkOK = "0123456789 ";
	var checkStr = text;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j)) break;
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
	}
	return allValid;
}
function checkPhone(text) {
	var checkOK = "0123456789-+() ";
	var checkStr = text;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j)) break;
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
	}
	return allValid;
}
function checkEMail(text) {
	txt=text;
	if (txt == "") { return(false) }
	if (txt.indexOf(".") == -1) { return(false) }
	dog = txt.indexOf("@");
	if (dog == -1) { return(false) }
	if ((dog < 1) || (dog > txt.length - 5)) { return(false) }
	if ((txt.charAt(dog - 1) == '.') || (txt.charAt(dog + 1) == '.')) { return(false) }
	return(true);
}
// end Check

// Menu
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_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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
function doPreloadImage() {
	MM_preloadImages(
		'imdesign/space.gif'
	);
}
// end Menu

// Cookie
function setCookie(name, value) {
	document.cookie = name + "=" + escape(value)+"; path=/; expires=Thursday, 31-Dec-2020 23:59:59 GMT;";
}
function setCookieNow(name, value) {
	document.cookie = name + "=" + escape(value)+"; path=/; expires=Thursday, 31-Dec-2020 23:59:59 GMT;";
}
function getCookie(name) {
	var prefix = name + "="
	var cookieStartIndex = document.cookie.indexOf(prefix)
	if (cookieStartIndex == -1)
		return ''
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
	if (cookieEndIndex == -1)
		cookieEndIndex = document.cookie.length
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}
// end Cookie

// Flash
function flashVersion() {
	// Internet Explorer
	var ua = navigator.userAgent.toLowerCase();
	var isIE = (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1);
	// Var
	var version = 0;
	var lastVersion = 10; //
	var i;
	if (isIE) { // browser == IE
		try {
			for (i = 3; i <= lastVersion; i++) {
				if (eval('new ActiveXObject("ShockwaveFlash.ShockwaveFlash.'+i+'")')) {
					version = i;
				}
			}
		} catch(e) {}
	} else { // browser != IE
		for (i = 0; i < navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.indexOf('Flash') > -1) {
				version = (parseInt(navigator.plugins[i].description.charAt(16)) > version) ? parseInt(navigator.plugins[i].description.charAt(16)) : version;
			}
		}
	}
	return version;
}
function checkFlashVersion() {
	if (flashVersion()<7) {
		window.location="getflash.php";
	}
}
function checkFlashVersion2() {
	if (flashVersion()>=7) {
		window.location="index.php";
	}
}
function flashWrite(sFile, sWidth, sHeight, sFileParam, sDiv) {
	sFile = sFile + '?' + sFileParam;
	sText = '   <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + sWidth + '" height="' + sHeight + '">' +
		'       <param name="movie" value="' + sFile + '">' +
		'       <param name="quality" value="high">' +
		'       <param name="menu" value="false">' +
		'       <param name="wmode" value="transparent">' +
		'       <embed src="' + sFile + '" width="' + sWidth + '" height="' + sHeight + '" quality="high" menu="false" wmode="transparent" pluginspage="http:www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>' +
		'   </object>';
//	sText = '<embed type="application/x-shockwave-flash" src="' + sFile + '" id="flash' + sDiv + '" name="flash' + sDiv + '" bgcolor="#ffffff" quality="high" menu="false" wmode="transparent" width="' + $sWidth + '" height="' + $sHeight + '">';
	document.getElementById(sDiv).innerHTML = sText;
}
// end Flash

// Open Image

function doOpenImage(filename, imgtext) {
//	var width = screen.availWidth-30;
//	var height = screen.availHeight-40;
	var width = 550;
	var height = 550;
	var left = (screen.width/2) - (width/2)-5;
	var top = (screen.height/2) - (height/2)-30;

	new_window=window.open("about:blank","_blank","width="+width+", height="+height+", scrollbars=no, resizable=no, left="+left+", top="+top);
	new_window.document.open("text/html");
	new_window.document.writeln("<HTML><HEAD><META http-equiv=Content-Type content=text/html; charset=iso-8859-1>");
	new_window.document.write("<TITLE>");
	new_window.document.write(imgtext);
	new_window.document.writeln("</TITLE>");
	new_window.document.writeln("</HEAD>");
	new_window.document.writeln("<BODY marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>");
	new_window.document.writeln("<table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr><td align=center bgcolor=#FAFAFA>");
	new_window.document.writeln("<img src="+filename+" border=1 onClick=\"window.close();\"");
	new_window.document.writeln("</td></tr></table>");
	new_window.document.write("</BODY></HTML>");
	new_window.document.close();
}

function doOpenImage2(filename, imgtext) {
//	var width = screen.availWidth-30;
//	var height = screen.availHeight-40;
	var width = 450;
	var height = 650;
	var left = (screen.width/2) - (width/2)-5;
	var top = (screen.height/2) - (height/2)-30;

	new_window=window.open("about:blank","_blank","width="+width+", height="+height+", scrollbars=no, resizable=no, left="+left+", top="+top);
	new_window.document.open("text/html");
	new_window.document.writeln("<HTML><HEAD><META http-equiv=Content-Type content=text/html; charset=iso-8859-1>");
	new_window.document.write("<TITLE>");
	new_window.document.write(imgtext);
	new_window.document.writeln("</TITLE>");
	new_window.document.writeln("</HEAD>");
	new_window.document.writeln("<BODY marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>");
	new_window.document.writeln("<table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr><td align=center bgcolor=#FAFAFA>");
	new_window.document.writeln("<img src="+filename+" border=1 onClick=\"window.close();\"");
	new_window.document.writeln("</td></tr></table>");
	new_window.document.write("</BODY></HTML>");
	new_window.document.close();
}

// end Open Image


// Function Site

function portfolioLoad02(sIdup, sId, sPage, sRnd) {
	sFileParam = 'idup=' + sIdup + '&amp;id=' + sId + '&amp;page=' + sPage + '&amp;rnd=' + sRnd;
  	flashWrite('imdesign/flash/'+sPortfolioFile01, 362, 290, sFileParam, 'load02');
	sText = '<img src="imdesign/head_portfolio' + sIdup + '.gif" width="400" height="100" class="png_filter" galleryimg="no">';
	document.getElementById('load04').innerHTML = sText;
}

function portfolioLoad03(sIdup, sId, sPage, sCount, sRnd) {
	sFileParam = 'idup=' + sIdup + '&amp;id=' + sId + '&amp;page=' + sPage + '&amp;count=' + sCount + '&amp;rnd=' + sRnd;
	flashWrite('imdesign/flash/'+sPortfolioFile02, 190, 435, sFileParam, 'load03');
	if (sCount==20) {
		doVisibleOff('load05');
	} else {
		doVisibleOn('load05');
	}
}

function doShowImage(sImage, sTitle) {
	var objLoadingLink = document.createElement("a");
	objLoadingLink.setAttribute('id', 'loadingLink');
	objLoadingLink.setAttribute('rel', 'lightbox');
	objLoadingLink.setAttribute('title', sTitle);
	objLoadingLink.setAttribute('href', sImage);
	myLightbox.start(objLoadingLink);
}

function doShowStudy(sID) {
	JavaScript:window.open('study.php?id=' + sID);
}
