/*
 *  iPadLoadStyle - jQuery plugin
 *  written by gecko
 *  http://gecko.hp2.jp/lotation_img/
 *
 *  Copyright (c) 2010 gecko (http://gecko.hp2.jp/)
 *  Dual licensed under the MIT (MIT-LICENSE.txt)
 *  and GPL (GPL-LICENSE.txt) licenses.
 *
 *  Built for jQuery library
 *  http://jquery.com
 *  Compatible with jQuery 1.4+
 *
 */
 
$.extend({
	iPadLoadStyle: function (opt) {
		var opt = jQuery.extend({
				common: false,
				landscape: false,
				portrait: false
			}, opt),
			iPad = /iPad/.test(navigator.userAgent),
			Android = /Android/.test(navigator.userAgent),
			d = document,
			$head = $("head"),
			linktag = function (h, m) {
				var tag = d.createElement("link");
				tag.href = h;
				tag.media = m;
				tag.type = "text/css";
				tag.rel = "stylesheet";
				return tag;
			};
		if (iPad) {
			//common
			if (opt.common) $head.append(linktag(opt.common, "only screen and (max-device-width: 1024px)"));
			//landscape
			if (opt.landscape) $head.append(linktag(opt.landscape, "all and (orientation:landscape)"));
			//portrait
			if (opt.portrait) $head.append(linktag(opt.portrait, "all and (orientation:portrait)"));
		}
		if (Android) {
			//common
			if (opt.common) $head.append(linktag(opt.common, "only screen and (max-device-width: 1024px)"));
			//landscape
			if (opt.landscape) $head.append(linktag(opt.landscape, "all and (orientation:landscape)"));
			//portrait
			if (opt.portrait) $head.append(linktag(opt.portrait, "all and (orientation:portrait)"));
		}
		return this;
	}
}); // JavaScript Document