|
1 /* clearTimeOut Keeps the Menu Open */ |
|
2 $clearTimeOut = 0; |
|
3 // Keep the Menu Open if we're highlighting a sub-menu item |
|
4 function keep_open() |
|
5 {$clearTimeOut = 0;} |
|
6 // Begin the closing procedure with a countdown |
|
7 function close_menu($id) |
|
8 { |
|
9 $clearTimeOut = 1; |
|
10 $temp_timeout = setTimeout("close_menu_final('"+$id+"');", 250); |
|
11 } |
|
12 // Do the final menu clearing |
|
13 function close_menu_final($id) |
|
14 { |
|
15 // Check whether or not we've scrolled over a menu item |
|
16 if($clearTimeOut == 1 && ($id.indexOf("sub-menu-") > -1 || $id.indexOf("sub-page-menu-") > -1)) |
|
17 { |
|
18 $use_id = "#"+$id; |
|
19 $($use_id).slideUp({duration: 250}); |
|
20 } |
|
21 } |
|
22 function switch_slides($current_id, $next_id) |
|
23 { |
|
24 $old_post_id = $current_id.replace("image-", "post-"); |
|
25 $new_post_id = $next_id.replace("image-", "post-"); |
|
26 |
|
27 $($current_id).fadeOut("fast"); |
|
28 $($next_id).addClass("floatleft"); |
|
29 $($old_post_id).slideUp("slow"); |
|
30 |
|
31 setTimeout( |
|
32 function() |
|
33 { |
|
34 $($next_id).fadeIn("slow"); |
|
35 $($new_post_id).slideDown("slow").addClass("feature-post-content").addClass("clearfix"); |
|
36 $.busy = 0; |
|
37 } |
|
38 ,100); |
|
39 } |
|
40 |
|
41 $(document).ready(function() |
|
42 { |
|
43 /***********************************************/ |
|
44 /* All functions for the featured posts Widget */ |
|
45 $.current_selected = $("#first_selected").html(); |
|
46 $("[id^='ocmx-featured-href-']").click(function() |
|
47 { |
|
48 $use_id = $(this).attr("id").replace("ocmx-featured-href-", ""); |
|
49 |
|
50 $old_header = "#feature-post-header-"+$.current_selected; |
|
51 $old_media = "#feature-post-media-"+$.current_selected; |
|
52 $header_id = "#feature-post-header-"+$use_id; |
|
53 $media_id = "#feature-post-media-"+$use_id; |
|
54 |
|
55 $("#feature-media-container").slideUp("slow"); |
|
56 $($media_id+" > object").addClass("no_display"); |
|
57 |
|
58 /* Clear old header */ |
|
59 $($old_header).addClass("no_display"); |
|
60 $($header_id).removeClass("no_display"); |
|
61 |
|
62 /* Hide old Media*/ |
|
63 $($old_media).slideUp("slow"); |
|
64 $($old_media+" object").addClass("no_display"); |
|
65 |
|
66 setTimeout(function() |
|
67 { |
|
68 $("#feature-media-container").slideDown("fast"); |
|
69 setTimeout(function() |
|
70 { |
|
71 $($media_id).slideDown("slow"); |
|
72 $($media_id+" > object").removeClass("no_display"); |
|
73 } |
|
74 ,1000); |
|
75 } |
|
76 ,150); |
|
77 $.current_selected = $use_id; |
|
78 return false; |
|
79 }); |
|
80 $.current_month = 1; |
|
81 $("a[id^='archive-href-']").click(function() |
|
82 { |
|
83 $use_id = $(this).attr("id").replace("archive-href-", ""); |
|
84 |
|
85 $old_detail = "#archive-detail-"+$.current_month; |
|
86 $new_detail = "#archive-detail-"+$use_id; |
|
87 |
|
88 /* Hide old Media*/ |
|
89 $($old_detail).slideUp("slow"); |
|
90 $($new_detail).slideDown("slow"); |
|
91 |
|
92 $.current_month = $use_id; |
|
93 return false; |
|
94 }); |
|
95 |
|
96 /********/ |
|
97 /* Menu */ |
|
98 $.open_menu = 0; |
|
99 $("a[id^='main-menu-item-']").mouseover(function(){ |
|
100 // Start the timeout to keep the menu open |
|
101 keep_open() |
|
102 // Create the id to ref the submenu |
|
103 $sub_menu_id = $(this).attr("id").replace("main-menu-item-", ""); |
|
104 $id = "sub-menu-"+$sub_menu_id; |
|
105 if(document.getElementById($id)) |
|
106 { |
|
107 $new_sub_menu = "#"+$id; |
|
108 |
|
109 if($.open_menu !== $new_sub_menu) |
|
110 {$(".sub-menu-container").slideUp("fast");} |
|
111 |
|
112 // fade in the submenu |
|
113 $($new_sub_menu).addClass("container").slideDown({duration: 100}); |
|
114 $.open_menu = $new_sub_menu; |
|
115 } |
|
116 }); |
|
117 |
|
118 $("a[id^='main-menu-page-item-']").mouseover(function(){ |
|
119 // Start the timeout to keep the menu open |
|
120 keep_open() |
|
121 // Create the id to ref the submenu |
|
122 $sub_menu_id = $(this).attr("id").replace("main-menu-page-item-", ""); |
|
123 $id = "sub-page-menu-"+$sub_menu_id; |
|
124 if(document.getElementById($id)) |
|
125 { |
|
126 $new_sub_menu = "#"+$id; |
|
127 |
|
128 if($.open_menu !== $new_sub_menu) |
|
129 {$(".sub-menu-container").slideUp("fast");} |
|
130 // fade in the submenu |
|
131 $($new_sub_menu).addClass("container").slideDown("2000"); |
|
132 $.open_menu = $new_sub_menu; |
|
133 } |
|
134 }); |
|
135 |
|
136 $("[id^='sub-menu-'], [id^='sub-page-menu-']").mouseover(function(){ |
|
137 // Start the timeout to keep the menu open |
|
138 keep_open() |
|
139 }); |
|
140 $("[id^='sub-menu-'], [id^='main-menu-item-'], [id^='sub-page-menu-'], [id^='main-menu-page-item-']").mouseout(function(){ |
|
141 // Create the id to ref the submenu |
|
142 $sub_menu_id = $(this).attr("id"); |
|
143 if($sub_menu_id.indexOf("main-menu-item-") > -1) |
|
144 {$sub_menu_id = $sub_menu_id.replace("main-menu-item-", "sub-menu-");} |
|
145 else if($sub_menu_id.indexOf("main-menu-page-item-") > -1) |
|
146 {$sub_menu_id = $sub_menu_id.replace("main-menu-page-item-", "sub-page-menu-");} |
|
147 // Start the cloding process |
|
148 close_menu($sub_menu_id); |
|
149 }); |
|
150 /********************/ |
|
151 /* Ajax Comments */ |
|
152 $("#commentform").submit(function(){return false;}); |
|
153 |
|
154 $("#comments-link").click(function(){ |
|
155 $("html").animate({scrollTop: $("#comments").offset().top}, 1000); |
|
156 return false; |
|
157 }); |
|
158 $("#comment_submit").live("click", function(){ |
|
159 // Compile the request location |
|
160 $post_page = $("#template-directory").html()+"/functions/ocmx_comment_post.php"; |
|
161 // Compile all the request details |
|
162 $author = $("#author").attr("value"); |
|
163 $email = $("#email").attr("value"); |
|
164 $url = $("#url").attr("value"); |
|
165 $comment = $("#comment").attr("value"); |
|
166 $twitter = $("#twitter").attr("value"); |
|
167 $email_subscribe = $("#email_subscribe").attr("checked"); |
|
168 $post_id = $("#comment_post_id").attr("value"); |
|
169 $comment_parent_id = $("#comment_parent_id").attr("value"); |
|
170 |
|
171 // Set which area the new comment will end up in |
|
172 if($comment_parent_id !== "0" && $comment_parent_id !== "") |
|
173 {$new_comments_id = "#new-reply-"+$comment_parent_id;} |
|
174 else |
|
175 {$new_comments_id = "#new_comments";} |
|
176 |
|
177 // Fade out the new comment div so that we can fade it in after posting our new comment |
|
178 //$($new_comments_id).fadeOut("fast"); |
|
179 $("#commment-post-alert").fadeIn("slow"); |
|
180 // Perform the "Magic" which is just a bit of Ajax |
|
181 $.post($post_page, { author: $author, email: $email, url: $url, twitter: $twitter, email_subscribe: $email_subscribe, comment: $comment, comment_post_id: $post_id, comment_parent: $comment_parent_id}, |
|
182 function(data) { |
|
183 if($.browser.msie) |
|
184 {location.reload();} |
|
185 else |
|
186 {$($new_comments_id).html($($new_comments_id).html()+" "+data).fadeIn("slow");} |
|
187 $("#commment-post-alert").fadeOut("fast"); |
|
188 $("#comment").attr("value", ""); |
|
189 }); |
|
190 return false; |
|
191 }); |
|
192 |
|
193 $("a[id^='reply-']").live("click", function(){ |
|
194 // Create the Comment Id and apply it to the comment form |
|
195 $comment_id = $(this).attr("id").replace("reply-", ""); |
|
196 |
|
197 // Set which href we're dealing with |
|
198 |
|
199 if($.href_id) |
|
200 { |
|
201 $oldhref = $.href_id; |
|
202 $($oldhref).html("Reply"); |
|
203 } |
|
204 $.href_id = "#reply-"+$comment_id; |
|
205 |
|
206 //Set where exactly the comment form will end up |
|
207 $new_location_id = "#form-placement-"+$comment_id; |
|
208 |
|
209 //Create the Id for the new placement of the comment Form and put it there |
|
210 if($($new_location_id).html().toString().indexOf("Leave") == -1) |
|
211 { |
|
212 $("#comment_form_container").remove().appendTo($new_location_id); |
|
213 $($new_location_id).fadeIn("slow"); |
|
214 $("#comment_parent_id").attr("value", $comment_id); |
|
215 // Change href to Cancel |
|
216 $($.href_id).html("Cancel"); |
|
217 } |
|
218 else |
|
219 { |
|
220 $($new_location_id).fadeOut("fast"); |
|
221 $("#comment_form_container").remove().appendTo("#original_comment_location"); |
|
222 $("#comment_parent_id").attr("value", "0"); |
|
223 // Change href back to Reply |
|
224 $($.href_id).html("Reply"); |
|
225 } |
|
226 setTimeout(function(){$("html").animate({scrollTop: $(".comment-form-content").offset().top}, 1000);}, 500); |
|
227 return false; |
|
228 }); |
|
229 $("#contact_form").submit(function(){ |
|
230 $err = ""; |
|
231 var theForm = document.getElementById("contact_form"); |
|
232 var e_value = $("#contact_email").attr("value"); |
|
233 |
|
234 if ($("#contact_name").attr("value") == "" || $("#contact_name").attr("value") == "Name") |
|
235 {$err = $err + "\n - Enter your name.";} |
|
236 if(e_value !== "Email Address" && e_value !== "" && e_value.indexOf("@") !== -1 && e_value.indexOf("@.") == -1 && e_value.indexOf("@@") == -1 && ( e_value.indexOf(",") == -1 && e_value.indexOf("/") == -1 && e_value.indexOf("'") == -1 && e_value.indexOf("&") == -1 && e_value.indexOf("%") == -1 )) |
|
237 {} |
|
238 else |
|
239 {$err = $err + "\n - Enter a valid e-mail address.";} |
|
240 if ($("#contact_subject").attr("value") == "" || $("#contact_subject").attr("value") == "Subject") |
|
241 {$err = $err + "\n - Enter a subject title for your message.";} |
|
242 if ($("#contact_message").attr("value") == "" || $("#contact_message").attr("value") == "Your Message") |
|
243 {$err = $err + "\n - Enter a message.";} |
|
244 |
|
245 if($err !== "") |
|
246 { |
|
247 $err = "Please correct the following: \n" + $err; |
|
248 alert($err); |
|
249 return false |
|
250 } |
|
251 else |
|
252 {return true;} |
|
253 }); |
|
254 /**********************/ |
|
255 /* Search Form Clearer */ |
|
256 $search_criteria_id = "search_criteria"; |
|
257 $("#"+$search_criteria_id).focus(function(){ |
|
258 if($("#"+$search_criteria_id).attr("value") == "Search...") |
|
259 {$("#"+$search_criteria_id).attr("value", "");} |
|
260 }); |
|
261 |
|
262 $("#"+$search_criteria_id).blur(function(){ |
|
263 if($("#"+$search_criteria_id).attr("value") == "") |
|
264 {$("#"+$search_criteria_id).attr("value", "Search...");} |
|
265 }); |
|
266 |
|
267 /************************/ |
|
268 /* Contact Form Clearer */ |
|
269 $contact_name_id = "contact_name"; |
|
270 $("#"+$contact_name_id).focus(function(){ |
|
271 if($("#"+$contact_name_id).attr("value") == "Name") |
|
272 {$("#"+$contact_name_id).attr("value", "");} |
|
273 }); |
|
274 |
|
275 $("#"+$contact_name_id).blur(function(){ |
|
276 if($("#"+$contact_name_id).attr("value") == "") |
|
277 {$("#"+$contact_name_id).attr("value", "Name");} |
|
278 }); |
|
279 |
|
280 $contact_email_id = "contact_email"; |
|
281 $("#"+$contact_email_id).focus(function(){ |
|
282 if($("#"+$contact_email_id).attr("value") == "Email Address") |
|
283 {$("#"+$contact_email_id).attr("value", "");} |
|
284 }); |
|
285 |
|
286 $("#"+$contact_email_id).blur(function(){ |
|
287 if($("#"+$contact_email_id).attr("value") == "") |
|
288 {$("#"+$contact_email_id).attr("value", "Email Address");} |
|
289 }); |
|
290 |
|
291 $contact_subject_id = "contact_subject"; |
|
292 $("#"+$contact_subject_id).focus(function(){ |
|
293 if($("#"+$contact_subject_id).attr("value") == "Subject") |
|
294 {$("#"+$contact_subject_id).attr("value", "");} |
|
295 }); |
|
296 |
|
297 $("#"+$contact_subject_id).blur(function(){ |
|
298 if($("#"+$contact_subject_id).attr("value") == "") |
|
299 {$("#"+$contact_subject_id).attr("value", "Subject");} |
|
300 }); |
|
301 $contact_message_id = "contact_message"; |
|
302 $("#"+$contact_message_id).focus(function(){ |
|
303 if($("#"+$contact_message_id).attr("value") == "Your Message") |
|
304 {$("#"+$contact_message_id).attr("value", "");} |
|
305 }); |
|
306 |
|
307 $("#"+$contact_message_id).blur(function(){ |
|
308 if($("#"+$contact_message_id).attr("value") == "") |
|
309 {$("#"+$contact_message_id).attr("value", "Your Message");} |
|
310 }); |
|
311 |
|
312 /*************************/ |
|
313 /* Comments Form Clearer */ |
|
314 $search_id = "s"; |
|
315 $("#"+$search_id).focus(function(){ |
|
316 if($("#"+$search_id).attr("value") == "Search...") |
|
317 {$("#"+$search_id).attr("value", "");} |
|
318 }); |
|
319 |
|
320 $("#"+$search_id).blur(function(){ |
|
321 if($("#"+$search_id).attr("value") == "") |
|
322 {$("#"+$search_id).attr("value", "Search...");} |
|
323 }); |
|
324 |
|
325 /*************************/ |
|
326 /* Comments Form Clearer */ |
|
327 $author_id = "author"; |
|
328 $("#"+$author_id).focus(function(){ |
|
329 if($("#"+$author_id).attr("value") == "Name") |
|
330 {$("#"+$author_id).attr("value", "");} |
|
331 }); |
|
332 |
|
333 $("#"+$author_id).blur(function(){ |
|
334 if($("#"+$author_id).attr("value") == "") |
|
335 {$("#"+$author_id).attr("value", "Name");} |
|
336 }); |
|
337 |
|
338 $email_id = "email"; |
|
339 $("#"+$email_id).focus(function(){ |
|
340 if($("#"+$email_id).attr("value") == "EMail Address") |
|
341 {$("#"+$email_id).attr("value", "");} |
|
342 }); |
|
343 |
|
344 $("#"+$email_id).blur(function(){ |
|
345 if($("#"+$email_id).attr("value") == "") |
|
346 {$("#"+$email_id).attr("value", "EMail Address");} |
|
347 }); |
|
348 |
|
349 $url_id = "url"; |
|
350 $("#"+$url_id).focus(function(){ |
|
351 if($("#"+$url_id).attr("value") == "Website URL") |
|
352 {$("#"+$url_id).attr("value", "");} |
|
353 }); |
|
354 $("#"+$url_id).blur(function(){ |
|
355 if($("#"+$url_id).attr("value") == "") |
|
356 {$("#"+$url_id).attr("value", "Website URL");} |
|
357 }); |
|
358 |
|
359 $twitter_id = "twitter"; |
|
360 $("#"+$twitter_id).focus(function(){ |
|
361 if($("#"+$twitter_id).attr("value") == "Twitter Name") |
|
362 {$("#"+$twitter_id).attr("value", "");} |
|
363 }); |
|
364 $("#"+$twitter_id).live("blur", function(){ |
|
365 if($("#"+$twitter_id).attr("value") == "") |
|
366 {$("#"+$twitter_id).attr("value", "Twitter Name");} |
|
367 }); |
|
368 }); |