├── resources ├── index.php ├── css │ ├── index.php │ └── styles.css ├── scripts │ ├── index.php │ ├── loadURL.php │ ├── js_functions.js │ ├── stateless.php │ ├── functions.php │ └── jquery.min.js └── images │ ├── bg.gif │ ├── JPL_Logo.png │ └── nasa-logo.png ├── xml └── xml │ ├── index.php │ ├── ic │ ├── index.php │ └── template.xml │ ├── config.xml │ └── content.xml ├── readme.pdf ├── README.md ├── map.xml ├── start.html ├── index.php └── LICENSE /resources/index.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /xml/xml/index.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /resources/css/index.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /xml/xml/ic/index.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /readme.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/cash/HEAD/readme.pdf -------------------------------------------------------------------------------- /resources/scripts/index.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /resources/images/bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/cash/HEAD/resources/images/bg.gif -------------------------------------------------------------------------------- /resources/images/JPL_Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/cash/HEAD/resources/images/JPL_Logo.png -------------------------------------------------------------------------------- /resources/images/nasa-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/cash/HEAD/resources/images/nasa-logo.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cash 2 | ==== 3 | 4 | Cassini Structured Homepages uses LDAP authorization to provide a security layer to webpage content 5 | -------------------------------------------------------------------------------- /map.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | /Users/dconner/cash/installed/xml 4 | 5 | -------------------------------------------------------------------------------- /start.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Congratulations! You have successfully deployed the CASH Framework

7 |

Getting Started

8 |

Feel free to explore the sample content that has been included with this deployment.

9 |

The following contents are defined in start.html.

10 |

You can change the contents of start.html as well as its filename. 11 | If you change the filename, you must update config.xml with the new 12 | filename.

13 | 14 | 15 | -------------------------------------------------------------------------------- /resources/scripts/loadURL.php: -------------------------------------------------------------------------------- 1 | 46 | -------------------------------------------------------------------------------- /resources/scripts/js_functions.js: -------------------------------------------------------------------------------- 1 | /* function loadFile(arg1) { 2 | var xmlhttp; 3 | if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari 4 | xmlhttp=new XMLHttpRequest(); 5 | } 6 | else {// code for IE6, IE5 7 | xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 8 | } 9 | xmlhttp.onreadystatechange=function(){ 10 | if (xmlhttp.readyState==4 && xmlhttp.status==200) { 11 | document.getElementById("myDiv").innerHTML=xmlhttp.responseText; 12 | } 13 | } 14 | xmlhttp.open("GET",arg1,true); 15 | xmlhttp.send(); 16 | } 17 | 18 | function loadHTML(url) { 19 | var temp = "loadURL.php?url="+url; 20 | $("#myDiv").load(temp); 21 | } 22 | 23 | function parseLink(arg){ 24 | if ((arg.substring(0,5) == "http")||(arg.substring(0,4) == "www")) { 25 | //forward to loadHTML function 26 | loadHTML(arg); 27 | if (arg.substring(0,4) == "www"){ 28 | //prepend http:// 29 | var temp = "http://" + arg; 30 | loadHTML(temp); 31 | } 32 | }else{ 33 | //forward to loadFile function 34 | loadHTML(arg); 35 | } 36 | } 37 | 38 | function change(url){ 39 | var len = url.length; 40 | var ext = url.substring(len-3,len); 41 | //document.getElementById('myDiv').src = "about:blank"; 42 | remove_download_pdf(); //removes download pdf link 43 | //if (!(ext == "xml")) { 44 | if (ext == "pdf") { 45 | show_download_pdf(url); 46 | } 47 | document.getElementById('myDiv').src = url; 48 | // }else{ 49 | // document.getElementById('myDiv').src = url;//"resources/scripts/loadURL.php?url="+url; 50 | $.ajax({ 51 | type: 'GET', 52 | url: 'resources/scripts/loadURL.php', 53 | data: {'url': url}, 54 | success: function(msg){ 55 | if (msg) { 56 | $('#myDiv').contents().find('body').html(msg); 57 | }else{ 58 | return; 59 | } 60 | } 61 | }); 62 | //} 63 | } 64 | */ 65 | function linkClicked(link) { 66 | $('.menu li a').removeClass('linkActive'); 67 | link.addClass('linkActive'); 68 | } 69 | 70 | function open_in_new_tab(url){ 71 | var win=window.open(url, '_blank'); 72 | win.focus(); 73 | } 74 | 75 | function show_download_pdf(url) { 76 | $.ajax({ 77 | type: 'GET', 78 | url: '#', 79 | data: {'url': url}, 80 | success: function(){ 81 | add_download_pdf(url); 82 | } 83 | }); 84 | } 85 | 86 | function add_download_pdf(url) { 87 | var link = "Download PDF"; 88 | $('.centerdiv_footer').append("
"+link+"
"); 89 | } 90 | 91 | function remove_download_pdf(){ 92 | $('.pdf_link').remove(); 93 | } 94 | -------------------------------------------------------------------------------- /xml/xml/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 18 | 19 | top_secret 20 | 21 | 22 | group_a 23 | 24 | 25 | 26 | 27 | secret 28 | 29 | 30 | group_a 31 | group_b 32 | 33 | 34 | 35 | 36 | 40 | 41 | /www/team_name/top_secret_folder 42 | top_secret 43 | 44 | 45 | /www/team_name/secret_folder 46 | secret 47 | 48 | 49 | 50 | 51 | 52 | 53 | 57 | 58 | 59 | 60 | start.html 61 | 62 | 63 | content.xml 64 | 65 | 66 | public 67 | 68 | 69 | project.domain.name 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
ldap.domain.address
78 | 123 79 | Organizational Unit 1 80 | Organizational Unit 2 81 | Some Organization 82 | US 83 | uniqueMember 84 | false 85 | 86 | public 87 | 88 |
89 | 90 | 91 |
92 | 93 | -------------------------------------------------------------------------------- /xml/xml/content.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 15 | 16 |
  • JPL Homepage
  • 17 |
  • These links are configurable
  • 18 |
    19 | 20 | 21 |
    22 | 41 | Page Title 42 |

    My Team's Title

    43 |
    44 | 45 | 46 | 65 | Sidebar Title 66 | 79 | 80 | 81 |
    82 | -------------------------------------------------------------------------------- /xml/xml/ic/template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 |

    Inner Content Template XML File

    12 |

    You will find the source xml for this file in 13 | 'ic/template.xml'.

    14 |

    <h2>You can use standard</h2>

    15 |

    <h3>html heading tags</h3>

    16 |

    <h4>to specify how you want</h3>

    17 |
    <h5>title text to show up.</h5>
    18 |

    Now let's begin an unordered list

    19 | 44 |

    Features Include:

    45 | 58 | 59 |

    Tables:

    60 | 61 | 62 | Column 1 63 | Column 2 (boldened and italicized) 64 | Column 3 (orange) 65 | 66 | 67 | Data 1.a (blue) 68 | Data 2.a (underlined) 69 | Data 3.a 70 | 71 | 72 | Data 1.b 73 | Data 2.b (hyperlinked) 74 | Data 3.b 75 | 76 |
    77 |

    Multiple Columns:

    78 | 79 |
    Column 1
    80 |

    Every column is considered a separate content section from every 81 | other column

    82 |
    83 | 84 |
    Column 2
    85 |

    86 | You can have as many columns as you want, though it's doubtful 87 | you'll find a use for any more than 10 88 |

    89 |
    90 | 91 |
    Column 3
    92 |

    And the third

    93 |
    94 | 95 |
    Column 4
    96 |

    And the fourth

    97 |
    98 |
    99 | 100 |
    101 | -------------------------------------------------------------------------------- /resources/css/styles.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 3 | margin: 0; 4 | padding: 0; 5 | width: 100%; 6 | height: 100%; 7 | min-height: 100%; 8 | } 9 | 10 | body { 11 | margin: 0; 12 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 13 | font-size: 14px; 14 | line-height: 20px; 15 | color: #333333; 16 | } 17 | 18 | img { 19 | max-width: 100%; 20 | vertical-align: middle; 21 | border: 0; 22 | -ms-interpolation-mode: bicubic; 23 | } 24 | 25 | h1, 26 | h2, 27 | h3, 28 | h4, 29 | h5, 30 | h6 { 31 | margin: 10px 0; 32 | font-family: inherit; 33 | font-weight: bold; 34 | line-height: 20px; 35 | color: inherit; 36 | text-rendering: optimizelegibility; 37 | } 38 | 39 | h1 { 40 | font-size: 38.5px; 41 | } 42 | 43 | h2 { 44 | font-size: 31.5px; 45 | } 46 | 47 | h3 { 48 | font-size: 24.5px; 49 | } 50 | 51 | h4 { 52 | font-size: 17.5px; 53 | } 54 | 55 | /* Outter div wrapper for the entire page */ 56 | .content { 57 | /*BACKGROUND FOR ENTIRE PAGE*/ 58 | /* background: url('../images/bg.gif') #213452 no-repeat ;*/ 59 | min-height: 100%; 60 | position: relative; 61 | overflow: auto; 62 | z-index: 0; 63 | } 64 | 65 | .background { 66 | position: absolute; 67 | z-index: -1; 68 | top: 0; 69 | /* bottom: 0; */ 70 | margin: 0; 71 | padding: 0; 72 | } 73 | 74 | .top { 75 | position: fixed; 76 | right:0; 77 | left: 0; 78 | } 79 | 80 | /* Header's Block (Top navbar) */ 81 | .top_block { 82 | width: 100%; 83 | display: block; 84 | margin-bottom: 50 px; 85 | } 86 | 87 | /* PERTAINS TO TOP BLOCK */ 88 | .block_2 { 89 | width: 100%; 90 | height: 25%; 91 | /* background-color: #020036; /* TOP NAVBAR COLOR */ 92 | /* background: linear-gradient(to right, #020036, #07122B);*/ 93 | } 94 | 95 | /* PERTAINS TO LEFT BLOCK */ 96 | .background.block_1 { 97 | height: auto !important; 98 | padding-bottom: 0; 99 | left: 0; 100 | width: 225px; 101 | margin-top: 8px; 102 | } 103 | 104 | /* PERTAINS TO LEFT BLOCK */ 105 | .block_1 { 106 | width: 230px; 107 | } 108 | 109 | .centerdiv{ 110 | position: fixed; 111 | left: 240px; 112 | right: 20px; 113 | top: 70px; 114 | bottom: 45px; 115 | } 116 | 117 | .centerdiv_footer{ 118 | position: absolute; 119 | right: 0; 120 | left: 0; 121 | bottom: 0; 122 | height: 1.5em; 123 | } 124 | 125 | /* PERTAINS TO CENTER DIV */ 126 | .block_5 { 127 | -moz-border-radius: 10px; 128 | -webkit-border-radius: 10px; 129 | border-radius: 10px; 130 | width: auto; 131 | height: auto; 132 | 133 | /* margin-bottom: 48px; */ 134 | overflow: auto; 135 | } 136 | 137 | /* CENTER CONTENT FRAME */ 138 | .iFrame{ 139 | position: absolute; 140 | top: 0; 141 | bottom: 0; 142 | left: 0; 143 | right: 0; 144 | } 145 | 146 | 147 | /* PERTAINS TO SIDEBAR DIV */ 148 | .sidebar_container{ 149 | position: fixed; 150 | overflow-y: auto; 151 | overflow-x: hidden; 152 | left: 4px; 153 | top: 70px; 154 | bottom: 45px; 155 | } 156 | .mysidebar{ 157 | -moz-border-radius: 10px; 158 | -webkit-border-radius: 10px; 159 | border-radius: 10px; 160 | position: absolute; 161 | 162 | /*top: 30%;*/ 163 | /* background:#020036; */ 164 | color:#ffffff; 165 | } 166 | 167 | /*PERTAINS TO MENU ITEMS ON THE SIDEBAR*/ 168 | .menu { 169 | width: 210px; 170 | margin:0; 171 | padding: 0; 172 | list-style:none; 173 | overflow: hidden; 174 | } 175 | 176 | /*PERTAINS TO MENU ITEMS ON THE SIDEBAR*/ 177 | .menu ul { 178 | box-sizing: border-box; 179 | /* outline: solid 2px red;*/ 180 | margin:0; 181 | padding:0; 182 | list-style:none; 183 | padding-left:10px; 184 | word-wrap: break-word; 185 | overflow-wrap: break-word; 186 | } 187 | 188 | /*ALL LIST ITEMS IN SIDEBAR*/ 189 | .menu li { 190 | padding:0; 191 | margin-bottom:1px; 192 | } 193 | 194 | /*ALL NONLINK LIST ITEMS IN SIDEBAR*/ 195 | .menu ul li { 196 | margin-bottom:1px; 197 | color:#FFFFFF; 198 | /*background:#4F698C !important;*/ 199 | } 200 | 201 | /* ALL LISTITEM LINKS IN SIDEBAR */ 202 | .menu a, .menu p { 203 | display:block; 204 | padding:2px 5px; 205 | text-decoration:none; 206 | } 207 | 208 | /*PERTAINS TO MENU ITEMS ON THE SIDEBAR*/ 209 | .menu li a:not(.listhead){ 210 | padding-left:25px; 211 | /*color:#FFFFFF;*/ 212 | /*background:#5E8FAD;*/ 213 | } 214 | 215 | /*PERTAINS TO MENU ITEMS ON THE SIDEBAR*/ 216 | .menu li a.linkActive { 217 | /*background:#34325e; */ 218 | text-decoration:italic; 219 | } 220 | 221 | /*PERTAINS TO MENU ITEMS ON THE SIDEBAR*/ 222 | .menu ul li .listhead, .menu li a .listhead{ 223 | border-bottom: inset 0.1px black; 224 | margin-left: 0px !important; 225 | padding-left: 0px !important; 226 | color: #ffffff !important; 227 | } 228 | 229 | .hidden { 230 | display:none; 231 | } 232 | 233 | /* FOOTER SECTION */ 234 | .footer { 235 | line-height: 2em; 236 | position: fixed; 237 | left: 0px; 238 | bottom: 0px; 239 | height: 2em; 240 | width: 100%; 241 | /*background-color: #020036;*/ 242 | /*color: #FFFFFF;*/ 243 | } 244 | 245 | /*HORIZONTAL LIST USED FOR TOP NAVBAR*/ 246 | .navlist { 247 | display:inline; 248 | padding-left:60px; 249 | } 250 | 251 | /*NAVLIST LIST ITEMS*/ 252 | .navlist li { 253 | text-align:center; 254 | display:inline; 255 | list-style-type:none; 256 | padding-right:30px; 257 | min-height: 60%; 258 | } 259 | 260 | /*NAVLIST LIST ITEM LINK HOVER*/ 261 | .navlist li a:hover { 262 | color: #FFFFFF; 263 | } 264 | 265 | /*SHADOW USED ON THE CENTER DIV*/ 266 | .shadow { 267 | box-shadow: 0px 0px 10px 5px rgba(0,0,0,.2); 268 | } 269 | 270 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 110 | 111 | 112 | 113 | 114 | Failed to load content xml file. Make sure it is properly ". 131 | "defined in config.xml."; 132 | } else { 133 | $title=getTitleHTML($contentXML); 134 | $header=getHeaderHTML($contentXML); 135 | //Use what we have 136 | echo $title; 137 | } 138 | ?> 139 | 140 | 141 | 142 |
    143 | 144 | 145 |
    146 | 158 | 159 | 160 | 176 |
    177 | 178 | 179 | 180 |
    181 |
    182 | 183 |
    184 | $header"; ?> 185 |
    186 |
    187 |
    188 | 192 |
    193 | 194 |
    195 | 196 | 197 | 198 | 219 | 220 | 221 |
    222 | 223 | 224 | 225 | 226 | 227 | 240 | 241 | 242 | 248 | 249 | 250 | -------------------------------------------------------------------------------- /resources/scripts/stateless.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | function hasChildren(SimpleXMLElement $xmlElement) { 10 | $children = $xmlElement->children(); 11 | $childrenExist = false; 12 | foreach ($children as $child) { 13 | $childrenExist = true; 14 | break; 15 | } 16 | return $childrenExist; 17 | } 18 | 19 | 20 | function hasNoLinkChildren($xmlElement) { 21 | return !hasChildrenOfType($xmlElement, "link"); 22 | } 23 | function hasChildrenOfType($xmlElement, $type) { 24 | $children = $xmlElement->children(); 25 | $childrenExist = false; 26 | $containsType = false; 27 | foreach ($children as $child) { 28 | if (!$childrenExist) { 29 | $childrenExist = true; 30 | } 31 | if ($child->getName() == $type) { 32 | $containsType = true; 33 | } 34 | } 35 | return $childrenExist && $containsLink; 36 | } 37 | 38 | 39 | 40 | /** 41 | * Determines whether the given xml element is a 'ul' element 42 | * 43 | * @param SimpleXMLElement $xmlElement 44 | * 45 | * @author Andrew Darwin 46 | */ 47 | function isULElement(SimpleXMLElement $xmlElement) { 48 | return $xmlElement->getName() == "ul"; 49 | } 50 | 51 | 52 | 53 | /** 54 | * Determines whether the given xml element is a 'li' element 55 | * 56 | * @param SimpleXMLElement $xmlElement 57 | * 58 | * @author Andrew Darwin 59 | */ 60 | function isLIElement(SimpleXMLElement $xmlElement) { 61 | return $xmlElement->getName() == "li"; 62 | } 63 | 64 | 65 | /** 66 | * Normalizes the text from a 'style' attribute so that it can be further 67 | * processed 68 | * 69 | * @param string $styleAttribute A style attribute might look something like: 70 | * "bold, italic, underlined" 71 | * @return array 72 | * 73 | * @author Andrew Darwin 74 | */ 75 | function formatStyleAttribute($styleAttribute) { 76 | $acceptedStyles = array("b", "u", "i"); 77 | $output = array(); 78 | $styles = explode(',', $styleAttribute); 79 | foreach ($styles as $style) { 80 | $style = trim($style); 81 | switch ($style) { 82 | case "bold": 83 | $style = "b"; 84 | break; 85 | case "underline": 86 | $style = "u"; 87 | break; 88 | case "underlined": 89 | $style = "u"; 90 | break; 91 | case "italic": 92 | $style = "i"; 93 | break; 94 | case "italics": 95 | $style = "i"; 96 | break; 97 | case "italicized": 98 | $style = "i"; 99 | break; 100 | } 101 | if (in_array($style, $acceptedStyles)) { 102 | array_push($output, $style); 103 | } 104 | } 105 | return $output; 106 | } 107 | 108 | 109 | /** 110 | * @param SimpleXMLElement $xmlElement 111 | * 112 | * @author Andrew Darwin 113 | */ 114 | function getTrimmed($xmlElement) { 115 | return trim((string)$xmlElement); 116 | } 117 | 118 | 119 | /** 120 | * Takes a prefix string (by reference) and prepends $addition 121 | * 122 | * @param string $prefix 123 | * @param string $addition 124 | * @return string 125 | * 126 | * @author Andrew Darwin 127 | */ 128 | function addToPrefix(&$prefix, $addition) { // Take prefix in by reference 129 | $prefix = $addition.$prefix; 130 | return $prefix; 131 | } 132 | 133 | 134 | /** 135 | * Takes a suffix string (by reference) and appends $addition 136 | * 137 | * @param string $suffix 138 | * @param string $addition 139 | * @return string 140 | * 141 | * @author Andrew Darwin 142 | */ 143 | function addToSuffix(&$suffix, $addition) { // Take suffix in by reference 144 | $suffix = $suffix.$addition; 145 | return $suffix; 146 | } 147 | 148 | 149 | /** 150 | * @param array $array 151 | * 152 | * @author Andrew Darwin 153 | */ 154 | function getArrayString($array) { 155 | if ($array == null) { 156 | return null; 157 | } 158 | $output = ""; 159 | $delimiter = ""; 160 | foreach ($array as $value) { 161 | $output = $output . $delimiter . $value; 162 | if ($delimiter == "") { 163 | $delimiter = ", "; 164 | } 165 | } 166 | return $output; 167 | } 168 | 169 | 170 | /** 171 | * Determines whether $dirA is a subdirectory of $dirB 172 | * 173 | * @param string $dirA 174 | * @param string $dirB 175 | * @return boolean 176 | * 177 | * @author Andrew Darwin 178 | */ 179 | function directoryAIsChildOfDirectoryB($dirA, $dirB) { 180 | $header = "directoryAIsChildOfDirectoryB(): "; 181 | // Return true if dirA starts with dirB 182 | $output = stringAStartsWithStringB($dirA, $dirB); 183 | //$output = strpos($dirA, $dirB) === 0; 184 | if ($output) { 185 | logMessage("$header Determined '$dirA' is a child of '$dirB'"); 186 | } else { 187 | logMessage("$header Determined '$dirA' is not a child of '$dirB'"); 188 | } 189 | return $output; 190 | } 191 | 192 | 193 | /** 194 | * @param string $stringA 195 | * @param string $stringB 196 | * 197 | * @author Andrew Darwin 198 | */ 199 | function stringAStartsWithStringB($stringA, $stringB) { 200 | return strpos($stringA, $stringB) === 0; 201 | } 202 | 203 | 204 | /** 205 | * @param string $stringA 206 | * @param string $stringB 207 | * 208 | * @author Andrew Darwin 209 | */ 210 | function stringAEndsWithStringB($stringA, $stringB) { 211 | return strpos($stringA, $stringB) === strlen($stringA) - 1; 212 | } 213 | 214 | 215 | /** 216 | * @param string $directoryPath 217 | * 218 | * @author Andrew Darwin 219 | */ 220 | function getDirectoryNameFromPath($directoryPath) { 221 | $lastSlashIndex = strrpos($directoryPath, "/"); 222 | $currentDirectoryName = substr($directoryPath, $lastSlashIndex + 1); 223 | return $currentDirectoryName; 224 | } 225 | 226 | 227 | /** 228 | * Returns an array containing all of the files in the dir passed in 229 | * 230 | * @param string $dir 231 | * 232 | * @author -> Delvison Castillo 233 | */ 234 | function getFilesFromDir($dir){ 235 | $files = array(); 236 | $handler = opendir($dir); 237 | while ($file = readdir($handler)) { 238 | if ($file != "." && $file != "..") { 239 | array_push($files,$file); 240 | } 241 | } 242 | return $files; 243 | } 244 | 245 | 246 | /** 247 | * @param string $text 248 | * 249 | * @author Andrew Darwin 250 | */ 251 | function stripLeadingSlash($text) { 252 | // If starts with slash, remove it. Otherwise, return original text 253 | $header = "stripLeadingSlash(): "; 254 | logMessage("$header Input = '$text'"); 255 | $output = $text; 256 | if (stringAStartsWithStringB($text, "/")) { 257 | $output = substr($text, 1); 258 | } 259 | logMessage("$header Output = '$output'"); 260 | return $output; 261 | } 262 | 263 | 264 | /** 265 | * @param string $text 266 | * 267 | * @author Andrew Darwin 268 | */ 269 | function stripTrailingSlash($text) { 270 | // If ends with slash, remove it. Otherwise, return original text 271 | $header = "stripTrailingSlash(): "; 272 | logMessage("$header Input = '$text'"); 273 | $output = $text; 274 | if (stringAEndsWithStringB($text, "/")) { 275 | $output = substr($text, 0, strlen($text) - 1); 276 | } 277 | logMessage("$header Output = '$output'"); 278 | return $output; 279 | } 280 | 281 | 282 | /** 283 | * @param string $stringA 284 | * @param string $stringB 285 | * 286 | * @author Andrew Darwin 287 | */ 288 | function getSubstringOfAAfterOccuranceOfB($stringA, $stringB) { 289 | $header = "getSubstringOfAAfterOccuranceOfB(): "; 290 | logMessage("$header Input: a='$stringA', b='$stringB'"); 291 | $positionOfB = strpos($stringA, $stringB); 292 | $output = $stringA; 293 | if ($positionOfB !== false) { 294 | $output = substr($stringA, $positionOfB + strlen($stringB)); 295 | } 296 | logMessage("$header Output = '$output'"); 297 | return $output; 298 | } 299 | 300 | 301 | /** 302 | * @param string $stringA 303 | * @param string $stringB 304 | * 305 | * @author Andrew Darwin 306 | */ 307 | function getSubstringOfABeforeOccuranceOfB($stringA, $stringB) { 308 | $header = "getSubstringOfABeforeOccuranceOfB(): "; 309 | logMessage("$header Input: a='$stringA', b='$stringB'"); 310 | $positionOfB = strpos($stringA, $stringB); 311 | $output = $stringA; 312 | if ($positionOfB !== false) { 313 | $output = substr($stringA, 0, $positionOfB); 314 | } 315 | logMessage("$header Output = '$output'"); 316 | return $output; 317 | } 318 | 319 | 320 | /** 321 | * Escapes spaces and ampersands (&) from a url 322 | * 323 | * @param string $url 324 | * @return string Returns the url with the necessary characters escaped. 325 | * 326 | * @author Delvison Castillo 327 | */ 328 | function clean_url($url) { 329 | $header = "clean_url(): "; 330 | logMessage("$header input url = '$url'"); 331 | $url = str_replace(" ", "%20", $url); 332 | $url = str_replace("&", "%26", $url); 333 | logMessage("$header output url = '$url'"); 334 | return $url; 335 | } 336 | 337 | 338 | /** 339 | * @param SimpleXMLElement $xmlElement 340 | * @return string 341 | * @author Andrew Darwin 342 | */ 343 | function stripEnclosingXMLTag($xmlElement) { 344 | $tagName = $xmlElement->getName(); 345 | $xmlString = $xmlElement->asXML(); 346 | $xmlString = getSubstringOfAAfterOccuranceOfB($xmlString, "<$tagName"); 347 | $xmlString = getSubstringOfAAfterOccuranceOfB($xmlString, ">"); 348 | $xmlString = getSubstringOfABeforeOccuranceOfB($xmlString, ""); 349 | return $xmlString; 350 | } 351 | ?> 352 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /resources/scripts/functions.php: -------------------------------------------------------------------------------- 1 | 56 | */ 57 | function logMessage($message) { 58 | global $logFilePath; 59 | global $logFileName; 60 | global $loggingEnabled; 61 | 62 | if ($loggingEnabled) { 63 | $newSession = false; 64 | if ($logFilePath == null || $logFilePath == "") { 65 | $logFilePath = getAdjustedCurrentDirectory()."/".$logFileName; 66 | } 67 | if (!file_exists($logFilePath)) { 68 | $temp = fopen($logFilePath, "a"); 69 | fclose($temp); 70 | $newSession = true; 71 | } 72 | // Open log file 73 | $openFile = fopen($logFilePath, "a"); /* "a" = append mode. This places 74 | the file pointer at the end of 75 | the file and allows you to 76 | write to, but not read the 77 | file. */ 78 | // Get date and time 79 | $dateAndTime = "[".date("Y/m/d h:i:s", mktime())."] "; 80 | 81 | // Write to file 82 | if ($newSession) { 83 | fwrite($openFile, $dateAndTime."----- Starting new session ----\n"); 84 | } 85 | if (!fwrite($openFile, $dateAndTime.$message."\n")) { 86 | echo "Failed to write to log!!!"; 87 | } 88 | 89 | // Close the file 90 | fclose($openFile); 91 | } 92 | } 93 | 94 | 95 | 96 | /** 97 | * Sets the global variable that specifies the path to all the xml files 98 | * 99 | * Reads the desired path from map.xml. This function is called by index.php and 100 | * loadURL.php 101 | * 102 | * @author Andrew Darwin 103 | */ 104 | function setXMLLocation() { 105 | global $pathToXMLFiles; 106 | $path = getPathToXMLFile("map.xml"); 107 | $xml = simplexml_load_file($path); 108 | $xmlDirectory = $xml->xml_directory[0]; 109 | $pathToXMLFiles = (string)$xmlDirectory; 110 | } 111 | 112 | 113 | /** 114 | * Returns the root directory of the framework instance, regardless of which 115 | * php files are in use. Should always be called instead of getcwd(). 116 | * 117 | * This function solves the problem of sometimes working from root and sometimes 118 | * from resources/scripts. 119 | * 120 | * @return string 121 | * @author Andrew Darwin 122 | */ 123 | function getAdjustedCurrentDirectory() { 124 | global $logFilePath; 125 | global $loggingEnabled; 126 | global $savedACD; 127 | 128 | if ($savedACD == null || $savedACD == "") { 129 | $originalLoggingSetting = $loggingEnabled; 130 | if ($logFilePath == null || $logFilePath == "") { 131 | $loggingEnabled = false; 132 | } 133 | $header = "getAdjustedCurrentDirectory(): "; 134 | 135 | // Get current working directory 136 | $currentDirectoryPath = getcwd(); 137 | logMessage("$header Get current working directory --> ". 138 | $currentDirectoryPath); 139 | 140 | // Determine the position of /resources/ in the current directory 141 | $resourcesPosition = strpos($currentDirectoryPath, "/resources/"); 142 | logMessage("$header Determine the position of /resources/ in the ". 143 | "current working directory --> $resourcesPosition"); 144 | 145 | $adjustedDirectoryPath; 146 | if ($resourcesPosition == false) { 147 | $adjustedDirectoryPath = $currentDirectoryPath; 148 | } else { 149 | $adjustedDirectoryPath = substr($currentDirectoryPath, 0, 150 | $resourcesPosition); 151 | } 152 | logMessage("$header Return adjustedDirectoryPath = ". 153 | $adjustedDirectoryPath); 154 | $loggingEnabled = $originalLoggingSetting; 155 | $savedACD = $adjustedDirectoryPath; 156 | } else { 157 | $adjustedDirectoryPath = $savedACD; 158 | } 159 | return $adjustedDirectoryPath; 160 | } 161 | 162 | 163 | /** 164 | * Determines the the absolute path to the xml files directory 165 | * @return string Absolute path to the xml files directory 166 | * @author Andrew Darwin 167 | */ 168 | function getPathToXMLFiles() { 169 | global $pathToXMLFiles; 170 | $output = ""; 171 | if ($pathToXMLFiles == null || $pathToXMLFiles == "") { 172 | $output = getAdjustedCurrentDirectory(); 173 | } else { 174 | $output = $pathToXMLFiles; 175 | } 176 | return $output; 177 | } 178 | 179 | 180 | /** 181 | * Determines the absolute path to the given xml file 182 | * @param string $fileName 183 | * @return string Absolute path to the given xml file name 184 | * @author Andrew Darwin 185 | */ 186 | function getPathToXMLFile($fileName) { 187 | return getPathToXMLFiles()."/".$fileName; 188 | } 189 | 190 | 191 | /** 192 | * Takes in the current users group and contents security level and looks at the 193 | * permissions dictionary that is retrieved after parsing the config file in 194 | * order to analyze whether that user has valid clearance 195 | * 196 | * @param array $currentUsersGroups 197 | * @param string $contentsACL 198 | * 199 | * @author Andrew Darwin 200 | */ 201 | function hasAccess($currentUsersGroups, $contentsACL){ 202 | global $defaultSecurityValue; 203 | global $aclDict; 204 | global $useLDAP; 205 | $header = "hasAccess(): "; 206 | logMessage("$header Checking access for groups: ". 207 | getArrayString($currentUsersGroups). 208 | " and contents ACL: $contentsACL"); 209 | $allowedGroups = array(); 210 | $accessGranted = false; 211 | if ($contentsACL == null) { 212 | logMessage("$header Received null contentsACL. Set contentsACL to the ". 213 | "default value: '$defaultSecurityValue'"); 214 | $contentsACL = $defaultSecurityValue; 215 | } 216 | //Look up groups contained within $contentsACL 217 | if (array_key_exists($contentsACL, $aclDict)) { 218 | $allowedGroups = $aclDict[$contentsACL]; 219 | } else { 220 | logMessage("$header No acl with name '$contentsACL' exists"); 221 | } 222 | logMessage("$header After dict lookup, allowedGroups = ". 223 | getArrayString($allowedGroups)); 224 | if ($allowedGroups != null) { 225 | foreach ($currentUsersGroups as $usersGroup) { 226 | if (in_array($usersGroup, $allowedGroups)) { 227 | $accessGranted = true; 228 | break; 229 | } 230 | } 231 | } else if (!$useLDAP && $contentsACL == "public") { 232 | $accessGranted = true; 233 | } 234 | if ($accessGranted) { 235 | logMessage("$header determined that groups ". 236 | getArrayString($currentUsersGroups)." provide sufficient ". 237 | "security clearance to view content with acl: ".$contentsACL); 238 | } else { 239 | logMessage("$header determined that groups ". 240 | getArrayString($currentUsersGroups)." DO NOT provide ". 241 | "sufficient security clearance to view content with acl: ". 242 | $contentsACL); 243 | } 244 | return $accessGranted; 245 | } 246 | 247 | 248 | /** 249 | * Determines whether the current user has access to the given xml element 250 | * @param SimpleXMLElement $xmlElement 251 | * @author Andrew Darwin 252 | */ 253 | function hasAccessTo($xmlElement) { 254 | global $usersGroups; 255 | global $defaultSecurityValue; 256 | $securityRequirement = getCurrentSecurityRequirement($xmlElement, 257 | $defaultSecurityValue); 258 | return hasAccess($usersGroups, $securityRequirement); 259 | } 260 | 261 | 262 | /** 263 | * Attempts to determine the ACL name associated with the given url 264 | * 265 | * @param string $url 266 | * @return string ACL name returned from getRestrictedDirectoryACL($localPath) 267 | * 268 | * @author Andrew Darwin 269 | */ 270 | function getACLforURL($url) { 271 | global $restrictedDirectoriesDict; 272 | $header = "getACLforURL(): "; 273 | 274 | // Extract directory from url 275 | $localPath = getLocalPathFromURL($url); 276 | logMessage("$header localPath = $localPath"); 277 | // Get ACL 278 | $acl = getRestrictedDirectoryACL($localPath); 279 | logMessage("$header acl = $acl"); 280 | return $acl; 281 | } 282 | 283 | 284 | /** 285 | * Determines the access control list that is associated with the given 286 | * restricted directory 287 | * @param string $restrictedDirectoryPath 288 | * @return string 289 | * @author Andrew Darwin 290 | */ 291 | function getRestrictedDirectoryACL($restrictedDirectoryPath) { 292 | global $restrictedDirectoriesDict; 293 | $header = "getRestrictedDirectoryACL(): "; 294 | logMessage("$header checking restrictedDirectoriesDict for ". 295 | $restrictedDirectoryPath); 296 | $acl = ""; 297 | // Check directory against list of restricted directories 298 | foreach ($restrictedDirectoriesDict as $path=>$aclName) { 299 | if (strpos($path, "/") != strlen($path)) { 300 | $path = $path."/"; 301 | } 302 | logMessage("$header Checking ".(string)$path); 303 | //if (strpos($restrictedDirectoryPath, (string)$path) === 0) { 304 | if (directoryAIsChildOfDirectoryB($restrictedDirectoryPath, 305 | (string)$path)) { 306 | /* We should enter the body of this if statement when 307 | $restrictedDirectoryPath starts with $path. */ 308 | logMessage("$header Found containing directory for ". 309 | $restrictedDirectoryPath); 310 | $acl = $aclName; 311 | break; 312 | } 313 | } 314 | return $acl; 315 | } 316 | 317 | 318 | /** 319 | * Determines the current directory name, relocating to ~CASH_ROOT if under 320 | * resources 321 | * @return string 322 | * @author Andrew Darwin 323 | */ 324 | function getAdjustedCurrentDirectoryName() { 325 | $header = "getAdjustedCurrentDirectoryName(): "; 326 | logMessage("$header First, get adjusted directory path"); 327 | $adjustedDirectoryPath = getAdjustedCurrentDirectory(); 328 | $currentDirectoryName = getDirectoryNameFromPath($adjustedDirectoryPath); 329 | logMessage("$header Next, determine current directory name based on last ". 330 | "forward slash --> '$currentDirectoryName'"); 331 | return $currentDirectoryName; 332 | } 333 | 334 | 335 | /** 336 | * Determines whether the given url is absolute or relative 337 | * 338 | * @param string $url 339 | * 340 | * @return boolean True if absolute, false if relative 341 | * 342 | * @author Andrew Darwin 343 | */ 344 | function isAbsoluteURL($url) { 345 | global $domainName; 346 | $header = "isAbsoluteURL(): "; 347 | $isAbsolute = false; 348 | if (strpos($url, "/") === 0) { 349 | logMessage("$header '$url' begins with / and thus is absolute"); 350 | $isAbsolute = true; 351 | } else if (strpos($url, "http") === 0) { 352 | logMessage("$header '$url' begins with 'http' and thus is absolute"); 353 | $isAbsolute = true; 354 | } else if (strpos($url, $domainName)) { 355 | /* Should arrive here if $domainName occurs within the first 10 356 | characters of $url */ 357 | logMessage("$header '$url' contains '$domainName' within the ". 358 | "first 10 characters and thus is absolute"); 359 | $isAbsolute = true; 360 | } else { 361 | logMessage("$header '$url' is relative"); 362 | } 363 | return $isAbsolute; 364 | } 365 | 366 | 367 | 368 | 369 | /** 370 | * Given a url, determines the local path to the linked file 371 | * @param string $url 372 | * @return string Returns the local path, if it can be determined. Otherwise, 373 | * returns the original url 374 | * @author Andrew Darwin 375 | */ 376 | function getLocalPathFromURL($url) { 377 | /** 378 | * Algorithm: 379 | * 1. Determine whether $url is absolute or relative 380 | * 2. If absolute, find matching target. If none is found, return 381 | * original URL. 382 | * 3. If relative, append to adjusted current directory 383 | * 384 | */ 385 | global $domainName; 386 | $header = "getLocalPathFromURL(): "; 387 | $output = ""; 388 | 389 | logMessage("$header Attempting to get local path from '$url'"); 390 | 391 | if (isAbsoluteURL($url)) { 392 | // Check for $domainName 393 | logMessage("$header url, '$url' is an absolute url. Check for ". 394 | "'$domainName' in '$url'."); 395 | $domainNamePosition = strpos($url, $domainName); 396 | if ($domainNamePosition != false) { 397 | logMessage("$header '$domainName' exists at position ". 398 | "'$domainNamePosition'"); 399 | // Replace $domainName with /www 400 | logMessage("$header Replace the the '$domainName' section ". 401 | "of '$url' with '/www'."); 402 | $output = "/www".substr($url, 403 | $domainNamePosition+ 404 | strlen($domainName)); 405 | logMessage("$header After doing so, the url becomes '$output'"); 406 | } else { 407 | logMessage("$header '$domainName' does not exist in url: ". 408 | "'$url'"); 409 | $output = $url; 410 | } 411 | } else { 412 | $adjustedDirectoryPath = getAdjustedCurrentDirectory(); 413 | logMessage("$header url, '$url' is a relative url. Append it to the ". 414 | "adjusted current directory path, '$adjustedDirectoryPath'"); 415 | $output = $adjustedDirectoryPath."/".$url; 416 | } 417 | return $output; 418 | } 419 | 420 | 421 | /** 422 | * query LDAP for the current users group and return its value 423 | * takes in associative array returned from getPermissions 424 | * returns an array of all groups the user belongs to mentioned in the config 425 | * 426 | * @return array 427 | * @author Andrew Darwin 428 | * @author Delvison Castillo 429 | */ 430 | function getUsersGroups() { 431 | global $user; 432 | global $usersGroups; 433 | global $aclDict; 434 | 435 | $header = "getUsersGroups(): "; 436 | logMessage("$header Trying to get user's group"); 437 | $groupsUserBelongsTo = array(); //array to be returned 438 | $groupsInConfig = array(); 439 | //logMessage("$header aclDict = ".var_dump($aclDict)); 440 | foreach ((array)$aclDict as $name=>$groups) { 441 | logMessage("$header name = $name"); 442 | foreach ($groups as $group){ 443 | logMessage("$header found group: $group"); 444 | array_push($groupsInConfig, $group); 445 | } 446 | } 447 | $groupsInConfig = array_unique($groupsInConfig); 448 | $usersGroups = (array)@queryLDAP($groupsInConfig); // Suppress warnings from 449 | // this function call 450 | logMessage("LDAP query determined user: $user belonged to groups: ". 451 | getArrayString($usersGroups)); 452 | return $usersGroups; 453 | } 454 | 455 | 456 | /** 457 | * Generates the DN string that's needed to query the LDAP Server 458 | * @return string 459 | * @author Andrew Darwin 460 | */ 461 | function getLDAPQueryDN($group) { 462 | global $organizationalUnit1, $organizationalUnit2; 463 | global $organization; 464 | global $countryNaming; 465 | $dn = "cn=$group, ou=$organizationalUnit1, ou=$organizationalUnit2, ". 466 | "o=$organization, c=$countryNaming"; 467 | return $dn; 468 | } 469 | 470 | 471 | /** 472 | * Generates the value string that's needed to query the LDAP Server 473 | * @return string 474 | * @author Andrew Darwin 475 | */ 476 | function getLDAPQueryValue() { 477 | global $user; 478 | global $organizationalUnit1, $organizationalUnit2; 479 | global $organization; 480 | global $countryNaming; 481 | $value = "uid=$user, ou=$organizationalUnit1, ou=$organizationalUnit2, ". 482 | "o=$organization, c=$countryNaming"; 483 | return $value; 484 | } 485 | 486 | 487 | /** 488 | * Generates the attribute string that's needed to query the LDAP Server 489 | * @return string 490 | * @author Andrew Darwin 491 | */ 492 | function getLDAPQueryAttribute() { 493 | global $attr; 494 | return $attr; 495 | } 496 | 497 | 498 | /** 499 | * This function queries the LDAP server to determine whether a given user and 500 | * group combination exists. This function returns an array of groups the given 501 | * user belongs to 502 | * 503 | * @param array $groupsInConfig 504 | * 505 | * @author Andrew Darwin 506 | * @author Delvison Castillo 507 | */ 508 | function queryLDAP($groupsInConfig) { 509 | $groupsUserBelongsTo = array(); 510 | global $ldapAddress; 511 | global $ldapPort; 512 | global $useLDAP; 513 | //LDAP QUERIES HERE 514 | if (!$useLDAP) { 515 | $groupsUserBelongsTo = array("public"); 516 | return $groupsUserBelongsTo; 517 | } 518 | if ($ldapAddress == "" || $ldapPort == "") { 519 | return null; 520 | } 521 | $ldap = ldap_connect($ldapAddress, $ldapPort); 522 | logMessage("queryLDAP() Tried to connect to LDAP and got the following ". 523 | "object: $ldap"); 524 | //$bindedLDAP = ldap_bind($ldap); //binded for read access 525 | if ($ldap && ldap_bind($ldap)) { 526 | logMessage("queryLDAP() is beginning to query groups from config"); 527 | foreach ($groupsInConfig as $group){ 528 | // prepare data 529 | $dn = getLDAPQueryDN($group); 530 | $value = getLDAPQueryValue(); 531 | $attr = getLDAPQueryAttribute(); 532 | logMessage("queryLDAP() prepared a query with dn: $dn, value: ". 533 | "$value, and attr: $attr"); 534 | $query = ldap_compare($ldap, $dn, $attr, $value); 535 | logMessage("queryLDAP(): The query returned: ". 536 | ($query ? "true" : "false")); 537 | if ($query === -1){ 538 | //AN ERROR HAS OCCURED 539 | $groupsUserBelongsTo = array("LDAP Error"); 540 | logMessage("LDAP ERROR"); 541 | } else if ($query) { 542 | array_push($groupsUserBelongsTo, $group); 543 | logMessage("queryLDAP() pushed group: $group to list of groups ". 544 | "the user belongs to"); 545 | } 546 | } 547 | } else { 548 | $groupsUserBelongsTo = array("Invalid LDAP Connection"); 549 | } 550 | return $groupsUserBelongsTo; 551 | } 552 | 553 | 554 | /** 555 | * Retrieves the current user's username 556 | * @return string 557 | * @author Delvison Castillo 558 | */ 559 | function getUser(){ 560 | GLOBAL $user; 561 | return $user; 562 | } 563 | 564 | 565 | /** 566 | * Retrieves the list of groups the current user is a member of 567 | * @return array 568 | * @author Delvison Castillo 569 | */ 570 | function getGroups(){ 571 | GLOBAL $usersGroups; 572 | return $usersGroups; 573 | } 574 | 575 | 576 | /** 577 | * Generates the html output for all css, javascript, and php declarations 578 | * @return string 579 | * @author Andrew Darwin 580 | */ 581 | function getAllScriptDeclarations() { 582 | $output = ""; 583 | $output = " 631 | */ 632 | function generateScriptHTMLFromFilePath($filePath) { 633 | $extension = pathinfo($filePath, PATHINFO_EXTENSION); 634 | $output = ""; 635 | switch ($extension) { 636 | case "css": 637 | $output .= "\n"; 639 | break; 640 | case "js": 641 | $output .= "\n"; 642 | break; 643 | } 644 | return $output; 645 | } 646 | 647 | 648 | /** 649 | * Takes in a url, determines whether that url is foreign or not 650 | * and returns a boolean 651 | * 652 | * @param string $url 653 | * 654 | * @author Andrew Darwin 655 | */ 656 | function is_link_external($url){ 657 | global $domainName; 658 | global $DEBUG; 659 | $header = "is_link_external(): "; 660 | logMessage("$header Input link = '$url'"); 661 | $is_external = false; 662 | $relativeTeamPathUnderWWW = getAdjustedCurrentDirectory(); 663 | logMessage("$header relativeTeamPathUnderWWW = ". 664 | "'$relativeTeamPathUnderWWW'"); 665 | $strippedURL = getLocalPathFromURL($url); 666 | $strippedURL = stripLeadingSlash($strippedURL); 667 | $relativeTeamPathUnderWWW = stripLeadingSlash($relativeTeamPathUnderWWW); 668 | if ($DEBUG && isAbsoluteURL($url)) { 669 | $prototypeName = getDirectoryNameFromPath($relativeTeamPathUnderWWW); 670 | $relativeTeamPathUnderWWW = getSubstringOfABeforeOccuranceOfB( 671 | $relativeTeamPathUnderWWW, 672 | $prototypeName); 673 | } 674 | logMessage("$header Stripped url = '$strippedURL'"); 675 | if (directoryAIsChildOfDirectoryB($strippedURL, 676 | $relativeTeamPathUnderWWW)) { 677 | logMessage("$header '$strippedURL' is a child of ". 678 | "'$relativeTeamPathUnderWWW'. Set external to false."); 679 | $is_external = false; 680 | } else { 681 | $is_external = true; 682 | logMessage("$header '$strippedURL' is not a child of ". 683 | "'$relativeTeamPathUnderWWW'. Set external to true."); 684 | } 685 | return $is_external; 686 | } 687 | 688 | 689 | 690 | /** 691 | * Parses an xml element that has children and returns the necessary html 692 | * @param SimpleXMLElement $xmlElement 693 | * @author Andrew Darwin 694 | */ 695 | function parseLink($xmlElement) { 696 | global $defaultSecurityValue; 697 | global $usersGroups; 698 | $output = ""; 699 | $parentSecurityRequirement = getCurrentSecurityRequirement($xmlElement, 700 | $defaultSecurityValue); 701 | $domElement = dom_import_simplexml($xmlElement); 702 | if ($domElement->hasChildNodes()) { 703 | $childList = $domElement->childNodes; 704 | foreach ($childList as $child) { 705 | $nodeName = $child->nodeName; 706 | switch ($child->nodeType) { 707 | case XML_TEXT_NODE: 708 | $output .= $child->nodeValue; 709 | break; 710 | case XML_ELEMENT_NODE: 711 | if ($nodeName == "link") { 712 | $simpleXML = simplexml_import_dom($child); 713 | $securityRequirement = 714 | getCurrentSecurityRequirement($simpleXML, 715 | $parentSecurityRequirement); 716 | if (hasAccess($usersGroups, $securityRequirement)) { 717 | $output .= getElementContentWithStyleTags($simpleXML, 718 | false, ""); 719 | } 720 | } 721 | break; 722 | } 723 | } 724 | } 725 | return $output; 726 | } 727 | /******************************************************************************/ 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | /******************************************************************************* 738 | ************************ XML Parsing (Stateful) ***************************** 739 | ******************************************************************************/ 740 | 741 | /** 742 | * Calls the necessary function to begin xml parsing 743 | * 744 | * @author Andrew Darwin 745 | */ 746 | function initializeMainContent() { 747 | global $mainContentFilePath; 748 | $header = "initializeMainContent(): "; 749 | logMessage("$header Initializing main content..."); 750 | parseConfig(); 751 | return initializeContent($mainContentFilePath); 752 | } 753 | 754 | 755 | 756 | /** 757 | * Reads in an .xml file and returns a SimpleXMLElement object that represents 758 | * the file. 759 | * 760 | * Note that because this function must be called first, calls to parseConfig() 761 | * and getUsersGroups() have been added to ensure that all necessary parsing 762 | * will be complete by the time the content is needed for use. 763 | * 764 | * @param $xmlFile This parameter can either be a SimpleXMLElement or a string. 765 | * 766 | * @author Andrew Darwin 767 | */ 768 | function initializeContent($xmlFile) { 769 | global $contentXML; 770 | 771 | if (is_null($contentXML)){ 772 | if ($xmlFile instanceof SimpleXMLElement) { 773 | $contentXML = $xmlFile; 774 | } else { 775 | $xmlFile = getPathToXMLFile($xmlFile); 776 | if (file_exists($xmlFile)) { //$xmlFile should be a string 777 | $contentXML = simplexml_load_file($xmlFile); 778 | } else { 779 | return null; 780 | } 781 | } 782 | logMessage("Loaded content xml into memory"); 783 | getUsersGroups(); 784 | } 785 | return $contentXML; 786 | } 787 | 788 | 789 | /** 790 | * Returns the proper html textual transcription of an unordered list xml 791 | * element 792 | * 793 | * Note that this function takes into account security access definitions to 794 | * hide certain content from unauthorized visitors. 795 | * 796 | * @param SimpleXMLElement $listXML 797 | * @param string $inheritedSecurity 798 | * @param boolean $shouldAddSwapToLinks 799 | * 800 | * @return string 801 | * @author Andrew Darwin 802 | */ 803 | function getListContents(SimpleXMLElement $listXML, $inheritedSecurity, 804 | $shouldAddSwapToLinks, $shouldIncludeCSSMenuClass) { 805 | if (!isULElement($listXML)) { 806 | logMessage("getListContents() received a non-ul element"); 807 | return; 808 | } 809 | // By this point, we can be sure that $listXML is a ul element 810 | global $defaultSecurityValue; 811 | global $usersGroups; 812 | global $user; // Used in this function purely for logging 813 | 814 | $header = "getListContents(): "; 815 | $output = ""; 816 | $securityRequirement = ""; 817 | //$securityRequirement = getCurrentSecurityRequirement($listXML, 818 | // $inheritedSecurity); 819 | $securityRequirement = $inheritedSecurity; 820 | $ulElementName = $listXML->getName(); 821 | 822 | /* Determine whether or not the current user has access to view the current 823 | xml element */ 824 | logMessage("$header Determine whether or not $user has access to view this". 825 | " $ulElementName element."); 826 | logMessage("$header Calling hasAccess() with usersGroups: '". 827 | getArrayString($usersGroups)."' and securityRequirement: '". 828 | $securityRequirement."'"); 829 | 830 | $accessGranted = hasAccess($usersGroups, $securityRequirement); 831 | 832 | logMessage("$header Given user's groups, '".getArrayString($usersGroups). 833 | "', and the specified security ACL for this xml element, '". 834 | "$securityRequirement', the user's security clearance has ". 835 | "been identified as ".($accessGranted ? "clear" : "prohibited"). 836 | ". Note that the defaultSecurityValue is '". 837 | "$defaultSecurityValue'."); 838 | 839 | /* As long as the current security requirement is not null, add the 840 | appropriate opening tag for this xml element. This is so that child 841 | elements of lesser security requirements can still be displayed. 842 | */ 843 | $output = $output."<$ulElementName>\n"; 844 | 845 | /* Now that the opening tag for this xml element (again, should be ul) has 846 | been added, we can begin traversing through the child elements to get 847 | content of this list. 848 | */ 849 | foreach($listXML as $content) { 850 | // This code works under the assumption that ul elements can ONLY 851 | // contain li elements and that nested ul elements must be enclosed in 852 | // an li element. 853 | if (isULElement($content)) { 854 | // This should not have happened!! 855 | logMessage("$header Encountered a ul element when we should have ". 856 | "only been dealing with li elements."); 857 | } 858 | 859 | // Get security requirement of current element 860 | $securityRequirement = getCurrentSecurityRequirement($content, 861 | $inheritedSecurity); 862 | if ($securityRequirement == null || $securityRequirement == "") { 863 | $securityRequirement = $inheritedSecurity; 864 | } 865 | logMessage("$header Get security requirement of current element --> ". 866 | $securityRequirement); 867 | 868 | // Determine whether user has access to current xml element 869 | logMessage("$header Determine whether '$user' has access to '". 870 | trim((string)$content)."'"); 871 | $accessGranted = hasAccess($usersGroups, $securityRequirement); 872 | 873 | 874 | 875 | $urlAttributeValue = getAttributeValue($content, "url"); 876 | $elementName = $content->getName(); 877 | 878 | $shouldExcludeClosingTag = hasChildren($content); 879 | if ($shouldExcludeClosingTag) { 880 | logMessage("$header Determined that the current xml element: ". 881 | "$content has children."); 882 | if ($accessGranted) { 883 | $intermediateContent = getOutputHTML($content, 884 | $shouldAddSwapToLinks, 885 | true, 886 | $shouldIncludeCSSMenuClass); 887 | $output = $output.$intermediateContent; 888 | logMessage("$header Added $intermediateContent to output"); 889 | $children = $content->children(); 890 | // First child should be a ul element 891 | logMessage("$header Begin recursive call..."); 892 | $output = $output.getListContents($children[0], 893 | $securityRequirement, 894 | $shouldAddSwapToLinks, 895 | $shouldIncludeCSSMenuClass); 896 | // Close the li tag 897 | $output = $output."\n"; 898 | } 899 | } else { 900 | if ($accessGranted) { 901 | $output = $output.getOutputHTML($content, $shouldAddSwapToLinks, 902 | false, false); 903 | } 904 | } 905 | } 906 | $output = $output."\n"; 907 | return $output; 908 | } 909 | 910 | 911 | /** 912 | * Parses the content of the xml file and outputs its HTML 913 | * representation. 914 | * 915 | * Assumes you have given it the content xml element 916 | * 917 | * @param SimpleXMLElement $contentBlock 918 | * @param string $inheritedSecurity 919 | * 920 | * @return string 921 | * @author Andrew Darwin 922 | * @author Delvison Castillo 923 | */ 924 | function getContent($contentBlock, $inheritedSecurityValue) { 925 | global $usersGroups; 926 | global $defaultSecurityValue; 927 | 928 | if ($inheritedSecurityValue == "") { 929 | $inheritedSecurityValue = $defaultSecurityValue; 930 | } 931 | 932 | $header = "getContent(contentBlock): "; 933 | logMessage("$header Attempting to get content"); 934 | 935 | // Determine number of column declarations 936 | $columnBlocks = $contentBlock->column; 937 | $numberOfColumns = 0; 938 | $numberOfColumnsEncountered = 0; 939 | foreach ($columnBlocks as $columnBlock) { 940 | $securityValue = getCurrentSecurityRequirement($columnBlock, 941 | $defaultSecurityValue); 942 | if(hasAccess($usersGroups, $securityValue)) { 943 | $numberOfColumns++; 944 | } 945 | } 946 | 947 | $contentString = ""; 948 | if ($contentBlock == null) { 949 | logMessage("$header contentBlock is null. This may indicate trying to ". 950 | "access a file on a remote server."); 951 | } 952 | logMessage("$header Beginning to iterate through xml elements in the ". 953 | "content block"); 954 | foreach ($contentBlock as $xmlElement) { 955 | $elementName = $xmlElement->getName(); 956 | $securityValue = getCurrentSecurityRequirement($xmlElement, 957 | $inheritedSecurityValue); 958 | $accessGranted = hasAccess($usersGroups, $securityValue); 959 | //IF THE ELEMENT IS A UL ELEMENT 960 | if (isULElement($xmlElement)) { 961 | logMessage("$header Encountered unordered list. Send duties to ". 962 | "getListContents()."); 963 | //Don't need to worry about checking security here because 964 | //getListContents() handles it 965 | $contentString .= getListContents($xmlElement, "", true, false); 966 | //PARSE TEXT COLUMN ELEMENTS 967 | } else if ($elementName == "column") { 968 | if ($accessGranted) { 969 | $numberOfColumnsEncountered++; 970 | $contentString .= "
    \n"; 978 | $contentString .= getContent($xmlElement, ""); 979 | $contentString .= "
    \n"; 980 | } 981 | 982 | //PARSE TABLE ELEMENTS 983 | } else if ($elementName == "table") { 984 | if (hasAccess($usersGroups, $securityValue)) { 985 | $contentString .= "\n". 986 | getContent($xmlElement, $securityValue). 987 | "
    \n"; 988 | } 989 | 990 | //PARSE ROW ELEMENTS 991 | } else if ($elementName == "row") { 992 | if (hasAccess($usersGroups, $securityValue)) { 993 | $contentString .= "\n".getContent($xmlElement, 994 | $securityValue)."\n"; 995 | } 996 | 997 | //PARSE COL ELEMENTS 998 | } else if ($elementName == "cell") { 999 | if (hasAccess($usersGroups, $securityValue)) { 1000 | $contentString .= getOutputHTMLWithCustomTag("td", $xmlElement, 1001 | true, false, false); 1002 | } else { 1003 | $contentString .= ""; 1004 | } 1005 | 1006 | //PARSE TABLE TITLES 1007 | } else if ($elementName == "col_title") { 1008 | if (hasAccess($usersGroups, $securityValue)) { 1009 | $contentString .= getOutputHTMLWithCustomTag("th", $xmlElement, 1010 | true, false, false); 1011 | } else { 1012 | $contentString .= ""; 1013 | } 1014 | } else if ($elementName == 'img') { 1015 | $contentString .= getImageHTML($xmlElement, "150px", "auto"); 1016 | } else if ($elementName == "embed") { 1017 | if ($accessGranted) { 1018 | $contentString .= stripEnclosingXMLTag($xmlElement); 1019 | } 1020 | } else { 1021 | if ($accessGranted) { 1022 | logMessage("$header Security has been granted for ". 1023 | "<$elementName>"); 1024 | $contentString = $contentString.getOutputHTML($xmlElement, true, 1025 | false, false); 1026 | } else { 1027 | logMessage("$header Security has not been granted for ". 1028 | "<$elementName>"); 1029 | } 1030 | } 1031 | } 1032 | return $contentString; 1033 | } 1034 | 1035 | 1036 | /** 1037 | * Currently, this function does nothing more than return getContent(). 1038 | * It exists in case we run into a situation where we need to do some special 1039 | * processing befor or after calling getContent(). 1040 | * 1041 | * @param SimpleXMLElement $inputXML 1042 | * 1043 | * @return string 1044 | * @author Andrew Darwin 1045 | */ 1046 | function getInnerContent($inputXML) { 1047 | global $contentXML; 1048 | $header = "getInnerContent(): "; 1049 | logMessage("$header Attempting to get inner content"); 1050 | parseConfig(); // Must parse config first to set global variables 1051 | initializeContent($inputXML); 1052 | $output = "\n\n"; 1053 | $output = $output.getAllScriptDeclarations(); 1054 | $output = $output . "\n\n"; 1055 | $output = $output.getContent($contentXML->content[0], ""); 1056 | $output = $output . "\n"; 1057 | //logMessage("$header $output"); 1058 | return $output; 1059 | } 1060 | 1061 | 1062 | /** 1063 | * This function examins an xml element and returns its specified 1064 | * security requirement. 1065 | * 1066 | * @param SimpleXMLElement $xmlElement 1067 | * @param string $fallbackSecurityValue 1068 | * 1069 | * @return string 1070 | * @author Andrew Darwin 1071 | */ 1072 | function getCurrentSecurityRequirement(SimpleXMLElement $xmlElement, 1073 | $fallbackSecurityValue) { 1074 | global $defaultSecurityValue; 1075 | $header = "getCurrentSecurityRequirement(): "; 1076 | $output = ""; 1077 | $urlACL = ""; 1078 | if ($fallbackSecurityValue == null || $fallbackSecurityValue == "") { 1079 | $fallbackSecurityValue = $defaultSecurityValue; 1080 | } 1081 | logMessage("$header Attempting to get current security requirement for\n". 1082 | $xmlElement->asXML()); 1083 | $attributeValue = getAttributeValue($xmlElement, "security"); 1084 | logMessage("$header security attribute = $attributeValue"); 1085 | $url = getAttributeValue($xmlElement, "url"); 1086 | logMessage("$header url attribute = $url"); 1087 | if ($url != null) { 1088 | $urlACL = getACLforURL($url); 1089 | } 1090 | logMessage("$header urlACL = $urlACL"); 1091 | if ($attributeValue != null) { 1092 | $output = $attributeValue; 1093 | } else if ($urlACL != null) { 1094 | $output = $urlACL; 1095 | } else { 1096 | $output = $fallbackSecurityValue; 1097 | logMessage("$header acl not found. Set it to '$fallbackSecurityValue'"); 1098 | } 1099 | return (string)$output; 1100 | } 1101 | 1102 | 1103 | /** 1104 | * parses the config file 1105 | * 1106 | * @author Andrew Darwin 1107 | * @author Delvison Castillo 1108 | */ 1109 | function parseConfig() { 1110 | global $configFileName; 1111 | global $configXML; 1112 | global $user; 1113 | global $aclDict; 1114 | global $restrictedDirectoriesDict; 1115 | global $startPage; 1116 | global $mainContentFilePath; 1117 | global $defaultSecurityValue; 1118 | global $ldapAddress; 1119 | global $ldapPort; 1120 | global $organizationalUnit1, $organizationalUnit2; 1121 | global $organization, $countryNaming, $attr; 1122 | global $useLDAP; 1123 | global $defaultSecurityInLDAPAbsence; 1124 | global $domainName; 1125 | 1126 | $logHeader = "parseConfig()"; 1127 | 1128 | //$pathToXMLFiles = getPathToXMLFiles(); 1129 | $configFilePath = getPathToXMLFile($configFileName); 1130 | logMessage("$logHeader configFilePath = $configFilePath"); 1131 | $configXML = simplexml_load_file($configFilePath); 1132 | logMessage("parseConfig() loaded config file and will now begin parsing"); 1133 | //parse access_config 1134 | $accessConfigXML = $configXML->access_config[0]; 1135 | foreach ($accessConfigXML as $xmlElement){ 1136 | $elementName = $xmlElement->getName(); 1137 | if ($elementName == "acl") { 1138 | $aclName = (string)$xmlElement->name; 1139 | $groups = $xmlElement->group; 1140 | $groupsArray = array(); 1141 | foreach ($groups as $groupItem) { 1142 | array_push($groupsArray, (string)$groupItem); 1143 | } 1144 | logMessage("$logHeader Encountered acl element with name = ". 1145 | "$aclName and groups = ".getArrayString($groupsArray)); 1146 | $tempArray = array((string)$aclName => $groupsArray); /*Had to cast 1147 | $aclName to string here 1148 | to avoid an illegal 1149 | offset type warning*/ 1150 | 1151 | $aclDict = array_merge($aclDict, $tempArray); /* Had to use 1152 | array_merge instead 1153 | of array_push */ 1154 | } else if ($elementName == "restricted_directory") { 1155 | $path = (string)$xmlElement->path; 1156 | $acl_name = (string)$xmlElement->acl_name; 1157 | logMessage("$logHeader Encountered restricted_directory element ". 1158 | "with path = $path and acl_name = $acl_name"); 1159 | $restrictedDirectoriesDict[$path] = $acl_name; 1160 | } 1161 | 1162 | } 1163 | $siteConfigXML = $configXML->site_config[0]; 1164 | foreach ($siteConfigXML as $xmlElement) { 1165 | $elementName = $xmlElement->getName(); 1166 | $stringValue = (string)$xmlElement; 1167 | switch ($elementName) { 1168 | case "start_page": 1169 | $startPage = $stringValue; break; 1170 | case "main_content": 1171 | $mainContentFilePath = $stringValue; break; 1172 | case "default_security": 1173 | $defaultSecurityValue = $stringValue; break; 1174 | case "domain_name": 1175 | $domainName = $stringValue; break; 1176 | 1177 | } 1178 | } 1179 | $ldapConfigXML = $configXML->ldap_config[0]; 1180 | foreach ($ldapConfigXML as $xmlElement) { 1181 | $elementName = $xmlElement->getName(); 1182 | $stringValue = getTrimmed((string)$xmlElement); 1183 | switch ($elementName) { 1184 | case "address": 1185 | $ldapAddress = $stringValue; break; 1186 | case "port": 1187 | $ldapPort = $stringValue; break; 1188 | case "organizational_unit1": 1189 | $organizationalUnit1 = $stringValue; break; 1190 | case "organizational_unit2": 1191 | $organizationalUnit2 = $stringValue; break; 1192 | case "organization": 1193 | $organization = $stringValue; break; 1194 | case "country_naming": 1195 | $countryNaming = $stringValue; break; 1196 | case "attribute": 1197 | $attr = $stringValue; break; 1198 | case "use_ldap": 1199 | $useLDAP = $stringValue == "true"; break; 1200 | case "default_security_in_ldap_absence": 1201 | $defaultSecurityInLDAPAbsence = $stringValue; break; 1202 | } 1203 | } 1204 | if (!$useLDAP) { 1205 | $defaultSecurityValue = $defaultSecurityInLDAPAbsence; 1206 | } 1207 | logMessage("$logHeader finished parsing and produced aclDict = '". 1208 | getArrayString($aclDict)."' and restrictedDirectoriesDict = '". 1209 | getArrayString($restrictedDirectoriesDict)."'"); 1210 | } 1211 | /******************************************************************************/ 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | /******************************************************************************* 1220 | ************************ XML Parsing (Stateless) **************************** 1221 | ******************************************************************************/ 1222 | 1223 | /** 1224 | * Returns the html title entry 1225 | * 1226 | * @param SimpleXMLElement $contentXML 1227 | * 1228 | * @return string 1229 | * @author Andrew Darwin 1230 | */ 1231 | function getTitleHTML(SimpleXMLElement $contentXML) { 1232 | $tag = "title"; 1233 | $content = $contentXML->header[0]->title; 1234 | $output = "<$tag>$content\n"; 1235 | logMessage("Got html title: $output"); 1236 | return $output; 1237 | } 1238 | 1239 | 1240 | /** 1241 | * Returns all parts of the html header that are not the title. 1242 | * 1243 | * @param SimpleXMLElement $contentXML 1244 | * 1245 | * @return string 1246 | * @author Andrew Darwin 1247 | */ 1248 | function getHeaderHTML(SimpleXMLElement $contentXML) { 1249 | $header = "getHeaderHTML(): "; 1250 | $headerContent = $contentXML->header[0]; // There should only be one header 1251 | $output = ""; 1252 | foreach($headerContent as $content) { 1253 | $elementName = $content->getName(); 1254 | if ($elementName == "img") { 1255 | logMessage("$header Encountered img element. Add it to output"); 1256 | $output .= getImageHTML($content, "auto", "60px"); 1257 | } else if ($elementName == "title") { 1258 | logMessage("$header Encountered title element. Do nothing."); 1259 | } else { 1260 | logMessage("$header Encountered unknown element. Add it to output"); 1261 | $output .= getOutputHTML($content, false, false, false); 1262 | } 1263 | } 1264 | return $output; 1265 | } 1266 | 1267 | 1268 | /** 1269 | * Returns the html code for the global navigation bar, located at the top of 1270 | * the webpage. 1271 | * 1272 | * @param SimpleXMLElement $contentXML 1273 | * 1274 | * @return string 1275 | * @author Andrew Darwin 1276 | */ 1277 | function getNavBarHTML($contentXML) { 1278 | $header = "getNavBarHTML(): "; 1279 | $navBarContent = $contentXML->navbar[0]; // Only one navbar[0] 1280 | $output = ""; 1281 | $navList = "\n"; 1292 | return $output; 1293 | } 1294 | 1295 | 1296 | /** 1297 | * A convenience function that takes an xml element and outputs 1298 | * the appropriate HTML code 1299 | * 1300 | * Input Parameters: SimpleXMLElement 1301 | * @param SimpleXMLElement $imgXMLElement 1302 | * @param string $imageWidth 1303 | * @param string $imageHeight 1304 | * 1305 | * @return string 1306 | * @author Andrew Darwin 1307 | */ 1308 | function getImageHTML(SimpleXMLElement $imgXMLElement, 1309 | $imageWidth, $imageHeight) { 1310 | $output = ""; 1311 | if (hasAccessTo($imgXMLElement)) { 1312 | $urlPrefix = ""; 1313 | $urlSuffix = ""; 1314 | if ($imageWidth == null) { 1315 | $imageWidth = "auto"; 1316 | } 1317 | if ($imageHeight == null) { 1318 | $imageHeight = "auto"; 1319 | } 1320 | $elementName = $imgXMLElement->getName(); 1321 | $src = getAttributeValue($imgXMLElement, "src"); 1322 | $width = getAttributeValue($imgXMLElement, "width"); 1323 | $height = getAttributeValue($imgXMLElement, "height"); 1324 | $url = getAttributeValue($imgXMLElement, "url"); 1325 | $cssEmbedAttributeValue = getAttributeValue($imgXMLElement, "css_embed"); 1326 | $cssClassValue = getAttributeValue($imgXMLElement, "css_class"); 1327 | if ($url != null && $url != "") { 1328 | $urlPrefix = ""; 1329 | $urlSuffix = ""; 1330 | } 1331 | if ($width == null) { 1332 | $width = "auto"; 1333 | } 1334 | if ($height == null) { 1335 | $height = "auto"; 1336 | } 1337 | $altText = (string)$imgXMLElement; 1338 | if ($altText != null && $altText != "") { 1339 | $altText = "alt=\"$altText\""; 1340 | } 1341 | $embeddedCSSText = "width:$width; height:$height;"; 1342 | if ($cssEmbedAttributeValue != null) { 1343 | $embeddedCSSText .= $cssEmbedAttributeValue; 1344 | } 1345 | if ($cssClassValue != null) { 1346 | $cssClassValue = " class='$cssClassValue'"; 1347 | } else { 1348 | $cssClassValue = ""; 1349 | } 1350 | if ($elementName == "img") { 1351 | $output = "$urlPrefix<$elementName$cssClassValue"." style=". 1352 | "'$embeddedCSSText' src='$src' $altText/>$urlSuffix\n"; 1353 | } 1354 | } 1355 | return $output; 1356 | } 1357 | 1358 | 1359 | /** 1360 | * Returns the entire HTML code for the navigation sidebar 1361 | * Calls getNavigationTitle and getNagivationItems 1362 | * 1363 | * @param SimpleXMLElement $contentXML 1364 | * 1365 | * @return string 1366 | * @author Andrew Darwin 1367 | */ 1368 | function getNavigation(SimpleXMLElement $contentXML) { 1369 | $output = ""; 1370 | $output .= getNavigationTitle($contentXML); 1371 | $output .= getNavigationItems($contentXML); 1372 | return $output; 1373 | } 1374 | 1375 | 1376 | /** 1377 | * Returns the content for the navigation sidebar, formatted as HTML 1378 | * 1379 | * @param SimpleXMLElement $contentXML 1380 | * 1381 | * @return string 1382 | * @author Andrew Darwin 1383 | */ 1384 | function getNavigationItems(SimpleXMLElement $contentXML) { 1385 | $header = "getNavigation(): "; 1386 | $navigationContent = $contentXML->navigation[0]; 1387 | $output = ""; 1388 | foreach($navigationContent as $content) { 1389 | $elementName = $content->getName(); 1390 | if ($elementName == "ul") { 1391 | logMessage("$header Encountered ul element. Call ". 1392 | "getListContents() and add return value to output."); 1393 | $output .= getListContents($content, "", true, true); 1394 | } 1395 | } 1396 | return $output; 1397 | } 1398 | 1399 | 1400 | /** 1401 | * Returns the title for the navigation sidebar, formatted as HTML 1402 | * 1403 | * @param SimpleXMLElement $contentXML 1404 | * 1405 | * @return string 1406 | * @author Andrew Darwin 1407 | */ 1408 | function getNavigationTitle(SimpleXMLElement $contentXML) { 1409 | $header = "getNavigation(): "; 1410 | $navigationContent = $contentXML->navigation[0]; 1411 | $output = ""; 1412 | foreach($navigationContent as $content) { 1413 | $elementName = $content->getName(); 1414 | if ($elementName == "sidebar_title") { 1415 | logMessage("$header Encountered title element. Format and add"); 1416 | $heading = getAttributeValue($content, "heading"); 1417 | if ($heading == null || $heading == "") { 1418 | $heading = "h3"; 1419 | } 1420 | $output = $output."
    ". 1421 | getCustomTaggedHTMLElementString($heading, $content, "", 1422 | false)."
    \n"; 1423 | break; 1424 | } 1425 | } 1426 | return $output; 1427 | } 1428 | 1429 | 1430 | /** 1431 | * This function examins an xml element and returns the specified attribute 1432 | * value 1433 | * 1434 | * @param SimpleXMLElement $xmlElement 1435 | * @param string $targetAttributeName 1436 | * 1437 | * @return string 1438 | * @author Andrew Darwin 1439 | */ 1440 | function getAttributeValue($xmlElement, $targetAttributeName) { 1441 | $attributes = $xmlElement->attributes(); 1442 | $output = ""; 1443 | if ($attributes != null) { 1444 | foreach ($attributes as $attribute) { 1445 | $currentAttributeName = $attribute->getName(); 1446 | if ($currentAttributeName == $targetAttributeName) { 1447 | $output = $attribute; 1448 | break; 1449 | } 1450 | } 1451 | } 1452 | return $output; 1453 | } 1454 | 1455 | 1456 | /** 1457 | * Returns the html output of any given xml element 1458 | * 1459 | * @param SimpleXMLElement $xmlElement 1460 | * @param boolean $shouldAddSwapToLinks Specifies whether to add 'swap' to links 1461 | * @param boolean $shouldExcludeClosingTag Specifies whether to include the 1462 | * closing tag 1463 | * @param boolean $shouldInsertCSSMenuClass Specifies whether to insert the CSS 1464 | * 'listhead' class 1465 | * 1466 | * @return string 1467 | * @author Andrew Darwin 1468 | */ 1469 | function getOutputHTML($xmlElement, $shouldAddSwapToLinks, 1470 | $shouldExcludeClosingTag, $shouldInsertCSSMenuClass) { 1471 | return getOutputHTMLWithCustomTag($xmlElement->getName(), 1472 | $xmlElement, 1473 | $shouldAddSwapToLinks, 1474 | $shouldExcludeClosingTag, 1475 | $shouldInsertCSSMenuClass); 1476 | } 1477 | 1478 | 1479 | /** 1480 | * Generates the output html code for an xml element with a custom tag 1481 | * @param string $tagName 1482 | * Specifies custom tag name to use for given xml element content 1483 | * @param SimpleXMLElement $xmlElement 1484 | * @param boolean $shouldAddSwapToLinks 1485 | * Specifies whether to add 'swap' to links 1486 | * @param boolean $shouldExcludeClosingTag 1487 | * Specifies whether to include the closing tag 1488 | * @param boolean $shouldInsertCSSMenuClass 1489 | * Specifies whether to insert the CSS 'listhead' class 1490 | * 1491 | * @return string 1492 | * @author Andrew Darwin 1493 | */ 1494 | function getOutputHTMLWithCustomTag($tagName, $xmlElement, 1495 | $shouldAddSwapToLinks, 1496 | $shouldExcludeClosingTag, 1497 | $shouldInsertCSSMenuClass) { 1498 | $header = "getOutputHTMLWithCustomTag(): "; 1499 | logMessage("$header\nBeginning call with:\nTagName=$tagName\n". 1500 | "xmlElement=".getTrimmed($xmlElement)."\naddSwap=...."); 1501 | $outputHTMLAttributes = ""; 1502 | //get attribute value css class 1503 | $cssClassAttributeValue = getAttributeValue($xmlElement, "css_class"); 1504 | //get attribute value for embedded css 1505 | $cssEmbedAttributeValue = getAttributeValue($xmlElement, "css_embed"); 1506 | $cssMenuClassName = ""; 1507 | //insert listhead as a class if necessary 1508 | if ($shouldInsertCSSMenuClass) { 1509 | $cssMenuClassName = "listhead"; 1510 | } 1511 | $styledContentString = getElementContentWithStyleTags($xmlElement, 1512 | $shouldAddSwapToLinks, 1513 | $cssMenuClassName); 1514 | if ($shouldInsertCSSMenuClass) { 1515 | $styledContentString = "". 1516 | $styledContentString. 1517 | ""; 1518 | } 1519 | //print out appropriate css class 1520 | if ($cssClassAttributeValue != null) { 1521 | $outputHTMLAttributes = "class=\"$cssClassAttributeValue\" "; 1522 | } 1523 | //print out appropriate embedded css 1524 | if ($cssEmbedAttributeValue != null) { 1525 | $outputHTMLAttributes .= "style=\"$cssEmbedAttributeValue\" "; 1526 | } 1527 | 1528 | $output = getCustomTaggedHTMLElementString($tagName, 1529 | $styledContentString, 1530 | $outputHTMLAttributes, 1531 | $shouldExcludeClosingTag); 1532 | logMessage("$header output = '$output'"); 1533 | return $output; 1534 | } 1535 | 1536 | 1537 | /** 1538 | * Generates the output html code for a custom tagged xml element 1539 | * @param string $tagName 1540 | * @param string $xmlElementContentWithStyling 1541 | * @param string $outputHTMLAttributes 1542 | * @param boolean $shouldExcludeClosingTag 1543 | * 1544 | * @return string 1545 | * @author Andrew Darwin 1546 | */ 1547 | function getCustomTaggedHTMLElementString( 1548 | $tagName, $xmlElementContentWithStyling, 1549 | $outputHTMLAttributes, $shouldExcludeClosingTag) { 1550 | $header = "getCustomTaggedHTMLElementString(): "; 1551 | logMessage("$header Starting function call...\n". 1552 | "tagName = '$tagName'\n". 1553 | "xmlElementContentWithStyling = ". 1554 | "'$xmlElementContentWithStyling'\n". 1555 | "outputHTMLAttributes = '$outputHTMLAttributes'\n". 1556 | "shouldExcludeClosingTag = some boolean"); 1557 | if ($outputHTMLAttributes == null) { 1558 | $outputHTMLAttributes = ""; 1559 | } else if ($outputHTMLAttributes != "") { 1560 | $outputHTMLAttributes = " ".$outputHTMLAttributes; 1561 | } 1562 | $output = "<$tagName$outputHTMLAttributes>$xmlElementContentWithStyling"; 1563 | if ($shouldExcludeClosingTag) { 1564 | $output = $output."\n"; 1565 | } else { 1566 | $output = $output."\n"; 1567 | } 1568 | logMessage("$header Return:\n$output"); 1569 | return $output; 1570 | } 1571 | 1572 | 1573 | /** 1574 | * Parses the style tags of the given xml element and uses them to generate 1575 | * the associated html code. 1576 | * @param SimpleXMLElement $xmlElement 1577 | * @param boolean $shouldAddSwapToLinks 1578 | * @param string $cssMenuClassName 1579 | * 1580 | * @return string 1581 | * @author Andrew Darwin 1582 | */ 1583 | function getElementContentWithStyleTags($xmlElement, $shouldAddSwapToLinks, 1584 | $cssMenuClassName) { 1585 | $header = "getElementContentWithStyleTags(): "; 1586 | logMessage("$header Beginning call...\n". 1587 | "xmlElement = '".getTrimmed($xmlElement)."'\n". 1588 | "shouldAddSwapToLinks = some boolean\n". 1589 | "cssMenuClassName = '$cssMenuClassName'"); 1590 | $attributes = $xmlElement->attributes(); 1591 | logMessage("$header Obtained attributes from XML Element, '$xmlElement'"); 1592 | $output = ""; 1593 | $prefix = ""; 1594 | $suffix = ""; 1595 | $urlSpecified = false; 1596 | $urlOpenTag = ""; 1597 | $urlCloseTag = ""; 1598 | $outputHTMLAttributes = ""; 1599 | if ($attributes != null) { 1600 | foreach ($attributes as $attribute) { 1601 | $currentAttributeName = $attribute->getName(); 1602 | switch ($currentAttributeName) { 1603 | case "style": 1604 | $styles = formatStyleAttribute($attribute); 1605 | foreach ($styles as $style) { 1606 | addToPrefix($prefix, "<$style>"); 1607 | addToSuffix($suffix, ""); 1608 | } 1609 | break; 1610 | case "css": 1611 | $outputHTMLAttributes = "class=\"$attribute\""; 1612 | break; 1613 | case "url": 1614 | // Must apply url last, so lets save it to a variable and do 1615 | // stuff with it later 1616 | $urlSpecified = true; 1617 | $loadURLPrefix = ""; 1618 | if (strpos(getcwd(), "resources/scripts") == false) { 1619 | $loadURLPrefix = "resources/scripts/"; 1620 | } 1621 | 1622 | // Escape any necessary characters from the url 1623 | $attribute = clean_url($attribute); 1624 | logMessage("$header Clean url = '$attribute'"); 1625 | $target = getAttributeValue($xmlElement, "target"); 1626 | $isExternal = is_link_external($attribute); 1627 | $loadURLPrefix .= "loadURL.php"; 1628 | $extension = pathinfo($attribute, PATHINFO_EXTENSION); 1629 | if ($extension == "xml") { 1630 | $href = "'$loadURLPrefix?url=$attribute'"; 1631 | } else { 1632 | $href = "'$attribute'"; 1633 | } 1634 | if ($target == "new_tab" || 1635 | ($target != "same_tab" && 1636 | is_link_external($attribute))) { 1637 | $href .= " target='_blank'"; 1638 | $shouldAddSwapToLinks = false; 1639 | } 1640 | $urlOpenTag = "children(); 1663 | $child = $children[0]; 1664 | if ($child->getName() == "link") { 1665 | logMessage("$header Determined that XML Element, '". 1666 | getTrimmed($xmlElement)."' has link children. Set ". 1667 | "inner content to [recursive call]..."); 1668 | $innerContent = parseLink($xmlElement); 1669 | logMessage("$header InnerContent is now '$innerContent' after ". 1670 | "calling parseLink"); 1671 | } else { 1672 | logMessage("$header Determined xml element, '". 1673 | getTrimmed($xmlElement). 1674 | "' has children, but not LINK children"); 1675 | } 1676 | } else { 1677 | logMessage("$header Determined that XML Element, '". 1678 | getTrimmed($xmlElement)."' does not have any link ". 1679 | "children. Set inner content to '".getTrimmed($xmlElement). 1680 | "'"); 1681 | } 1682 | $output = $prefix.$innerContent.$suffix; 1683 | logMessage("$header Return '$output'"); 1684 | return $output; 1685 | } 1686 | /******************************************************************************/ 1687 | ?> 1688 | -------------------------------------------------------------------------------- /resources/scripts/jquery.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license 2 | //@ sourceMappingURL=jquery.min.map 3 | */(function(e,t){var n,r,i=typeof t,o=e.document,a=e.location,s=e.jQuery,u=e.$,l={},c=[],p="1.9.1",f=c.concat,d=c.push,h=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=p.trim,b=function(e,t){return new b.fn.init(e,t,r)},x=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^[\],:{}\s]*$/,E=/(?:^|:|,)(?:\s*\[)+/g,S=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,A=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,j=/^-ms-/,D=/-([\da-z])/gi,L=function(e,t){return t.toUpperCase()},H=function(e){(o.addEventListener||"load"===e.type||"complete"===o.readyState)&&(q(),b.ready())},q=function(){o.addEventListener?(o.removeEventListener("DOMContentLoaded",H,!1),e.removeEventListener("load",H,!1)):(o.detachEvent("onreadystatechange",H),e.detachEvent("onload",H))};b.fn=b.prototype={jquery:p,constructor:b,init:function(e,n,r){var i,a;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof b?n[0]:n,b.merge(this,b.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:o,!0)),C.test(i[1])&&b.isPlainObject(n))for(i in n)b.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(a=o.getElementById(i[2]),a&&a.parentNode){if(a.id!==i[2])return r.find(e);this.length=1,this[0]=a}return this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):b.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),b.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return h.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=b.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return b.each(this,e,t)},ready:function(e){return b.ready.promise().done(e),this},slice:function(){return this.pushStack(h.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(b.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:d,sort:[].sort,splice:[].splice},b.fn.init.prototype=b.fn,b.extend=b.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||b.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(o=arguments[u]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(b.isPlainObject(r)||(n=b.isArray(r)))?(n?(n=!1,a=e&&b.isArray(e)?e:[]):a=e&&b.isPlainObject(e)?e:{},s[i]=b.extend(c,a,r)):r!==t&&(s[i]=r));return s},b.extend({noConflict:function(t){return e.$===b&&(e.$=u),t&&e.jQuery===b&&(e.jQuery=s),b},isReady:!1,readyWait:1,holdReady:function(e){e?b.readyWait++:b.ready(!0)},ready:function(e){if(e===!0?!--b.readyWait:!b.isReady){if(!o.body)return setTimeout(b.ready);b.isReady=!0,e!==!0&&--b.readyWait>0||(n.resolveWith(o,[b]),b.fn.trigger&&b(o).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===b.type(e)},isArray:Array.isArray||function(e){return"array"===b.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==b.type(e)||e.nodeType||b.isWindow(e))return!1;try{if(e.constructor&&!y.call(e,"constructor")&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||y.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=b.buildFragment([e],t,i),i&&b(i).remove(),b.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=b.trim(n),n&&k.test(n.replace(S,"@").replace(A,"]").replace(E,"")))?Function("return "+n)():(b.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||b.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&b.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(j,"ms-").replace(D,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:v&&!v.call("\ufeff\u00a0")?function(e){return null==e?"":v.call(e)}:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?b.merge(n,"string"==typeof e?[e]:e):d.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(g)return g.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return f.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),b.isFunction(e)?(r=h.call(arguments,2),i=function(){return e.apply(n||this,r.concat(h.call(arguments)))},i.guid=e.guid=e.guid||b.guid++,i):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if("object"===b.type(r)){o=!0;for(u in r)b.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,b.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(b(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),b.ready.promise=function(t){if(!n)if(n=b.Deferred(),"complete"===o.readyState)setTimeout(b.ready);else if(o.addEventListener)o.addEventListener("DOMContentLoaded",H,!1),e.addEventListener("load",H,!1);else{o.attachEvent("onreadystatechange",H),e.attachEvent("onload",H);var r=!1;try{r=null==e.frameElement&&o.documentElement}catch(i){}r&&r.doScroll&&function a(){if(!b.isReady){try{r.doScroll("left")}catch(e){return setTimeout(a,50)}q(),b.ready()}}()}return n.promise(t)},b.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=b.type(e);return b.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=b(o);var _={};function F(e){var t=_[e]={};return b.each(e.match(w)||[],function(e,n){t[n]=!0}),t}b.Callbacks=function(e){e="string"==typeof e?_[e]||F(e):b.extend({},e);var n,r,i,o,a,s,u=[],l=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=u.length,n=!0;u&&o>a;a++)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,u&&(l?l.length&&c(l.shift()):r?u=[]:p.disable())},p={add:function(){if(u){var t=u.length;(function i(t){b.each(t,function(t,n){var r=b.type(n);"function"===r?e.unique&&p.has(n)||u.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=u.length:r&&(s=t,c(r))}return this},remove:function(){return u&&b.each(arguments,function(e,t){var r;while((r=b.inArray(t,u,r))>-1)u.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?b.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],this},disable:function(){return u=l=r=t,this},disabled:function(){return!u},lock:function(){return l=t,r||p.disable(),this},locked:function(){return!l},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!u||i&&!l||(n?l.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},b.extend({Deferred:function(e){var t=[["resolve","done",b.Callbacks("once memory"),"resolved"],["reject","fail",b.Callbacks("once memory"),"rejected"],["notify","progress",b.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return b.Deferred(function(n){b.each(t,function(t,o){var a=o[0],s=b.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&b.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?b.extend(e,r):r}},i={};return r.pipe=r.then,b.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=h.call(arguments),r=n.length,i=1!==r||e&&b.isFunction(e.promise)?r:0,o=1===i?e:b.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?h.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&b.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}}),b.support=function(){var t,n,r,a,s,u,l,c,p,f,d=o.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="
    a",n=d.getElementsByTagName("*"),r=d.getElementsByTagName("a")[0],!n||!r||!n.length)return{};s=o.createElement("select"),l=s.appendChild(o.createElement("option")),a=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={getSetAttribute:"t"!==d.className,leadingWhitespace:3===d.firstChild.nodeType,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:"/a"===r.getAttribute("href"),opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:!!a.value,optSelected:l.selected,enctype:!!o.createElement("form").enctype,html5Clone:"<:nav>"!==o.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===o.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},a.checked=!0,t.noCloneChecked=a.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!l.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}a=o.createElement("input"),a.setAttribute("value",""),t.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),t.radioValue="t"===a.value,a.setAttribute("checked","t"),a.setAttribute("name","t"),u=o.createDocumentFragment(),u.appendChild(a),t.appendChecked=a.checked,t.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;return d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip,b(function(){var n,r,a,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",u=o.getElementsByTagName("body")[0];u&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",u.appendChild(n).appendChild(d),d.innerHTML="
    t
    ",a=d.getElementsByTagName("td"),a[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===a[0].offsetHeight,a[0].style.display="",a[1].style.display="none",t.reliableHiddenOffsets=p&&0===a[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=4===d.offsetWidth,t.doesNotIncludeMarginInBodyOffset=1!==u.offsetTop,e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(o.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="
    ",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(u.style.zoom=1)),u.removeChild(n),n=d=a=r=null)}),n=s=u=l=r=a=null,t}();var O=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,B=/([A-Z])/g;function P(e,n,r,i){if(b.acceptData(e)){var o,a,s=b.expando,u="string"==typeof n,l=e.nodeType,p=l?b.cache:e,f=l?e[s]:e[s]&&s;if(f&&p[f]&&(i||p[f].data)||!u||r!==t)return f||(l?e[s]=f=c.pop()||b.guid++:f=s),p[f]||(p[f]={},l||(p[f].toJSON=b.noop)),("object"==typeof n||"function"==typeof n)&&(i?p[f]=b.extend(p[f],n):p[f].data=b.extend(p[f].data,n)),o=p[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[b.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[b.camelCase(n)])):a=o,a}}function R(e,t,n){if(b.acceptData(e)){var r,i,o,a=e.nodeType,s=a?b.cache:e,u=a?e[b.expando]:b.expando;if(s[u]){if(t&&(o=n?s[u]:s[u].data)){b.isArray(t)?t=t.concat(b.map(t,b.camelCase)):t in o?t=[t]:(t=b.camelCase(t),t=t in o?[t]:t.split(" "));for(r=0,i=t.length;i>r;r++)delete o[t[r]];if(!(n?$:b.isEmptyObject)(o))return}(n||(delete s[u].data,$(s[u])))&&(a?b.cleanData([e],!0):b.support.deleteExpando||s!=s.window?delete s[u]:s[u]=null)}}}b.extend({cache:{},expando:"jQuery"+(p+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?b.cache[e[b.expando]]:e[b.expando],!!e&&!$(e)},data:function(e,t,n){return P(e,t,n)},removeData:function(e,t){return R(e,t)},_data:function(e,t,n){return P(e,t,n,!0)},_removeData:function(e,t){return R(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&b.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),b.fn.extend({data:function(e,n){var r,i,o=this[0],a=0,s=null;if(e===t){if(this.length&&(s=b.data(o),1===o.nodeType&&!b._data(o,"parsedAttrs"))){for(r=o.attributes;r.length>a;a++)i=r[a].name,i.indexOf("data-")||(i=b.camelCase(i.slice(5)),W(o,i,s[i]));b._data(o,"parsedAttrs",!0)}return s}return"object"==typeof e?this.each(function(){b.data(this,e)}):b.access(this,function(n){return n===t?o?W(o,e,b.data(o,e)):null:(this.each(function(){b.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function W(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(B,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:O.test(r)?b.parseJSON(r):r}catch(o){}b.data(e,n,r)}else r=t}return r}function $(e){var t;for(t in e)if(("data"!==t||!b.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}b.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=b._data(e,n),r&&(!i||b.isArray(r)?i=b._data(e,n,b.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=b.queue(e,t),r=n.length,i=n.shift(),o=b._queueHooks(e,t),a=function(){b.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return b._data(e,n)||b._data(e,n,{empty:b.Callbacks("once memory").add(function(){b._removeData(e,t+"queue"),b._removeData(e,n)})})}}),b.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?b.queue(this[0],e):n===t?this:this.each(function(){var t=b.queue(this,e,n);b._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&b.dequeue(this,e)})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(e,t){return e=b.fx?b.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=b.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=b._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var I,z,X=/[\t\r\n]/g,U=/\r/g,V=/^(?:input|select|textarea|button|object)$/i,Y=/^(?:a|area)$/i,J=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,G=/^(?:checked|selected)$/i,Q=b.support.getSetAttribute,K=b.support.input;b.fn.extend({attr:function(e,t){return b.access(this,b.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,t){return b.access(this,b.prop,e,t,arguments.length>1)},removeProp:function(e){return e=b.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u="string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=b.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||"string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?b.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return b.isFunction(e)?this.each(function(n){b(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=b(this),u=t,l=e.match(w)||[];while(o=l[a++])u=r?u:!s.hasClass(o),s[u?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&b._data(this,"__className__",this.className),this.className=this.className||e===!1?"":b._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(X," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=b.isFunction(e),this.each(function(n){var o,a=b(this);1===this.nodeType&&(o=i?e.call(this,n,a.val()):e,null==o?o="":"number"==typeof o?o+="":b.isArray(o)&&(o=b.map(o,function(e){return null==e?"":e+""})),r=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=b.valHooks[o.type]||b.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(U,""):null==n?"":n)}}}),b.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;for(;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(b.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&b.nodeName(n.parentNode,"optgroup"))){if(t=b(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=b.makeArray(t);return b(e).find("option").each(function(){this.selected=b.inArray(b(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var o,a,s,u=e.nodeType;if(e&&3!==u&&8!==u&&2!==u)return typeof e.getAttribute===i?b.prop(e,n,r):(a=1!==u||!b.isXMLDoc(e),a&&(n=n.toLowerCase(),o=b.attrHooks[n]||(J.test(n)?z:I)),r===t?o&&a&&"get"in o&&null!==(s=o.get(e,n))?s:(typeof e.getAttribute!==i&&(s=e.getAttribute(n)),null==s?t:s):null!==r?o&&a&&"set"in o&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r):(b.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=b.propFix[n]||n,J.test(n)?!Q&&G.test(n)?e[b.camelCase("default-"+n)]=e[r]=!1:e[r]=!1:b.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!b.support.radioValue&&"radio"===t&&b.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!b.isXMLDoc(e),a&&(n=b.propFix[n]||n,o=b.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):V.test(e.nodeName)||Y.test(e.nodeName)&&e.href?0:t}}}}),z={get:function(e,n){var r=b.prop(e,n),i="boolean"==typeof r&&e.getAttribute(n),o="boolean"==typeof r?K&&Q?null!=i:G.test(n)?e[b.camelCase("default-"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?b.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&b.propFix[n]||n,n):e[b.camelCase("default-"+n)]=e[n]=!0,n}},K&&Q||(b.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return b.nodeName(e,"input")?e.defaultValue:r&&r.specified?r.value:t},set:function(e,n,r){return b.nodeName(e,"input")?(e.defaultValue=n,t):I&&I.set(e,n,r)}}),Q||(I=b.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},b.attrHooks.contenteditable={get:I.get,set:function(e,t,n){I.set(e,""===t?!1:t,n)}},b.each(["width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),b.support.hrefNormalized||(b.each(["href","src","width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),b.each(["href","src"],function(e,t){b.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),b.support.style||(b.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),b.support.optSelected||(b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),b.support.enctype||(b.propFix.enctype="encoding"),b.support.checkOn||b.each(["radio","checkbox"],function(){b.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),b.each(["radio","checkbox"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,n){return b.isArray(n)?e.checked=b.inArray(b(e).val(),n)>=0:t}})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}b.event={global:{},add:function(e,n,r,o,a){var s,u,l,c,p,f,d,h,g,m,y,v=b._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=b.guid++),(u=v.events)||(u=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(w)||[""],l=n.length;while(l--)s=rt.exec(n[l])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),p=b.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=b.event.special[g]||{},d=b.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&b.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=u[g])||(h=u[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),b.event.global[g]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,p,f,d,h,g,m=b.hasData(e)&&b._data(e);if(m&&(c=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(s=rt.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=b.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),u=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));u&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||b.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)b.event.remove(e,d+t[l],n,r,!0);b.isEmptyObject(c)&&(delete m.handle,b._removeData(e,"events"))}},trigger:function(n,r,i,a){var s,u,l,c,p,f,d,h=[i||o],g=y.call(n,"type")?n.type:n,m=y.call(n,"namespace")?n.namespace.split("."):[];if(l=f=i=i||o,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+b.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),u=0>g.indexOf(":")&&"on"+g,n=n[b.expando]?n:new b.Event(g,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:b.makeArray(r,[n]),p=b.event.special[g]||{},a||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!a&&!p.noBubble&&!b.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(l=l.parentNode);l;l=l.parentNode)h.push(l),f=l;f===(i.ownerDocument||o)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((l=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(b._data(l,"events")||{})[n.type]&&b._data(l,"handle"),s&&s.apply(l,r),s=u&&l[u],s&&b.acceptData(l)&&s.apply&&s.apply(l,r)===!1&&n.preventDefault();if(n.type=g,!(a||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||"click"===g&&b.nodeName(i,"a")||!b.acceptData(i)||!u||!i[g]||b.isWindow(i))){f=i[u],f&&(i[u]=null),b.event.triggered=g;try{i[g]()}catch(v){}b.event.triggered=t,f&&(i[u]=f)}return n.result}},dispatch:function(e){e=b.event.fix(e);var n,r,i,o,a,s=[],u=h.call(arguments),l=(b._data(this,"events")||{})[e.type]||[],c=b.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=b.event.handlers.call(this,e,l),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((b.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,u),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||"click"!==e.type))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==e.type)){for(o=[],a=0;u>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?b(r,this).index(l)>=0:b.find(r,this,null,[l]).length),o[r]&&o.push(i);o.length&&s.push({elem:l,handlers:o})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[b.expando])return e;var t,n,r,i=e.type,a=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new b.Event(a),t=r.length;while(t--)n=r[t],e[n]=a[n];return e.target||(e.target=a.srcElement||o),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,a,s=n.button,u=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||o,a=i.documentElement,r=i.body,e.pageX=n.clientX+(a&&a.scrollLeft||r&&r.scrollLeft||0)-(a&&a.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(a&&a.scrollTop||r&&r.scrollTop||0)-(a&&a.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&u&&(e.relatedTarget=u===e.target?n.toElement:u),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return b.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==o.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===o.activeElement&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=b.extend(new b.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?b.event.trigger(i,null,t):b.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},b.removeEvent=o.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},b.Event=function(e,n){return this instanceof b.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&b.extend(this,n),this.timeStamp=e&&e.timeStamp||b.now(),this[b.expando]=!0,t):new b.Event(e,n)},b.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},b.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){b.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj; 4 | return(!i||i!==r&&!b.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),b.support.submitBubbles||(b.event.special.submit={setup:function(){return b.nodeName(this,"form")?!1:(b.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=b.nodeName(n,"input")||b.nodeName(n,"button")?n.form:t;r&&!b._data(r,"submitBubbles")&&(b.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),b._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&b.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return b.nodeName(this,"form")?!1:(b.event.remove(this,"._submit"),t)}}),b.support.changeBubbles||(b.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(b.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),b.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),b.event.simulate("change",this,e,!0)})),!1):(b.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!b._data(t,"changeBubbles")&&(b.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||b.event.simulate("change",this.parentNode,e,!0)}),b._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return b.event.remove(this,"._change"),!Z.test(this.nodeName)}}),b.support.focusinBubbles||b.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){b.event.simulate(t,e.target,b.event.fix(e),!0)};b.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),b.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return b().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=b.guid++)),this.each(function(){b.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,b(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){b.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){b.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?b.event.trigger(e,n,r,!0):t}}),function(e,t){var n,r,i,o,a,s,u,l,c,p,f,d,h,g,m,y,v,x="sizzle"+-new Date,w=e.document,T={},N=0,C=0,k=it(),E=it(),S=it(),A=typeof t,j=1<<31,D=[],L=D.pop,H=D.push,q=D.slice,M=D.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},_="[\\x20\\t\\r\\n\\f]",F="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=F.replace("w","w#"),B="([*^$|!~]?=)",P="\\["+_+"*("+F+")"+_+"*(?:"+B+_+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+O+")|)|)"+_+"*\\]",R=":("+F+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+P.replace(3,8)+")*)|.*)\\)|)",W=RegExp("^"+_+"+|((?:^|[^\\\\])(?:\\\\.)*)"+_+"+$","g"),$=RegExp("^"+_+"*,"+_+"*"),I=RegExp("^"+_+"*([\\x20\\t\\r\\n\\f>+~])"+_+"*"),z=RegExp(R),X=RegExp("^"+O+"$"),U={ID:RegExp("^#("+F+")"),CLASS:RegExp("^\\.("+F+")"),NAME:RegExp("^\\[name=['\"]?("+F+")['\"]?\\]"),TAG:RegExp("^("+F.replace("w","w*")+")"),ATTR:RegExp("^"+P),PSEUDO:RegExp("^"+R),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+_+"*(even|odd|(([+-]|)(\\d*)n|)"+_+"*(?:([+-]|)"+_+"*(\\d+)|))"+_+"*\\)|)","i"),needsContext:RegExp("^"+_+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+_+"*((?:-\\d)?\\d*)"+_+"*\\)|)(?=[^-]|$)","i")},V=/[\x20\t\r\n\f]*[+~]/,Y=/^[^{]+\{\s*\[native code/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,G=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,K=/'|\\/g,Z=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,et=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,tt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{q.call(w.documentElement.childNodes,0)[0].nodeType}catch(nt){q=function(e){var t,n=[];while(t=this[e++])n.push(t);return n}}function rt(e){return Y.test(e+"")}function it(){var e,t=[];return e=function(n,r){return t.push(n+=" ")>i.cacheLength&&delete e[t.shift()],e[n]=r}}function ot(e){return e[x]=!0,e}function at(e){var t=p.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}}function st(e,t,n,r){var i,o,a,s,u,l,f,g,m,v;if((t?t.ownerDocument||t:w)!==p&&c(t),t=t||p,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!d&&!r){if(i=J.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&y(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return H.apply(n,q.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&T.getByClassName&&t.getElementsByClassName)return H.apply(n,q.call(t.getElementsByClassName(a),0)),n}if(T.qsa&&!h.test(e)){if(f=!0,g=x,m=t,v=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){l=ft(e),(f=t.getAttribute("id"))?g=f.replace(K,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=l.length;while(u--)l[u]=g+dt(l[u]);m=V.test(e)&&t.parentNode||t,v=l.join(",")}if(v)try{return H.apply(n,q.call(m.querySelectorAll(v),0)),n}catch(b){}finally{f||t.removeAttribute("id")}}}return wt(e.replace(W,"$1"),t,n,r)}a=st.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},c=st.setDocument=function(e){var n=e?e.ownerDocument||e:w;return n!==p&&9===n.nodeType&&n.documentElement?(p=n,f=n.documentElement,d=a(n),T.tagNameNoComments=at(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),T.attributes=at(function(e){e.innerHTML="";var t=typeof e.lastChild.getAttribute("multiple");return"boolean"!==t&&"string"!==t}),T.getByClassName=at(function(e){return e.innerHTML="",e.getElementsByClassName&&e.getElementsByClassName("e").length?(e.lastChild.className="e",2===e.getElementsByClassName("e").length):!1}),T.getByName=at(function(e){e.id=x+0,e.innerHTML="
    ",f.insertBefore(e,f.firstChild);var t=n.getElementsByName&&n.getElementsByName(x).length===2+n.getElementsByName(x+0).length;return T.getIdNotName=!n.getElementById(x),f.removeChild(e),t}),i.attrHandle=at(function(e){return e.innerHTML="",e.firstChild&&typeof e.firstChild.getAttribute!==A&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},T.getIdNotName?(i.find.ID=function(e,t){if(typeof t.getElementById!==A&&!d){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){return e.getAttribute("id")===t}}):(i.find.ID=function(e,n){if(typeof n.getElementById!==A&&!d){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==A&&r.getAttributeNode("id").value===e?[r]:t:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){var n=typeof e.getAttributeNode!==A&&e.getAttributeNode("id");return n&&n.value===t}}),i.find.TAG=T.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==A?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.NAME=T.getByName&&function(e,n){return typeof n.getElementsByName!==A?n.getElementsByName(name):t},i.find.CLASS=T.getByClassName&&function(e,n){return typeof n.getElementsByClassName===A||d?t:n.getElementsByClassName(e)},g=[],h=[":focus"],(T.qsa=rt(n.querySelectorAll))&&(at(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||h.push("\\["+_+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){e.innerHTML="",e.querySelectorAll("[i^='']").length&&h.push("[*^$]="+_+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(T.matchesSelector=rt(m=f.matchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){T.disconnectedMatch=m.call(e,"div"),m.call(e,"[s!='']:x"),g.push("!=",R)}),h=RegExp(h.join("|")),g=RegExp(g.join("|")),y=rt(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},v=f.compareDocumentPosition?function(e,t){var r;return e===t?(u=!0,0):(r=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&r||e.parentNode&&11===e.parentNode.nodeType?e===n||y(w,e)?-1:t===n||y(w,t)?1:0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return u=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:0;if(o===a)return ut(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?ut(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},u=!1,[0,0].sort(v),T.detectDuplicates=u,p):p},st.matches=function(e,t){return st(e,null,null,t)},st.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&c(e),t=t.replace(Z,"='$1']"),!(!T.matchesSelector||d||g&&g.test(t)||h.test(t)))try{var n=m.call(e,t);if(n||T.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return st(t,p,null,[e]).length>0},st.contains=function(e,t){return(e.ownerDocument||e)!==p&&c(e),y(e,t)},st.attr=function(e,t){var n;return(e.ownerDocument||e)!==p&&c(e),d||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):d||T.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},st.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},st.uniqueSort=function(e){var t,n=[],r=1,i=0;if(u=!T.detectDuplicates,e.sort(v),u){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e};function ut(e,t){var n=t&&e,r=n&&(~t.sourceIndex||j)-(~e.sourceIndex||j);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function lt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ct(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function pt(e){return ot(function(t){return t=+t,ot(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}o=st.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=st.selectors={cacheLength:50,createPseudo:ot,match:U,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,tt),e[3]=(e[4]||e[5]||"").replace(et,tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||st.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&st.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return U.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&z.test(n)&&(t=ft(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(et,tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[e+" "];return t||(t=RegExp("(^|"+_+")"+e+"("+_+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==A&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=st.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[x]||(m[x]={}),l=c[e]||[],d=l[0]===N&&l[1],f=l[0]===N&&l[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[N,d,f];break}}else if(v&&(l=(t[x]||(t[x]={}))[e])&&l[0]===N)f=l[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[x]||(p[x]={}))[e]=[N,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||st.error("unsupported pseudo: "+e);return r[x]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ot(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=M.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ot(function(e){var t=[],n=[],r=s(e.replace(W,"$1"));return r[x]?ot(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ot(function(e){return function(t){return st(e,t).length>0}}),contains:ot(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:ot(function(e){return X.test(e||"")||st.error("unsupported lang: "+e),e=e.replace(et,tt).toLowerCase(),function(t){var n;do if(n=d?t.getAttribute("xml:lang")||t.getAttribute("lang"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:pt(function(){return[0]}),last:pt(function(e,t){return[t-1]}),eq:pt(function(e,t,n){return[0>n?n+t:n]}),even:pt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:pt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:pt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:pt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[n]=lt(n);for(n in{submit:!0,reset:!0})i.pseudos[n]=ct(n);function ft(e,t){var n,r,o,a,s,u,l,c=E[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=i.preFilter;while(s){(!n||(r=$.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(o=[])),n=!1,(r=I.exec(s))&&(n=r.shift(),o.push({value:n,type:r[0].replace(W," ")}),s=s.slice(n.length));for(a in i.filter)!(r=U[a].exec(s))||l[a]&&!(r=l[a](r))||(n=r.shift(),o.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?st.error(e):E(e,u).slice(0)}function dt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function ht(e,t,n){var i=t.dir,o=n&&"parentNode"===i,a=C++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,s){var u,l,c,p=N+" "+a;if(s){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[x]||(t[x]={}),(l=c[i])&&l[0]===p){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[p],l[1]=e(t,n,s)||r,l[1]===!0)return!0}}function gt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function mt(e,t,n,r,i){var o,a=[],s=0,u=e.length,l=null!=t;for(;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function yt(e,t,n,r,i,o){return r&&!r[x]&&(r=yt(r)),i&&!i[x]&&(i=yt(i,o)),ot(function(o,a,s,u){var l,c,p,f=[],d=[],h=a.length,g=o||xt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:mt(g,f,e,s,u),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,u),r){l=mt(y,d),r(l,[],s,u),c=l.length;while(c--)(p=l[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(p=y[c])&&l.push(m[c]=p);i(null,y=[],l,u)}c=y.length;while(c--)(p=y[c])&&(l=i?M.call(o,p):f[c])>-1&&(o[l]=!(a[l]=p))}}else y=mt(y===a?y.splice(h,y.length):y),i?i(null,a,y,u):H.apply(a,y)})}function vt(e){var t,n,r,o=e.length,a=i.relative[e[0].type],s=a||i.relative[" "],u=a?1:0,c=ht(function(e){return e===t},s,!0),p=ht(function(e){return M.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;o>u;u++)if(n=i.relative[e[u].type])f=[ht(gt(f),n)];else{if(n=i.filter[e[u].type].apply(null,e[u].matches),n[x]){for(r=++u;o>r;r++)if(i.relative[e[r].type])break;return yt(u>1&>(f),u>1&&dt(e.slice(0,u-1)).replace(W,"$1"),n,r>u&&vt(e.slice(u,r)),o>r&&vt(e=e.slice(r)),o>r&&dt(e))}f.push(n)}return gt(f)}function bt(e,t){var n=0,o=t.length>0,a=e.length>0,s=function(s,u,c,f,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,T=l,C=s||a&&i.find.TAG("*",d&&u.parentNode||u),k=N+=null==T?1:Math.random()||.1;for(w&&(l=u!==p&&u,r=n);null!=(h=C[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,u,c)){f.push(h);break}w&&(N=k,r=++n)}o&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,o&&b!==v){g=0;while(m=t[g++])m(x,y,u,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=L.call(f));y=mt(y)}H.apply(f,y),w&&!s&&y.length>0&&v+t.length>1&&st.uniqueSort(f)}return w&&(N=k,l=T),x};return o?ot(s):s}s=st.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=ft(e)),n=t.length;while(n--)o=vt(t[n]),o[x]?r.push(o):i.push(o);o=S(e,bt(i,r))}return o};function xt(e,t,n){var r=0,i=t.length;for(;i>r;r++)st(e,t[r],n);return n}function wt(e,t,n,r){var o,a,u,l,c,p=ft(e);if(!r&&1===p.length){if(a=p[0]=p[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&!d&&i.relative[a[1].type]){if(t=i.find.ID(u.matches[0].replace(et,tt),t)[0],!t)return n;e=e.slice(a.shift().value.length)}o=U.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],i.relative[l=u.type])break;if((c=i.find[l])&&(r=c(u.matches[0].replace(et,tt),V.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=r.length&&dt(a),!e)return H.apply(n,q.call(r,0)),n;break}}}return s(e,p)(r,t,d,n,V.test(e)),n}i.pseudos.nth=i.pseudos.eq;function Tt(){}i.filters=Tt.prototype=i.pseudos,i.setFilters=new Tt,c(),st.attr=b.attr,b.find=st,b.expr=st.selectors,b.expr[":"]=b.expr.pseudos,b.unique=st.uniqueSort,b.text=st.getText,b.isXMLDoc=st.isXML,b.contains=st.contains}(e);var at=/Until$/,st=/^(?:parents|prev(?:Until|All))/,ut=/^.[^:#\[\.,]*$/,lt=b.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return r=this,this.pushStack(b(e).filter(function(){for(t=0;i>t;t++)if(b.contains(r[t],this))return!0}));for(n=[],t=0;i>t;t++)b.find(e,this[t],n);return n=this.pushStack(i>1?b.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t,n=b(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(b.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1))},filter:function(e){return this.pushStack(ft(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?lt.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],a=lt.test(e)||"string"!=typeof e?b(e,t||this.context):0;for(;i>r;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&11!==n.nodeType){if(a?a.index(n)>-1:b.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}}return this.pushStack(o.length>1?b.unique(o):o)},index:function(e){return e?"string"==typeof e?b.inArray(this[0],b(e)):b.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?b(e,t):b.makeArray(e&&e.nodeType?[e]:e),r=b.merge(this.get(),n);return this.pushStack(b.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),b.fn.andSelf=b.fn.addBack;function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}b.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(e,t,n){return b.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(e,t,n){return b.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return b.dir(e,"previousSibling",n)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.merge([],e.childNodes)}},function(e,t){b.fn[e]=function(n,r){var i=b.map(this,t,n);return at.test(e)||(r=n),r&&"string"==typeof r&&(i=b.filter(r,i)),i=this.length>1&&!ct[e]?b.unique(i):i,this.length>1&&st.test(e)&&(i=i.reverse()),this.pushStack(i)}}),b.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?b.find.matchesSelector(t[0],e)?[t[0]]:[]:b.find.matches(e,t)},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!b(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(t=t||0,b.isFunction(t))return b.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return b.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=b.grep(e,function(e){return 1===e.nodeType});if(ut.test(t))return b.filter(t,r,!n);t=b.filter(t,r)}return b.grep(e,function(e){return b.inArray(e,t)>=0===n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,At={option:[1,""],legend:[1,"
    ","
    "],area:[1,"",""],param:[1,"",""],thead:[1,"","
    "],tr:[2,"","
    "],col:[2,"","
    "],td:[3,"","
    "],_default:b.support.htmlSerialize?[0,"",""]:[1,"X
    ","
    "]},jt=dt(o),Dt=jt.appendChild(o.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,b.fn.extend({text:function(e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e))return this.each(function(t){b(this).wrapAll(e.call(this,t))});if(this[0]){var t=b(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return b.isFunction(e)?this.each(function(t){b(this).wrapInner(e.call(this,t))}):this.each(function(){var t=b(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=b.isFunction(e);return this.each(function(n){b(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){b.nodeName(this,"body")||b(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=0;for(;null!=(n=this[r]);r++)(!e||b.filter(e,[n]).length>0)&&(t||1!==n.nodeType||b.cleanData(Ot(n)),n.parentNode&&(t&&b.contains(n.ownerDocument,n)&&Mt(Ot(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&b.cleanData(Ot(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&b.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return b.clone(this,e,t)})},html:function(e){return b.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!b.support.htmlSerialize&&mt.test(e)||!b.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(b.cleanData(Ot(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=b.isFunction(e);return t||"string"==typeof e||(e=b(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;n&&(b(this).remove(),n.insertBefore(e,t))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=f.apply([],e);var i,o,a,s,u,l,c=0,p=this.length,d=this,h=p-1,g=e[0],m=b.isFunction(g);if(m||!(1>=p||"string"!=typeof g||b.support.checkClone)&&Ct.test(g))return this.each(function(i){var o=d.eq(i);m&&(e[0]=g.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(p&&(l=b.buildFragment(e,this[0].ownerDocument,!1,this),i=l.firstChild,1===l.childNodes.length&&(l=i),i)){for(n=n&&b.nodeName(i,"tr"),s=b.map(Ot(l,"script"),Ht),a=s.length;p>c;c++)o=l,c!==h&&(o=b.clone(o,!0,!0),a&&b.merge(s,Ot(o,"script"))),r.call(n&&b.nodeName(this[c],"table")?Lt(this[c],"tbody"):this[c],o,c);if(a)for(u=s[s.length-1].ownerDocument,b.map(s,qt),c=0;a>c;c++)o=s[c],kt.test(o.type||"")&&!b._data(o,"globalEval")&&b.contains(u,o)&&(o.src?b.ajax({url:o.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):b.globalEval((o.text||o.textContent||o.innerHTML||"").replace(St,"")));l=i=null}return this}});function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function Ht(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function Mt(e,t){var n,r=0;for(;null!=(n=e[r]);r++)b._data(n,"globalEval",!t||b._data(t[r],"globalEval"))}function _t(e,t){if(1===t.nodeType&&b.hasData(e)){var n,r,i,o=b._data(e),a=b._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)b.event.add(t,n,s[n][r])}a.data&&(a.data=b.extend({},a.data))}}function Ft(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!b.support.noCloneEvent&&t[b.expando]){i=b._data(t);for(r in i.events)b.removeEvent(t,r,i.handle);t.removeAttribute(b.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),b.support.html5Clone&&e.innerHTML&&!b.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Nt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){b.fn[e]=function(e){var n,r=0,i=[],o=b(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),b(o[r])[t](n),d.apply(i,n.get());return this.pushStack(i)}});function Ot(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||b.nodeName(o,n)?s.push(o):b.merge(s,Ot(o,n));return n===t||n&&b.nodeName(e,n)?b.merge([e],s):s}function Bt(e){Nt.test(e.type)&&(e.defaultChecked=e.checked)}b.extend({clone:function(e,t,n){var r,i,o,a,s,u=b.contains(e.ownerDocument,e);if(b.support.html5Clone||b.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(b.support.noCloneEvent&&b.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||b.isXMLDoc(e)))for(r=Ot(o),s=Ot(e),a=0;null!=(i=s[a]);++a)r[a]&&Ft(i,r[a]);if(t)if(n)for(s=s||Ot(e),r=r||Ot(o),a=0;null!=(i=s[a]);a++)_t(i,r[a]);else _t(e,o);return r=Ot(o,"script"),r.length>0&&Mt(r,!u&&Ot(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,u,l,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===b.type(o))b.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),u=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[u]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!b.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!b.support.tbody){o="table"!==u||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)b.nodeName(l=o.childNodes[i],"tbody")&&!l.childNodes.length&&o.removeChild(l) 5 | }b.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),b.support.appendChecked||b.grep(Ot(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===b.inArray(o,r))&&(a=b.contains(o.ownerDocument,o),s=Ot(f.appendChild(o),"script"),a&&Mt(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,u=b.expando,l=b.cache,p=b.support.deleteExpando,f=b.event.special;for(;null!=(n=e[s]);s++)if((t||b.acceptData(n))&&(o=n[u],a=o&&l[o])){if(a.events)for(r in a.events)f[r]?b.event.remove(n,r):b.removeEvent(n,r,a.handle);l[o]&&(delete l[o],p?delete n[u]:typeof n.removeAttribute!==i?n.removeAttribute(u):n[u]=null,c.push(o))}}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+x+")(.*)$","i"),Yt=RegExp("^("+x+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+x+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===b.css(e,"display")||!b.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=b._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=b._data(r,"olddisplay",un(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&b._data(r,"olddisplay",i?n:b.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}b.fn.extend({css:function(e,n){return b.access(this,function(e,n,r){var i,o,a={},s=0;if(b.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=b.css(e,n[s],!1,o);return a}return r!==t?b.style(e,n,r):b.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:nn(this))?b(this).show():b(this).hide()})}}),b.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":b.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=b.camelCase(n),l=e.style;if(n=b.cssProps[u]||(b.cssProps[u]=tn(l,u)),s=b.cssHooks[n]||b.cssHooks[u],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:l[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(b.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||b.cssNumber[u]||(r+="px"),b.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(l[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{l[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,u=b.camelCase(n);return n=b.cssProps[u]||(b.cssProps[u]=tn(e.style,u)),s=b.cssHooks[n]||b.cssHooks[u],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||b.isNumeric(o)?o||0:a):a},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s.getPropertyValue(n)||s[n]:t,l=e.style;return s&&(""!==u||b.contains(e.ownerDocument,e)||(u=b.style(e,n)),Yt.test(u)&&Ut.test(n)&&(i=l.width,o=l.minWidth,a=l.maxWidth,l.minWidth=l.maxWidth=l.width=u,u=s.width,l.width=i,l.minWidth=o,l.maxWidth=a)),u}):o.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s[n]:t,l=e.style;return null==u&&l&&l[n]&&(u=l[n]),Yt.test(u)&&!zt.test(n)&&(i=l.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),l.left="fontSize"===n?"1em":u,u=l.pixelLeft+"px",l.left=i,a&&(o.left=a)),""===u?"auto":u});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=b.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=b.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=b.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=b.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=b.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=b.support.boxSizing&&"border-box"===b.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(b.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function un(e){var t=o,n=Gt[e];return n||(n=ln(e,t),"none"!==n&&n||(Pt=(Pt||b("