
//common image preload

vimgname = new Array("gnavi_home_f2.gif","gnavi_product_f2.gif","gnavi_vieralife_f2.gif","gnavi_vierastory_f2.gif","gnavi_glossary_f2.gif","gnavi_sitemap_f2.gif");
vloadimg = new Array();
for(i=0; i<vimgname.length; i++){
	vloadimg[i] = new Image();
	vloadimg[i].src = '/avc/viera/common/img/' + vimgname[i];
}

function chImg(imgID, imgSRC) {
	document.images[imgID].src = imgSRC;
}




function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}





function CWinOpen(theURL,winName,getwinW,getwinH,features) {

	features = features + ',width=' + getwinW + ',height=' + getwinH;
	window.open(theURL,winName,features);

}

function FSOpen(FSurl,FSwinName){
	winH = screen.availHeight;
	winW = screen.availWidth;
	window.open(FSurl,FSwinName,"height="+winH+",width="+winW+",top=0,left=0,status=no,resizable=yes");
}


function ImgTitleAdd() {
	for(i=0; i<document.images.length; i++){
		document.images[i].title = "";
	}
}


// for SETUP Simulation
function MM_openBrWindow2(theURL,winName,features) { //v2.0
	popWin =  window.open(theURL,winName,features);
	popWin.focus();
}



// for e-book
function openBrWindow() 
{
	window.open('/avc/viera/popup/viera_magazine/2007_01/flash/F_viewer_standard.htm','Win1','scrollbars=no,resizable=yes,width=1014,height=674,left=0,top=0');
}


// for top swf
function newwin1()
{
	sub = window.open("/avc/viera/popup/story/index.html","story","status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=770,height=600");
}



function View360Open(){
	window.open("/avc/viera/3d/360view/index.html","eyeware","height=610,width=840,top=0,left=0,status=yes,resizable=no");
}




var Mac_ffFlag = "";
if(navigator.userAgent.indexOf("Mac") != -1 ){
	if(navigator.userAgent.toUpperCase().indexOf("FIREFOX") != -1 ){
		Mac_ffFlag = "FF";
	}
}

/*
var Win_ie6Flag = "";
if (typeof document.body.style.maxHeight != "undefined"){
}else{
	Win_ie6Flag = "ie6";
}*/



jQuery.noConflict();
var $j = jQuery;

$j(document).ready(function(){

// Global navi

	var timer;
		   
	function hideMenu(){
		$j(".gmenu").css("visibility", "hidden");
	}

	$j("img.menudisp").hover(
		function(){
										 
		hideMenu();

		if(timer){
			clearTimeout(timer);
		}

		var menuID = $j(this).attr("ID").replace(/gnavi/i, "gmenu");
			$j("#" + menuID).css("visibility", "visible");
		},
		function(){
			timer = setTimeout('$j(".gmenu").css("visibility", "hidden")', 500);
		}
		

	);

	$j("div.gmenu").hover(
		function(){
			if(timer){
				clearTimeout(timer);
			}
		},
		function(){
			$j(this).css("visibility", "hidden");
		}
	);

// image RollOver

	var preloadImg = new Object;
	$j("img.imgro").each(
		function(){
			var imgSrc = this.src;
			var dotNum = imgSrc.lastIndexOf("." , imgSrc.length);
			var replaceStr = imgSrc.substr(dotNum, imgSrc.length);
			var imgOnSrc = imgSrc.replace(replaceStr, "_f2" + replaceStr);
			preloadImg = new Image();
			preloadImg.src = imgOnSrc;
			$j(this).hover(
				function(){this.src = imgOnSrc;},
				function(){this.src = imgSrc;}
			);
	});




		$j("div .menu-contents").click(function(){
			var blocklink = $j(this).find("a");
			if(blocklink.attr("href") != undefined){
				if(blocklink.attr("target") == "_blank"){
					window.open(blocklink.attr("href"));
				}else{
					window.location = blocklink.attr("href");
				}
			}
			return false;
		});

		$j("div .menu-contents").hover(
				function(){
					var blocklink = $j(this).find("a");
					if(blocklink.attr("href") != undefined){
						$j(this).addClass("menu-hover");
					}
				},
				function(){$j(this).removeClass("menu-hover");}
		);


// image Fade

	$j(".imgfade").hover(

		function(){
			$j(this).addClass("fadeon");
		},
		function(){
			$j(this).removeClass("fadeon");
		}

	);


// for ipad

	if(navigator.userAgent.toUpperCase().indexOf("IPAD") != -1 || navigator.userAgent.toUpperCase().indexOf("IPHONE") != -1){
		$j(".menu-foot").css("marginTop", "-1px");
		$j(".addthis_button_google_plusone").css("display", "none");
	}


});


