// JavaScript Document
////////////////////////////top menu///////////////////////////////////////////////////////////////////////////////
var mXlocAry=[];
var mWAry=[];
var bartmpx=0;
var justchanged=false;
var submenuAry=[];
var mouseonsubmenu=false;
var mosec;///mouse over section

function settopmenu(num){
	bartmpx=num;
	 $('#menuselectbar').css('width',twAry[num]+parseInt($('.topmenuitem').css('margin-left'))*2);
var tmptmxbase=parseInt($('#topmenudiv').css('margin-left'));
var tmptmx=tmptmxbase;

	for(i=0;i<$('.topmenuitem').length;i++){
		mXlocAry.push(tmptmx);
		mWAry.push(twAry[i]+parseInt($('.topmenuitem').css('margin-left'))*2);
		$('.topmenuitem:eq('+i+')').css('left',(tmptmx-tmptmxbase-parseInt($('.topmenuitem').css('margin-left')))+'px');
		$('.topmenuitem:eq('+i+')').css('width',(parseInt($('.topmenuitem').css('margin-left'))*2+twAry[i])+'px');
		tmptmx+=parseInt($('.topmenuitem').css('margin-left'))*2+twAry[i];
		for(ii=0;ii<submenuAry[i].length;ii++){
			$('.submenu:eq('+i+') span:eq('+ii+')').hide();
		}
	}
	
	$('#menuselectbar').css('margin-left',mXlocAry[bartmpx]);
	$('.topmenuitem:eq('+bartmpx+')').css('color','#20c2a5');
	$('#submenudiv').css('display','none');
	
$('.topmenuitem').bind({
  click: function() {
		$('.topmenuitem').css('color','#246E6E');
		$(this).css('color','#20c2a5');
		bartmpx=$(this).index();
		justchanged=true;
		document.location=topmenuAry[$(this).index()];
  },
  mouseenter: function() {
	  var mynum=$(this).index();
	  mosec=mynum;
    $('#menuselectbar').clearQueue();
	$('#menuselectbar').animate({'width':mWAry[mynum],'margin-left':mXlocAry[mynum]},300);
	if(submenuAry[mynum].length>0){
		$('#submenudiv').css('display','block');
	}
	$('#submenudiv').html("");
	for(i=0;i<submenuAry[$(this).index()].length;i++){
		$('#submenudiv').append('<p>'+submenuAry[mynum][i][0]+'</p>');
	}
	$('#submenudiv').css('margin-left',mXlocAry[$(this).index()]+parseInt($('.topmenuitem').css('margin-left'))+(twAry[$(this).index()]/2)-parseInt($('#submenudiv').css('width'))/2);
	
	
	$('#submenudiv p').bind({
	mouseenter: function(){
		$(this).css('background-color','#9cc');
	},
	mouseleave: function(){
		$(this).css('background-color','#fff');
	},
	click: function(){
		document.location=submenuAry[mosec][$(this).index('#submenudiv p')][1];
	}
	});

  },
  mouseleave: function(e) {
	  var mynum=$(this).index();
	  if(e.pageY<101 && $('#submenudiv').css('display')=='block' || $('#submenudiv').css('display')=='none'){
	  		putitback();
		}else{
			setTimeout('checkonsubmenu()',100);
		}
  }
});


$('#submenudiv').bind({
  mouseenter: function() {
	  mouseonsubmenu=true;
	  
  },
  mouseleave: function() {
	putitback();
  }
  
});

var mylang;
var tmpaddAry=document.location.href.split('/');
var mypath=tmpaddAry[tmpaddAry.length-1];
var pathend=mypath.substr(mypath.length-4,4);

if(pathend==".php" || pathend==""){
	pathend="?";
}else{
	pathend="&";
}
if(lang==1){
	mylang='English';
	mypath+=pathend+"lang=0";
}else{
	mylang='Japanese';
	mypath+=pathend+"lang=1";
}
$('#langdiv p').text(mylang);
$('#langdiv p').click(function(){document.location=mypath});

}

//////////to check if mouse is on the submenu
function checkonsubmenu(){
	 if( !mouseonsubmenu ){
		 putitback();
	 }
}
function putitback(){
	mouseonsubmenu=false;
	$('#submenudiv').css('display','none');
	$('#menuselectbar').animate({'margin-left':mXlocAry[bartmpx],'width':mWAry[bartmpx]},300);
}
///////////left column button///////////////////////////////////////////////////////////////////////////////////////////
function setleftcolumnbutton(){
	for(i=0;i<lcmbtitleAry.length;i++){
		$('#leftcolumn').append('<p class="leftcolumnbtn">'+lcmbtitleAry[i]+'</p>');
	}
$('.leftcolumnbtn').data('ison',false);
$('.leftcolumnbtn').bind('mouseenter mouseleave', function() {
    if(!$(this).data('ison')){
  		$(this).toggleClass('leftcolumnbtnor');
	}
});
	
$('.leftcolumnbtn').click(function(){
								   $('.leftcolumnbtn').removeClass('leftcolumnbtnselected');
								   $('.leftcolumnbtn').removeClass('leftcolumnbtnor');
								   $('.leftcolumnbtn').data('ison',false);
								   $(this).data('ison',true);
								   $(this).toggleClass('leftcolumnbtnselected');
								   lcmbcmd($(this).index());
								   }
						  );
}
/////slideshow variables, used in Production pages too/////////////////////////////////////////////////
var stAry=["Web support","Illustration","Toon animation","Flash games","Graphic design","Christian cliparts"];//slide title array
var slidedisplaying=0;
var dotnum=6;
var ssint;
var issliding=false;
var ssimgAry=[];

var lg;
	if(lang==1){
		lg="j";
	}else{
		lg="";
	}
////preload slide images//////////////////////////////////////////////////////////////////////////////////////////////
function preloadslideimg(num){
	for(i=0;i<num;i++){
		ssimgAry.push(new Image());
		ssimgAry[i].src='images/slidepic'+lg+i+'.jpg';
		ssimgAry[i].width=670;
		ssimgAry[i].height=234;
	}
}
////gallery bg//////////////////////////////////////////////////////////////////////////////////////////////////////////
var gw=500;//gallery width
var gh=275;//gallery height
var animAry=[];

function creategallery(){
	$('#maindiv').append('<div id="captiondiv"></div>');
	$('#maindiv').append('<div id="gallery"><table align="center" style="margin-top:50px"><tr><td align="right" style="cursor:pointer"><img src="images/galleryclose.png"  id="galleryclose"></td></tr><tr><td id="cliptd" ></td></tr><tr><td id="gallerycopy" style="color:#fff">Description</td></tr></table></div>');
	$('#galleryclose').click(function(){
									  $('#gallery').hide();
									  $('#cliptd').html('');
									  });
	$('#gallery').hide();
	$('#captiondiv').hide();
}
function galleryup(gnum,gtitle,gw,gh,gprice,gtype,gary){
	if(gw=="url"){
		$('#gallery').hide();
		window.open(gh); 
	}else{
	$('#cliptd').html("");
	if(gnum>0){
		$('#cliptd').append('<img src="images/galleryprev.png" id="galleryprev" style="cursor:pointer" >');
		$('#galleryprev').click(function(){
										 $('#cliptd').html("");
										 galleryup(gnum-1,gary[gnum-1][0],gary[gnum-1][1],gary[gnum-1][2],gary[gnum-1][3],gtype,gary);
										 });
	}
$('#cliptd').append('<embed src="animations/'+gtype+gnum+'.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" menu="false" width="'+gw+'" height="'+gh+'"></embed>');
if(gnum<gary.length-1){
	$('#cliptd').append('<img src="images/gallerynext.png" id="gallerynext" style="cursor:pointer" >');
	$('#gallerynext').click(function(){
										 $('#cliptd').html("");
										 galleryup(gnum+1,gary[gnum+1][0],gary[gnum+1][1],gary[gnum+1][2],gary[gnum+1][3],gtype,gary);
										 });
}
$('#gallerycopy').html('<p><strong>Title: </strong>'+gtitle+'<br /><strong>Standard production fee: </strong>'+gprice+'</p>');
$('#gallery').show();
	
	}
}
function imggallery(gnum,gtitle,gtype,gtitleary,prefix,gimgary){
	$('#cliptd').html("");
	if(gnum>0){
		$('#cliptd').append('<img src="images/galleryprev.png" id="galleryprev" style="cursor:pointer" >');
		$('#galleryprev').click(function(){
										 $('#cliptd').html("");
										 imggallery(gnum-1,gtitleary[gnum-1],gtype,gtitleary,prefix,gimgary);
										 });
	}
$('#cliptd').append(gimgary[gnum]);
if(gnum<gtitleary.length-1){
	$('#cliptd').append('<img src="images/gallerynext.png" id="gallerynext" style="cursor:pointer"  >');
	$('#gallerynext').click(function(){
										 $('#cliptd').html("");
										imggallery(gnum+1,gtitleary[gnum+1],gtype,gtitleary,prefix,gimgary);
										 });
}
$('#gallerycopy').html('<p>'+gtitle+'</p>');
$('#gallery').show();
	
}

