
function hpics (dir, token, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12) {
    pics (true, true, dir, token, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12);
}

function vpics (dir, token, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12) {
    pics (false, true, dir, token, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12);
}

function hpics2 (dir, token, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12) {
    pics (true, false, dir, token, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12);
}

function vpics2 (dir, token, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12) {
    pics (false, false, dir, token, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12);
}

function pics (is_h, is_normal, dir, token, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12) {
	    
    var i = 0, j;
    var ids = new Array();
    if (typeof(id1) != "undefined") ids[i++] = id1;
    if (typeof(id2) != "undefined") ids[i++] = id2;
    if (typeof(id3) != "undefined") ids[i++] = id3;
    if (typeof(id4) != "undefined") ids[i++] = id4;
    if (typeof(id5) != "undefined") ids[i++] = id5;
    if (typeof(id6) != "undefined") ids[i++] = id6;
    if (typeof(id7) != "undefined") ids[i++] = id7;
    if (typeof(id8) != "undefined") ids[i++] = id8;
    if (typeof(id9) != "undefined") ids[i++] = id9;
    if (typeof(id10) != "undefined") ids[i++] = id10;
    if (typeof(id11) != "undefined") ids[i++] = id11;
    if (typeof(id12) != "undefined") ids[i++] = id12;
    
    show_img_multi (is_h, is_normal, dir, token, ids);
}

function show_img_multi (is_h, is_normal, dir, token, ids) {
	
    var tail = "y.jpg";	
    if (screen.width >= 1280) tail = "u.jpg";
    if (screen.width >= 1600) tail = "w.jpg";
    if (!is_normal) tail = "y.jpg";
	
    var fn, j, s = '<br>', n = ids.length;	
    for (j = 0; j < n; j++) {
    	    fn = dir + token + ids[j] + tail;
    	    if (j != n-1) 
    	    	show_img (is_h, is_normal, fn);
    	    else
    	    	show_img (is_h, is_normal, fn, '<p>'); 
    	}	
}

function show_img (is_h, is_normal, fn, s) {
	
    var width = 600;
    if (screen.width >= 1280) width = 810;
    if (screen.width >= 1600) width = 1050;
    if (!is_normal) {
    	width = 450;
    	if (screen.width >= 1280) width = 600;
    	if (screen.width >= 1600) width = 750;
    }
    
    var height = 540;
    if (screen.width >= 1280) height = 720;
    if (screen.width >= 1600) height = 810;
    if (!is_normal) {
    	height = 420;
    	if (screen.width >= 1280) height = 540;
    	if (screen.width >= 1600) height = 630;
    }
    
    var style_s = 'width:' + width; 
    if (!is_h) style_s = 'height:' + height;
    
    document.write('<a href="' + fn + '"><img style=";' + style_s + 'px;" src="' + fn + '"></a><br>');
    if (typeof(id12) != "undefined") document.write(s);
//    document.write('<a href="' + fn + '"><img style=";width:' + width + 'px;" src="' + fn + '"></a><br>' + s);
}

var bg_tails = new Array (
	new Array ( 0,     "1024x550"),	// 1024x550, c
	new Array ( 1024,  "1024x550"),	// 1024x550, 1024, 800, 600, ... 1024x768 1280x800
	new Array ( 1280,  "1280x580"),	// 1280x580, 1280, 1152
	new Array ( 1680,  "1680x780"),	// 1680x780, 1680, 1600, 1440   1680x1050, 1920x1080
	new Array ( 1920,  "1920x810"),	// 1920x810, 1920
	new Array ( 2560,  "1920x810")	// 1920x810, 2560
);

function bg_tail () {
    var s2 = "1920x550";  		// default: 1920x550
    for (var i = bg_tails.length-1; i >= 0; i--)
    	if (screen.width <= bg_tails[i][0]) 
    	    s2 = bg_tails[i][1];
    return s2;
}

var bgs = new Array (
//	"Gondola01", 
	"Progue03", "Progue05", "Progue06", 
	"Santorini07", "Santorini09", "Ia17", 
	"Mykonos09", "Mykonos10", 
	"Venice01", "Venice17", "Musk01", 
	"Manver01", "Khuri01", 
	"AMS17", "AMS30", "AMS51", 
	"BBC03", "Yun20", "Firework24"
);

function set_banner_h () {
    var s2 = bg_tail();
    var sp = s2.split("x");
    var h = sp[1] - 55;
    var obj = document.getElementById("banner");
    obj.style.height = h + 'px';
}

function set_bg (fn) {
    var bgfn = "/icon/blog/" + fn + "_" + bg_tail() + ".jpg";
//    bgfn = "/icon/Ia17_1024x550.jpg";
    document.body.background = bgfn;
    set_banner_h ();
}

var curr_j = 0;

function set_bg_auto () {	
    var j;
    if (cookie_bg_index_exist()) 
    	j = cookie_bg_index_get();
    else
       	j = Math.floor((new Date()).getTime()/(1000*60*60*24));	// every 24 hours
//    j = Math.floor((new Date()).getTime()/(1000*60*60*24));	// every 24 hours
    curr_j = j % bgs.length;
    curr_j = bgs.length - 1;	// 2010.1.1 firework24
    set_bg (bgs[curr_j]);
}

function set_bg_next () {	
    curr_j = (curr_j + 1) % bgs.length;
    set_bg (bgs[curr_j]);
    cookie_bg_index_set (curr_j);
}

function set_bg_prev () {	
    curr_j = (curr_j + bgs.length - 1) % bgs.length;
    set_bg (bgs[curr_j]);
    cookie_bg_index_set (curr_j);
}

set_bg_auto ();

function set_bg_ramdom () {	
    var j = Math.floor(Math.random()*bgs.length);	// 6 Hours
    set_bg (bgs[j]);
}

// ------ cookie -----------

var cookie_bg_i = "yhkuan_blog_index";

function cookie_bg_index_set (index) {
    var s1 = "yhkuan_blog_index";
    var exp = new Date();
    exp.setTime (exp.getTime() + (1000*60*60*24*365*100));	// keep 100 years, forever
    cookie_set (s1, index, exp);
}

function cookie_bg_index_get () {
    var s1 = "yhkuan_blog_index";
    return Math.floor (cookie_get (s1));
}

function cookie_bg_index_exist () {
    var s1 = "yhkuan_blog_index";
    return cookie_get( s1 );
}

function cookie_get (s) {
    var dc = document.cookie;
    if (dc.length > 0) {
        var s2 = dc.split(";");
        for (i = 0; i < s2.length; i++)
            if (s2[i].indexOf(s) != -1) {
            	var s3 = s2[i].split("=");
            	return s3[1];
            }     
   }
   return null;
}  
 
function cookie_set (name, value, expires) {
    if (expires == null) expires = "";
    document.cookie = name + "=" + value + ";path=/" +"; expires=" + expires.toGMTString();
}

// 每天自動更換一張


/*
	body {
		margin:20px 20px 20px 20px;
		margin:15px 15px 15px 15px;
		background:#FFF;
		background:#111;
		overflow:auto;					
  		background-repeat:no-repeat;
  		background-image:url("/icon/Ia17_1680x550.jpg");	
		}

<script language="JavaScript" src="/plog.js"></script>
<br>
<a href="/travel/2003/Venice/Intro.html" style="; font-size:16px; font-weight:normal; text-decoration:none; margin-right:12px; ">個人簡介</a>
<a href="/memo/service/" style="; font-size:16px; font-weight:normal; text-decoration:none; margin-right:12px; ">耀輝工作室</a>
<a href="/" style="; font-size:16px; font-weight:normal; text-decoration:none; margin-right:12px; ">個人網站</a>
<a href="index.php?op=ViewArticle&articleId=126&blogId=1" style="; font-size:16px; font-weight:normal; text-decoration:none; margin-right:12px; ">留言版</a>
<a href="mailto:yh@kuan.cc" style="; font-size:16px; font-weight:normal; text-decoration:none; margin-right:12px; ">email</a>
<a href="index.php?op=ViewArticle&articleId=166&blogId=1" style="; font-size:15px; font-weight:normal; text-decoration:none; margin-right:12px; ">再見聯電</a>
<br>
<a href="index.php?op=ViewArticle&articleId=409&blogId=1" style="; font-size:15px; font-weight:normal; text-decoration:none; margin-right:12px; ">耀輝攝影入門兩天班</a>
<a href="index.php?op=ViewArticle&articleId=461&blogId=1" style="; font-size:15px; font-weight:normal; text-decoration:none; margin-right:12px; ">耀輝攝影平日家教班</a>
<a href="javascript:set_bg_next();" style="; font-size:15px; font-weight:normal; text-decoration:none; margin-right:12px; ">挑喜歡的部落格大圖</a>
<br>
<iframe src="/php/yhkuan/index2.php" width=115 height=19 frameborder=0 marginheight=0 marginwidth=0 align=left scrolling=no></iframe>


*/	
