function killErrors() {
return true;
}
window.onerror =killErrors;

function goToIndex(index)
{
	 document.getElementById("tab1-iframe").contentWindow.goToIndex(index);
	 //
	changeMenuStyle(index);
	
	$("#colorDiv").hide();
	$(".bigimg").hide();
	$("#contentDiv").css("display","block");
	 //
	}
function changeMenuStyle(index)
{
	 $(".menulist span").removeClass();
	 $("#menu"+index).addClass("c96C733");
}
//
//
var bodyWidth,bodyHeight;
var canvasTop,canvasLeft;
var mouseX,mouseY;
var _poly,flag;
 
var f='0';
 
var canvasWeight=1024;
var canvasHeight=560;
 
var goUrlFlog=1;
$(document).ready(function(){
	
  bodyWidth=$(document.body).outerWidth(true);
  bodyHeight=$("#top").outerHeight(true)+5;
  
  if(bodyWidth>canvasWeight)
  canvasLeft=(bodyWidth-canvasWeight)/2;
  else
  canvasLeft=0;
  
  canvasTop=bodyHeight;
  $(".bigimg").hide();
 
  $("#indexmiddle").mouseleave(function(){
	if(goUrlFlog=='1')
	{if(f=='0'){
	$("#img1").show();
	$("#img2").show();
	$("#img3").show();
	$("#img4").show();
	$("#img5").show();
	$("#img6").show();
	$("#divbg1").hide();
	$("#divbg2").hide();
	$("#divbg3").hide();
	$("#divbg4").hide();
	$("#divbg5").hide();
	$("#divbg6").hide();}
	}
	});

$("#colorDivLine").mousemove(function(e){
	 
	var mouseCoo = mouseCoordination(e);
	mouseX=mouseCoo.x-canvasLeft;
	mouseY=mouseCoo.y-canvasTop;
	   //
	var pt=new point();
    pt.x=mouseX;
    pt.y=mouseY;  
	    
   if(f=='0'){
	    //_poly=[{x:0,y:0},{x:129,y:0},{x:534,y:314},{x:217,y:560},{x:0,y:560}];
		_poly=[{x:0,y:23},{x:129,y:23},{x:534,y:335},{x:215,y:582},{x:0,y:582}];
    flag=PointInPoly(pt,_poly);
    if(flag){
    $("#img1").hide();
    $("#divbg1").show();
    }else{
    $("#img1").show();
    $("#divbg1").hide(); }
  
   //
    //_poly=[{x:141,y:0},{x:603,y:0},{x:653,y:224},{x:543,y:308}];
	_poly=[{x:141,y:23},{x:603,y:23},{x:653,y:247},{x:543,y:331}];
    flag=PointInPoly(pt,_poly);
    if(flag){
    $("#img2").hide();
    $("#divbg2").show();
	}else{
    $("#img2").show();
    $("#divbg2").hide();}
   //
   //_poly=[{x:611,y:0},{x:945,y:0},{x:660,y:218}];
   _poly=[{x:611,y:23},{x:945,y:23},{x:660,y:241}];
   flag=PointInPoly(pt,_poly);
  if(flag){
   $("#img3").hide();
    $("#divbg3").show();}
   else{
   $("#img3").show();
   $("#divbg3").hide();}
   //
    //_poly=[{x:953,y:0},{x:1024,y:0},{x:1024,y:353},{x:772,y:508},{x:467,y:379}];
	_poly=[{x:953,y:23},{x:1024,y:23},{x:1024,y:376},{x:772,y:531},{x:464,y:402}];
   flag=PointInPoly(pt,_poly);
  if(flag){
   $("#img4").hide();
    $("#divbg4").show();}
   else{
   $("#img4").show();
   $("#divbg4").hide();}
   //
    //_poly=[{x:1024,y:359},{x:1024,y:560},{x:702,y:560}];
	_poly=[{x:1024,y:382},{x:1024,y:583},{x:702,y:583}];
   flag=PointInPoly(pt,_poly);
  if(flag){
   $("#img5").hide();
    $("#divbg5").show();}
   else{
   $("#img5").show();
   $("#divbg5").hide();}
   ///
      //_poly=[{x:228,y:560},{x:459,y:384},{x:765,y:513},{x:688,y:560}];
	  _poly=[{x:228,y:583},{x:459,y:406},{x:765,y:536},{x:688,y:583}];
   flag=PointInPoly(pt,_poly);
   if(flag){
   $("#img6").hide();
   $("#divbg6").show();}
   else{
   $("#img6").show();
   $("#divbg6").hide();}
	   }
	 
 }).click(function(){
	f='1';
   var pt=new point();
   pt.x=mouseX;
   pt.y=mouseY;  
   
  //one-colorDiv click
   //_poly=[{x:0,y:0},{x:129,y:0},{x:534,y:314},{x:217,y:560},{x:0,y:560}];
   _poly=[{x:0,y:23},{x:129,y:23},{x:534,y:335},{x:215,y:582},{x:0,y:582}];
   flag=PointInPoly(pt,_poly);
   if(flag)
    imgClick('1');
	//$("#divbg1").hide();
   //
  // _poly=[{x:141,y:0},{x:603,y:0},{x:653,y:224},{x:543,y:308}];
   _poly=[{x:141,y:23},{x:603,y:23},{x:653,y:247},{x:543,y:331}];
   flag=PointInPoly(pt,_poly);
   if(flag)
   imgClick("2");
  // $("#divbg2").hide();
   //
   //_poly=[{x:611,y:0},{x:945,y:0},{x:660,y:218}];
   _poly=[{x:611,y:23},{x:945,y:23},{x:660,y:241}];
   flag=PointInPoly(pt,_poly);
   if(flag)
   imgClick("3");
   //
  // _poly=[{x:953,y:0},{x:1024,y:0},{x:1024,y:353},{x:772,y:508},{x:467,y:379}];
   _poly=[{x:953,y:23},{x:1024,y:23},{x:1024,y:376},{x:772,y:531},{x:464,y:402}];
   flag=PointInPoly(pt,_poly);
   if(flag)
   imgClick("4");
   //
   //_poly=[{x:1024,y:359},{x:1024,y:560},{x:702,y:560}];
   _poly=[{x:1024,y:382},{x:1024,y:583},{x:702,y:583}];
   flag=PointInPoly(pt,_poly);
   if(flag)
   imgClick("5");
   // 
   //_poly=[{x:228,y:560},{x:459,y:384},{x:765,y:513},{x:688,y:560}];
   _poly=[{x:228,y:583},{x:459,y:406},{x:765,y:536},{x:688,y:583}];
   flag=PointInPoly(pt,_poly);
   if(flag)
   imgClick("6");
   
});
	 //
	 loadPicArr("img",'0','12');	
 //
});
//

var colorIndex=0;
function hideColorDiv()
{
	for(i=1;i<=6;i++){
			 if(i!=colorIndex)
			     {
					  $("#colorDiv"+i).hide();
					  goUrlFlog=0;
					  f='0';
					  if(colorIndex==1)
					  {
						   var url='list.php?id1='+colorIndex;
						   $("#tab1-iframe").attr("src",url);
						   //$("#tab1-iframe").attr("src","building.html");
                           $("#tab1-iframe").load( function(){
								var menuHtml=$(this).contents().find("#menu").html();
								$("#menu").html(menuHtml);
								$(".menulist span").removeClass("c96C733");
								});
					  }
					   if(colorIndex==2)
					  {
						   var url='list.php?id1='+colorIndex;
						   $("#tab1-iframe").attr("src",url);
						   //$("#tab1-iframe").attr("src","building.html");
                           $("#tab1-iframe").load( function(){
								var menuHtml=$(this).contents().find("#menu").html();
								$("#menu").html(menuHtml);
								$(".menulist span").removeClass("c96C733");
								});
					  }
					   if(colorIndex==3)
					  {
						  var url='news.php?id1='+colorIndex;
						   $("#tab1-iframe").attr("src",url);
						   $("#tab1-iframe").load( function(){
								var menuHtml=$(this).contents().find("#menu").html();
								$("#menu").html(menuHtml);
								$(".menulist span").removeClass("c96C733");
								});
					  }
					  if(colorIndex==4)
					  { 
					  		var url='location.php?id1='+colorIndex;
						   $("#tab1-iframe").attr("src",url);
						   $("#tab1-iframe").load( function(){
								var menuHtml=$(this).contents().find("#menu").html();
								$("#menu").html(menuHtml);
								$(".menulist span").removeClass("c96C733");
								});
					  }
					   if(colorIndex==5)
					  {
						 var url='floor.php?id1='+colorIndex;
						   $("#tab1-iframe").attr("src",url);
						   $("#tab1-iframe").load( function(){
								var menuHtml=$(this).contents().find("#menu").html();
								$("#menu").html(menuHtml);
								$(".menulist span").removeClass("c96C733");
								});
					  }
					   if(colorIndex==6)
					  {		var url='gallery.php?id1='+colorIndex;
						   $("#tab1-iframe").attr("src",url);
						   $("#tab1-iframe").load( function(){
								var menuHtml=$(this).contents().find("#menu").html();
								$("#menu").html(menuHtml);
								$(".menulist span").removeClass("c96C733");
								});
					  }
					 
					 }
			 }
}
//
function pancelClick(index)
{
	colorIndex=index;
	$("#img"+index).hide(100,function(){
		setTimeout("$('#colorDivLine').hide()", 200);
		setTimeout("hideColorDiv()", 400);
	 });
}
function imgClick(index)
{
	goUrlFlog=0;
    f='0';
	/*if(index==5){
		window.location.href="floor.php?id1="+index; 
	}else if(index==4){
		window.location.href="location.php?id1="+index; 
	}else if(index==3){
		window.location.href="news.php?id1="+index; 
	}else
		window.location.href="list.php?id1="+index;*/
	if(index==1){
		window.location.href=linkurl1; 
	}
	if(index==2){
		window.location.href=linkurl2; 
	}
	if(index==3){
		window.location.href=linkurl3; 
	}
	if(index==4){
		window.location.href=linkurl4; 
	}
	if(index==5){
		window.location.href=linkurl5; 
	}
	if(index==6){
		window.location.href=linkurl6; 
	}
}
//function
function mouseCoordination(michael){   
   
     if(michael.pageX || michael.pageY){   
 
      return {x:michael.pageX, y:michael.pageY};   
      }   
      else return {   

       x:michael.clientX + document.body.scrollLeft - document.body.clientLeft,   
       y:michael.clientY + document.body.scrollTop  - document.body.clientTop   
       };   
         
} 

function PointInPoly(pt, poly) {
    for (var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i) 
        ((poly[i].y <= pt.y && pt.y < poly[j].y) || (poly[j].y <= pt.y && pt.y < poly[i].y)) 
        && (pt.x < (poly[j].x - poly[i].x) * (pt.y - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x) 
        && (c = !c); 
    return c; 
}
function point(){
 this.x=0;
 this.y=0;
}
//
 function loadPicArr(picCanvas,i,num)
{
        var i=i;
        var t=$("#"+picCanvas+i);
		var src=t.attr("thissrc");
		if(typeof(src)=='undefined') return;
		
		var loadpic="images/loading.gif";
		var errorpic="";
		var img=new Image();
		//alert("Loading..."+src); 
		//var loading=$("<div style='margin-top:25%; margin-left:50%;position:absolute;'><img border=0 alt=\"loading...\" title=\"loading...\" src=\""+loadpic+"\" /></div>");
		var loading=$("<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center' valign='middle'><img border=0 alt=\"loading...\" title=\"loading...\" src=\""+loadpic+"\" /></td></tr></table>");
		/*if(i=='1'||i=='7'){
			var loading=$("<div style='margin-top:60%; margin-left:40%;position:absolute;'><img border=0 alt=\"loading...\" title=\"loading...\" src=\""+loadpic+"\" /></div>");
		
		}
		if(i=='2'||i=='8'){
			var loading=$("<div style='margin-top:60%; margin-left:50%;position:absolute;'><img border=0 alt=\"loading...\" title=\"loading...\" src=\""+loadpic+"\" /></div>");
		}
		if(i=='3'||i=='9'){
			var loading=$("<div style='margin-top:40%; margin-left:40%;position:absolute;'><img border=0 alt=\"loading...\" title=\"loading...\" src=\""+loadpic+"\" /></div>");
		}
		if(i=='4'||i=='10'){
			var loading=$("<div style='margin-top:50%; margin-left:60%;position:absolute;'><img border=0 alt=\"loading...\" title=\"loading...\" src=\""+loadpic+"\" /></div>");
		}
		if(i=='5'||i=='11'){
			var loading=$("<div style='margin-top:75%; margin-left:60%;position:absolute;'><img border=0 alt=\"loading...\" title=\"loading...\" src=\""+loadpic+"\" /></div>");
		}
		if(i=='6'||i=='12'){
			var loading=$("<div style='margin-top:50%; margin-left:50%;position:absolute;'><img border=0 alt=\"loading...\" title=\"loading...\" src=\""+loadpic+"\" /></div>");
		}if(i=='0'){
			var loading=$("<div style='margin-top:50%; margin-left:50%;position:absolute;'><img border=0 alt=\"loading...\" title=\"loading...\" src=\""+loadpic+"\" /></div>");
		}*/
		
		
		//var loading="";
		img.src=src;
	    t.attr("src","");
		t.hide();
		t.after(loading);
		
		 if($.browser.msie)
	          {		
			 /* alert("ddd");
			  loading.remove();
			t.attr("src",src);
			t.css("display","block");
			 return;*/
			
		         }/**/
		$(img).load(function(){
			//autoScaling();
			loading.remove();
			t.attr("src",src);
			t.show();
			 
			//grayscale(document.getElementById(picCanvas+i)); 
			//alert("ddd");
			if(i>num)
			{
			   // grayscale(t);
			    return "ok";
			}else
			{
			   i++;
			   loadPicArr(picCanvas,i,num);
			}
			//alert("finally!"+i);
		});
		
		// alert(img.complete); 
/*   If($.browser.msie)
  {
		 if (img.complete)
		 {
			 loading.remove();
			t.attr("src",src);
			t.show();
			//grayscale(document.getElementById(picCanvas+i)); 
			 if(i>num)
			{
			   // grayscale(t);
			    return "ok";
			}else
			{
			   i++;
			   loadPicArr(picCanvas,i,num);
			}
			 }
}*/
		//error 
		$(img).error(function(){
		  // alert("error");
		    loading.remove();
			t.attr("src",errorpic);
			t.show();
		     if(i>num)
			{
			    return "ok";
			}else
			{
			   i++;
			   loadPicArr(picCanvas,i,num);
			}
		}
		)
}
