/*
 * common.js
 *
 */
 


// onload event set
//
window.onload = function () { 
	swapImage.init();
}


// popup
//
function fWinClosed(winVar) {
var ua = navigator.userAgent
	if( !!winVar )
		if( ( ua.indexOf('Gecko')!=-1 || ua.indexOf('MSIE 4')!=-1 ) && ua.indexOf('Win')!=-1 ) 
				return winVar.closed
			else return typeof winVar.document  != 'object'
	else return true
}
function fOpenWin(theURL,targetName,theW,theH) {
	if(fWinClosed(tWin)){
		var tWin = window;
		tWin = open(theURL,targetName,'scrollbars=yes,resizable=yes,toolbar=no,location=yes,directories=no,status=yes,menubar=yes,width='+theW+',height='+theH+'');
		tWin.focus();
	}
}
function fOpenSP(theURL,targetName,theW,theH) {
	if(fWinClosed(tWin)){
		var tWin = window;
		tWin = open(theURL,targetName,'scrollbars=no,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,width='+theW+',height='+theH+'');
		tWin.focus();
	}
}


// tvcm
//
function wmvConvert(){
	document.write('<object id="MediaPlayer" width="320" height="280" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" align="middle">\n');
	document.write('<param name="FileName" value="wmv/cm.wmv">\n');
	document.write('<param name="Showcontrols" value="true">\n');
	document.write('<param name="AutoStart" value="true">\n');
	document.write('<param name="ShowStatusBar" value="false">\n');
	document.write('<param name="ShowDisplay" value="false">\n');
	document.write('<embed type="application/x-mplayer2" src="wmv/cm.wmv" pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&" showcontrols="false" autostart="true" showstatusbar="true" showdisplay="false" width="320" height="280" filename="wmv/cm.wmv" align="middle"></embed>\n');
	document.write('</object>');
}


// pageup scroll
/*
function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 50);
    }
}
*/

function fTabChange(tabid) {
	arr = new Array();
	arr[0] = "_df.";
	arr[1] = "_ov.";
	arr[2] = "_ac.";
	img = new Image()
	
	// 1つめの引数はidの為その分を引く
	for(i=0; i < arguments.length-1; i++) {
		img = document.getElementById(tabid).getElementsByTagName('li')[i].getElementsByTagName('img')[0];
		switch(arguments[i+1]){
			case 0:
				str = img.src.replace(arr[2], arr[0]);
				str = str.replace(arr[1], arr[0]);
				break;
			case 1:
				str = img.src.replace(arr[0], arr[2]);
				str = str.replace(arr[1], arr[2]);
				break;
    }
		img.src = str;
	}

}


// ウエディングレポートのスライドショー
function fReportOv() {
	var class_df = "ui-tabs-selected";	

	$("div#dReportPicArea > ul li img").each(function(i, item){
			var a = $(item).parent().get(0);
			var li_class = $(a).parent().get(0).className;
			var src = $(this).attr('src');
			
			if(class_df == li_class)	{
				
				$(item).attr('src', src.replace("_df","_ac"));
				src = $(this).attr('src');
				$(item).attr('src', src.replace("_ov","_ac"));
			}
			else {
				$(item).attr('src', src.replace("_ac","_df"));
			}
	});
	return false;
}