var url = location.href;
var ua = navigator.userAgent;
var path = "";
var page = "";
var $jq = jQuery.noConflict();
//_________________________________________________________
//                                           汎用関数

function setPath(num) {
	
	if(num == 0 || num == undefined) {
		path = "./";
	}else {
		for(i = 0; i < num; i++) {
			path += "../";
		}
	}
	
	getPageName(num);
	
	delete num;
	
}

function getPageName(num) {
	
	if(url.match("/concept/")) page = "concept";
	else if(url.match("/products/")) page = "products";
	else if(url.match("/topics/")) page = "topics";
	else if(url.match("/shop/")) page = "shop";
	else if(num == 0)  page = "home";
	
	delete num;
}

//_________________________________________________________
//                                           アクセス解析
document.write('<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>');
function analytics() {
	_uacct = "UA-1491266-1";
	urchinTracker();
}

//_________________________________________________________
//                                           ヘッダメニュー

function attachHeaderNav(num) {
	var mainNav = new Array("logo", "gnav_btn1_off", "gnav_btn2_off", "gnav_btn3_off", "gnav_btn4_off");
	
	if(url.match("/concept/")) mainNav[2] = "gnav_btn2_on";
	else if(url.match("/products/")) mainNav[3] = "gnav_btn3_on";
	else if(url.match("/shop/")) mainNav[4] = "gnav_btn4_on";
	else if(num == 0) mainNav[1] = "gnav_btn1_on";
	
	document.write('<div id="header">');
	document.write('<h1>SUSIE N.Y.</h1>');
	document.write('<div id="head_logo">');
	document.write('<div id="logo"><a href="' + path +'index.html"><img src="' + path +'common2/logo.gif" alt="susie" width="197" height="19" /></a></div>');
	document.write('<ul id="sub_nav">');
	document.write('<li><a href="' + path +'contact/index.html"><img src="' + path +'common2/head_nav3.gif" alt="" width="108" height="24" /></a></li>');
	document.write('<li><a href="' + path +'friends/index.php"><img src="' + path +'common2/head_nav2.gif" alt="" width="108" height="24" /></a></li>');
	document.write('<li><a href="' + path +'mobile/index.html"><img src="' + path +'common2/head_nav1.gif" alt="" width="94" height="24" /></a></li>');
	document.write('</ul>');
	document.write('</div>');
	document.write('<div class="clear">&nbsp;</div>');
	document.write('<ul id="g_nav">');
	document.write('<li><a href="' + path +'index.html"><img src="' + path +'common2/' + mainNav[1] + '.gif" alt="" width="74" height="30" /></a></li>');
	document.write('<li><img src="' + path +'common2/gnav_line.gif" alt="" width="2" height="30" /></li>');
	document.write('<li><a href="' + path +'concept/index.html"><img src="' + path +'common2/' + mainNav[2] + '.gif" alt="" width="143" height="30" /></a></li>');
	document.write('<li><img src="' + path +'common2/gnav_line.gif" alt="" width="2" height="30" /></li>');
	document.write('<li><a href="' + path +'products/index.html"><img src="' + path +'common2/' + mainNav[3] + '.gif" alt="" width="94" height="30" /></a></li>');
	document.write('<li><img src="' + path +'common2/gnav_line.gif" alt="" width="2" height="30" /></li>');
	document.write('<li><a href="' + path +'shop/index.html"><img src="' + path +'common2/' + mainNav[4] + '.gif" alt="" width="99" height="30" /></a></li>');
	document.write('</ul>');
	document.write('<div class="clear">&nbsp;</div>');
	document.write('</div>');
	
	delete num;
}


function attachFooter(num) {
	
	document.write('<div id="footer">');
	document.write('<div id="foot_copy"><img src="' + path +'common2/footer_copy.gif" alt="" width="305" height="13" /></div>');
	document.write('<ul id="foot_nav">');
	document.write('<li><a href="' + path +'privacy/index.html"><img src="' + path +'common2/footer_privacy_off.gif" alt="" width="90" height="13" /></a></li>');
	document.write('<li><a href="' + path +'terms/index.html"><img src="' + path +'common2/footer_terms_off.gif" alt="" width="80" height="13" /></a></li>');
	document.write('</ul>');
	document.write('<div class="clear">&nbsp;</div>');
	document.write('</div>');
	
	analytics();
	
	delete num;
}
        
  
//_______________________________________________________________________
//                                           メールマガジン　ポップアップ

function mailFromPopup() {
	
	var id = "mail-area";
	var id2 = "form-area";
	
	if(document.getElementById) {
		document.getElementById(id).style.display = "block";
		document.getElementById(id2).style.display = "block";
	}else if(document.all) {
		document.all.id.style.display = "block";
		document.all.id2.style.display = "block";	}
	
}

function mailFormClose() {
	
	var id = "mail-area";
	var id2 = "form-area";
	
	if(document.getElementById) {
		document.getElementById(id).style.display = "none";
		document.getElementById(id2).style.display = "none";
	}else if(document.all) {
		document.all.id.style.display = "none";
		document.all.id2.style.display = "none";
	}
}

//_______________________________________________________________________
//                                     ルージュ　グラマラス　ポップアップ
function app_popup(url, width, height){
	window.open(url, "WindowOpen", "toolbar=yes, status=no, scrollbars=yes, resizable=yes, width=" + width +", height=" + height);	
}

//_________________________________________________________________
//                                           ニュース成分表オープン
function news_el_winOpen(theURL) { //v2.0
	var winName = "newselement";
	var features = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=352,height=355";
	window.open(theURL,winName,features);
}

//_________________________________________________________
//                                           ロールオーバー
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_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 attach_shoplist_text(){
	var htmlsrc ="";
	htmlsrc += '<img src="images/shop_t.gif" alt="Shop List" width="685" height="57" id="shop" /><p style="width:680px;margin: 5px 0px 0px 35px;font-size:11px;">2011年1月現在の取扱い店舗となっております。店舗改装等の理由で取扱いが中止になる場合もありますので、あらかじめご確認いただけますようお願い申し上げます。また、取扱い商品が店舗ごとに異なる場合があります。各店舗へお問い合わせください。</p>';
	
	if(url.match("/shop/")){
		$jq("#shop").replaceWith(htmlsrc);
	}
}

$jq(document).ready(attach_shoplist_text);



//_____________________________________________________
//                                    全体ロールオーバー

$jq(function(){
    $jq("img[src*='_on']").addClass("current");
  
    $jq("img,input[type='image']").hover(function(){
        if ($jq(this).attr("src")){
            $jq(this).attr("src",$jq(this).attr("src").replace("_off.", "_on."));
        }
    },function(){
        if ($jq(this).attr("src") && !$jq(this).hasClass("current") ){
            $jq(this).attr("src",$jq(this).attr("src").replace("_on.", "_off."));
        }
    });
});




function msie(){
	if(ua.match("MSIE 7")){
			$jq("#head_logo").css("height" , "78px");
	}
}

$jq(window).load(msie);








