//Common Declarations
//DD_roundies.addRule('.rounded', '10px');

$(document).ready(function() {
	initialize();
});

function initialize() {
	showLoginLink();
	nthChildSelectorUtility();
	setupFilters();
	correctFloats();
	tickerSWF();
	
	$('.pagination li a.previous, .pagination li a.next').click(function() {
	    if ($(this).attr('href') == "#") {
		return false;
	    }
	});
};

sfHover = function() {
	var sfEls = document.getElementById("global-nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" hover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" hover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function correctFloats() {
	
	var max_height = 0;
	$('#featured-item-list ul li, #program-list ul li, #dvd-list ul li').each(function() {
		var height = $(this).height();
		if (height > max_height){
			max_height = height;
		}
	});
	
	$('#featured-item-list ul li, #program-list ul li, #dvd-list ul li').each(function() {
		$(this).height(max_height);
	});
}

function setupFilters() {
	
	if ($('#select-filter').length != 0){
		$('#select-filter').change(appendQueryParameters);
		$('#select-filter optgroup').each(function() {
			var key = $(this).attr('id');
			var value = getQuerystring(key);
			
			if (value != ''){
				$('#select-filter').attr('value', value);
			}
		});
	}
	
	var value = getQuerystring('index');
	$('#filter ul li a, #item-filter ul li a').each(function () {
		if (value != '' && $(this).text() == value){
			$(this).addClass('selected');
		}
	});

	
	if ($('#business-unit-list').length != 0){
		var current_business_unit = (window.location.pathname).split('/', 2).pop();
		if(current_business_unit != ""){
			$('#business-unit-list ul li a').filter('[href$='+current_business_unit+'/]').addClass('active');
		}
	}
	
	if ($('#global-nav').length != 0){
		var current_page = (window.location.pathname).split('/').pop();
		if(current_page !=""){
			$('#global-nav ul li a').filter('[href$=/'+current_page+']').addClass('active');
		}
		else {
			$('#global-nav ul li a').filter('[href$=/index.jsp]').addClass('active');
		}
	}
};

// append query parameters to URL
function appendQueryParameters() {
        var option = $(this).find('option:selected');
	  
        // if the option element is the child of an optgroup, set querystring parameters
        if (option.parent('optgroup').length != 0){
		var key = $(this).find('option:selected').parent('optgroup').attr("id");
		var value = $(this).val();
		var url = '?' + key + '=' + value;
		
		var path = '';
		
		switch(self.location.pathname){
			case '/bio.jsp':
				self.location = self.location.protocol + '//' + self.location.host + '/browse-bios.jsp' + url;
				break;
			case '/press-release.jsp':
				self.location = self.location.protocol + '//' + self.location.host + '/browse-press-releases.jsp' + url;
				break;
			default:
				self.location = url;
				break;
		}
        }
	// otherwise, remove querystring parameters and return to default page
        else {
		self.location = self.location.protocol + '//' + self.location.host + self.location.pathname;
        }
}

// sets classes for first-child and last-child LI items
function nthChildSelectorUtility() {
	$('.object-nav ul li:first-child').addClass('first');
	$('.object-nav ul li:last-child').addClass('last');
};

//Login Modal
function loginModal() { 
	$('.login-modal').overlay({ 
		top: '15%', 
		expose: { 
			color: '#333', 
			loadSpeed: 200, 
			opacity: 0.9 
		},
		onBeforeLoad: function() { 
			loginForm();
			
        },
		onLoad: function() {
			toggleSelect();
			$('.close').click(function() {
				$('.login-modal').overlay().close();
				return false;
			})
		},
		onClose: function() {
			toggleSelect();
			$('#login').show();
			$('#forgotpassword').hide();
		},
		api: true
	});
};

//Cookie Functions
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires=';expires='+date.toGMTString();}else{var expires='';}document.cookie=name+'='+value+expires+';path=/';};
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}return null;};
function eraseCookie(name){createCookie(name,"",-1);};

function noCache(){return Math.random(0, 1000)+'='+Math.random(0,1000);};

//Site User Functions
var standardLoginLinks =	'<ul>' +
								'<li><a href="/register.jsp">Register</a> |</li>' +
								'<li><a href="#" class="login-modal" rel="#login-modal">Login</a>' +
							'</ul>';
var loggedInLoginLinks =	'<ul>' +
								'<li>Welcome, <a href="/profile.jsp">displayname</a> |</li>' +
								'<li><a href="#" onclick="logout();return false;">Log Out</a></li>' +
							'</ul>';

function showLoginLink() {
	if(isLoggedIn()==true) {
		var str = readCookie('userId').split('|')[0];
		var displayname = str.replace(/\b(\w)/g,
			function (w, p1) { return p1.toUpperCase(); }) //Capitalizes first letter of each word.
		$('#login_links').html(loggedInLoginLinks.replace('displayname',displayname));
	} else {
		$('#login_links').html(standardLoginLinks);
		loginModal();
	}
};

function login(name, id) {
	var userId = name + '|' + id;
	createCookie('userId',userId,30);
};
function logout() {
	eraseCookie('userId');
	showLoginLink();
	if(window.location.href.indexOf('/profile.jsp')>-1) {
		window.location = '/';
	}
};
function isLoggedIn() { 
	if(readCookie('userId')) { return true; }
	return false;
};

function download(assetURI) {
	if(isLoggedIn()) {
		window.open(assetURI);
		return false;
	} else {
		$('.login-modal').overlay().load();
	};
};


//Login Form
function loginForm() {
	$.get('/ajax/html/login.html', function(data) {
		$('#modal-dialog').html(data);
		$('#login_email').focus();
		$('#forgotpassword-link').click(function() {
			$('#login').hide();
			$('#forgotpassword').show();
			forgotPasswordForm();
			return false;
		});
		 
		$('#loginForm').validate({
			meta: 'validate',
			messages: {
				login_email: {
					required: 'Please enter your email address.',
					email: 'Please enter a valid email address (you@example.com).'
				},
				login_password: 'Please enter your password.'
			},
			errorElement: 'em',
			errorLabelContainer: '#login-error',
			wrapper: 'li',
			submitHandler: function() {	
				var email = $('input#login_email').val();
				var password = $('input#login_password').val();
				var dataString = 'email='+ email + '&password=' + password;
				//alert(dataString);
				$.ajax({
					type: 'POST',
					url: '/ajax/service.jsp?type=login',
					data: dataString,
					success: function(xml) {
						var response = '';
						var name = '';
						var id = '';
						if (xml) {
							response = $(xml).find('response').text();
							name = $(xml).find('name').text();
							id = $(xml).find('id').text();
							if(response == '0') {
								$('.login-modal').overlay().close();
								login(name, id);
								showLoginLink();
								if(window.location.href.indexOf('/register.jsp')>-1) {
									window.location = '/profile.jsp';
								}
							} else if(response == '5') {
								alert('Your email address was not recognized.');
							} else if(response == '6') {
								//alert('Incorrect password.');
								$('#login-error').show().append('<li><em class="error">Incorrect password.</em></li>');
							} else if(response == '7') {
								alert('Your account has not yet been approved.');
							}
						} else {
							alert('There was an error.\nSorry for the inconvenience.');
							return false;
						}
					}
				});
				return false;
			}
		});
		$('#loginFormSubmit').click(function() {
			$('#loginFormSubmitButton').submit();
			return false;
		});
	});
};

//Forgot Password Form
function forgotPasswordForm() {
	$('#forgot_email').focus();
	$('#forgotpasswordForm').validate({
		meta: 'validate',
		messages: {
			forgot_email: {
				required: 'Please enter your email address.',
				email: 'Please enter a valid email address (you@example.com).'
			}
		},
		errorElement: 'em',
		errorLabelContainer: '#forgot-password-error',
		wrapper: 'li',
		submitHandler: function() {	
			var email = $('input#forgot_email').val();
			var dataString = 'email='+ email;
			$.ajax({
				type: 'POST',
				url: '/ajax/service.jsp?type=forgetPassword',
				data: dataString,
				success: function(xml) {
					var response = '';
					if (xml) {
						response = $(xml).find('response').text();
						if(response == '0') {
							var message =	'<p>Your password has been reset and sent to your email address.</p>' +
											'<a href="#" class="button close"><span>OK</span></a>';
							$('#forgotpassword-box').html(message)
							.hide()
							.fadeIn('fast', function() {
								message;
							});
							$('.close').click(function() {
								$('.login-modal').overlay().close();
							})
						} else if(response == '5') {
							alert('Your email address was not recognized.');
						} else if(response == '7') {
							alert('Your account has not yet been approved.');
						}
					} else {
						alert('There was an error.\nSorry for the inconvenience.');
						return false;
					}
				}
			});
			return false;
		}
	});
	$('#forgotpasswordSubmit').click(function() {
		$('#forgotpasswordSubmitButton').submit();
		return false;
	});
};

//Registration Form
function registrationForm() {
	if(isLoggedIn()==true) {
		window.location = '/profile.jsp';
	} else {
		$.get('/ajax/html/registration.html', function(data) {
			$('#registration-form').html(data);
			$('#first_name').focus();
			$('#registrationForm').validate({
				meta: 'validate',
				rules: {          
					'confirm_the_password': {
						equalTo: '#the_password'
					}
				},
				messages: {
					email: {
						email: 'Please enter a valid email address (you@example.com).'
					},
					confirm_the_password: {
						equalTo: 'Your passwords do not match.'
					}
				},
				errorElement: 'em',
				submitHandler: function() {
					var first_name = $('input#first_name').val();
					var last_name = $('input#last_name').val();
					var email = $('input#email').val();
					var the_password = $('input#the_password').val();
					var company = $('input#company').val();
					var company_description = $('input#company_description').val();
					var job_title = $('input#job_title').val();
					var phone = $('input#phone').val();
					var dataString = 'first_name='+first_name+ '&last_name='+ last_name + '&email='+ email + '&the_password='+ the_password + '&company='+ company + '&company_description='+ company_description + '&job_title='+ job_title + '&phone='+ phone;
					$.ajax({
						type: 'POST',
						url: '/ajax/service.jsp?type=register',
						data: dataString,
						success: function(xml) {
							var response = '';
							if (xml) {
								response = $(xml).find('response').text();
								if(response == '0') {
									var message =	'<div class="block rounded">' +
														'<div id="message">' +
															'<h3>Thank You!</h3>' +
															'<p>' +
																'Thank you for registering. ' +
																'A site administrator will review your information and get back to you within 24 hours. ' +
																'If you have any questions or need to reach us more urgently, please refer to our <a href="/contact.jsp">Contacts</a> page.' +
															'</p>' +
														'</div>' +
													'</div>';
									$('#registration').html(message)
									.hide()
									.fadeIn('fast', function() {
										message;
									});
								} else if(response == '3') {
									alert('This email address is already registered.');
								}
							} else {
								alert('There was an error.\nSorry for the inconvenience.');
								return false;
							}
						}
					});
					return false;
				}
			});
			$('#registrationFormSubmit').click(function() {
				$('#registrationFormSubmitButton').submit();
				return false;
			});
		});
	}	
};

//Profile
function getProfile() {
	if(isLoggedIn()!=true) {
		window.location = '/register.jsp';
	} else {
		$.get('/ajax/html/registration.html', function(data) {
			$('#registration-form').html(data);
			$('#registrationFormSubmit').html('<span>Update</span>');

			$.ajax({
				type: 'GET',
				url: '/ajax/service.jsp?type=getProfile' + '&nc=' + noCache(),
				success: function(xml) {
					var response = '';
					if (xml) {
						response = $(xml).find('response').text();
						if(response == '12') {
							window.location = '/';
						} else {
							var first_name = $(xml).find('first_name').text();
							var last_name = $(xml).find('last_name').text();
							var email = $(xml).find('email').text();
							var company = $(xml).find('company').text();
							var company_description = $(xml).find('company_description').text();
							var job_title = $(xml).find('job_title').text();
							var phone = $(xml).find('phone').text();
							profileId = $(xml).find('id').text();
							profilePassword = Math.floor(Math.random()*999999999999999) + '';
							$('#the_password').value = profilePassword;
							$('#confirm_the_password').value = profilePassword;
							$('input#first_name').val(first_name);
							$('input#last_name').val(last_name);
							$('input#email').val(email).attr('disabled', true);
							$('input#the_password').val(profilePassword);
							$('input#confirm_the_password').val(profilePassword);
							$('input#company').val(company);
							$('input#company_description').val(company_description);
							$('input#job_title').val(job_title);
							$('input#phone').val(phone);
						}
					} else {
						alert('There was an error.\nSorry for the inconvenience.');
						return false;
					}
				}
			});
			$('#registrationForm').validate({
				meta: 'validate',
				rules: {          
					'confirm_the_password': {
						equalTo: '#the_password'
					}
				},
				messages: {
					email: {
						email: 'Please enter a valid email address (you@example.com).'
					},
					confirm_the_password: {
						equalTo: 'Your passwords do not match.'
					}
				},
				errorElement: 'em',
				submitHandler: function() {
					var first_name = $('input#first_name').val();
					var last_name = $('input#last_name').val();
					var email = $('input#email').val();
					var the_password = $('input#the_password').val();
					var company = $('input#company').val();
					var company_description = $('input#company_description').val();
					var job_title = $('input#job_title').val();
					var phone = $('input#phone').val();
					
					if(profilePassword == the_password)  {
						var dataString = 'first_name='+first_name+ '&last_name='+ last_name + '&email='+ email + '&company='+ company + '&company_description='+ company_description + '&job_title='+ job_title + '&phone='+ phone;
					} else {
						var dataString = 'first_name='+first_name+ '&last_name='+ last_name + '&email='+ email + '&the_password='+ the_password + '&company='+ company + '&company_description='+ company_description + '&job_title='+ job_title + '&phone='+ phone;
					}
					$.ajax({
						type: 'POST',
						url: '/ajax/service.jsp?type=saveProfile',
						data: dataString,
						success: function(xml) {
							var response = '';
							if (xml) {
								response = $(xml).find('response').text();
								if(response == '0') {
									var message = '<p class="confirmed">Your profile has been updated.</p>';		
									$('#registration-message').html(message);
									var userId = first_name + ' ' + last_name + '|' + profileId + '|' + email;
									createCookie('userId',userId,30);
									showLoginLink();
								} else if(response == '9') {
									alert('Invalid user id.');
								}
							} else {
								alert('There was an error.\nSorry for the inconvenience.');
								return false;
							}
						}
					});
					return false;
				}
			});
			$('#registrationFormSubmit').click(function() {
				$('#registrationForm').submit();
			});
		});
	}
};

function toggleSelect() {
	$('select').each(function() {
		if (!$(this).hasClass('hidden')){
			$(this).addClass('hidden');
		}
		else{
			$(this).removeClass('hidden');
		}
	})
};

//Get URL Parameters
function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
};

/*!
* jQuery corner plugin: simple corner rounding
* Examples and documentation at: http://jquery.malsup.com/corner/
* version 2.09 (11-MAR-2010)
* Requires jQuery v1.3.2 or later
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Authors: Dave Methvin and Mike Alsup
*/
 
/**
* corner() takes a single string argument: $('#myDiv').corner("effect corners width")
*
* effect: name of the effect to apply, such as round, bevel, notch, bite, etc (default is round).
* corners: one or more of: top, bottom, tr, tl, br, or bl. (default is all corners)
* width: width of the effect; in the case of rounded corners this is the radius.
* specify this value using the px suffix such as 10px (yes, it must be pixels).
*/
;(function($) {
 
var style = document.createElement('div').style;
var moz = style['MozBorderRadius'] !== undefined;
var webkit = style['WebkitBorderRadius'] !== undefined;
var radius = style['borderRadius'] !== undefined || style['BorderRadius'] !== undefined;
var mode = document.documentMode || 0;
var noBottomFold = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);
 
var expr = $.browser.msie && (function() {
    var div = document.createElement('div');
    try { div.style.setExpression('width','0+0'); div.style.removeExpression('width'); }
    catch(e) { return false; }
    return true;
})();
    
function sz(el, p) {
    return parseInt($.css(el,p))||0;
};
function hex2(s) {
    var s = parseInt(s).toString(16);
    return ( s.length < 2 ) ? '0'+s : s;
};
function gpc(node) {
    while(node) {
        var v = $.css(node,'backgroundColor');
        if (v && v != 'transparent' && v != 'rgba(0, 0, 0, 0)') {
if (v.indexOf('rgb') >= 0) {
var rgb = v.match(/\d+/g);
return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
}
            return v;
}
node = node.parentNode; // keep walking if transparent
    }
    return '#ffffff';
};
 
function getWidth(fx, i, width) {
    switch(fx) {
    case 'round': return Math.round(width*(1-Math.cos(Math.asin(i/width))));
    case 'cool': return Math.round(width*(1+Math.cos(Math.asin(i/width))));
    case 'sharp': return Math.round(width*(1-Math.cos(Math.acos(i/width))));
    case 'bite': return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
    case 'slide': return Math.round(width*(Math.atan2(i,width/i)));
    case 'jut': return Math.round(width*(Math.atan2(width,(width-i-1))));
    case 'curl': return Math.round(width*(Math.atan(i)));
    case 'tear': return Math.round(width*(Math.cos(i)));
    case 'wicked': return Math.round(width*(Math.tan(i)));
    case 'long': return Math.round(width*(Math.sqrt(i)));
    case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
case 'dogfold':
    case 'dog': return (i&1) ? (i+1) : width;
    case 'dog2': return (i&2) ? (i+1) : width;
    case 'dog3': return (i&3) ? (i+1) : width;
    case 'fray': return (i%2)*width;
    case 'notch': return width;
case 'bevelfold':
    case 'bevel': return i+1;
    }
};
 
$.fn.corner = function(options) {
    // in 1.3+ we can fix mistakes with the ready state
if (this.length == 0) {
        if (!$.isReady && this.selector) {
            var s = this.selector, c = this.context;
            $(function() {
                $(s,c).corner(options);
            });
        }
        return this;
}
 
    return this.each(function(index){
var $this = $(this);
// meta values override options
var o = [$this.attr($.fn.corner.defaults.metaAttr) || '', options || ''].join(' ').toLowerCase();
var keep = /keep/.test(o); // keep borders?
var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]); // corner color
var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]); // strip color
var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
var re = /round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/;
var fx = ((o.match(re)||['round'])[0]);
var fold = /dogfold|bevelfold/.test(o);
var edges = { T:0, B:1 };
var opts = {
TL: /top|tl|left/.test(o), TR: /top|tr|right/.test(o),
BL: /bottom|bl|left/.test(o), BR: /bottom|br|right/.test(o)
};
if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
opts = { TL:1, TR:1, BL:1, BR:1 };
 
// support native rounding
if ($.fn.corner.defaults.useNative && fx == 'round' && (radius || moz || webkit) && !cc && !sc) {
if (opts.TL)
$this.css(radius ? 'border-top-left-radius' : moz ? '-moz-border-radius-topleft' : '-webkit-border-top-left-radius', width + 'px');
if (opts.TR)
$this.css(radius ? 'border-top-right-radius' : moz ? '-moz-border-radius-topright' : '-webkit-border-top-right-radius', width + 'px');
if (opts.BL)
$this.css(radius ? 'border-bottom-left-radius' : moz ? '-moz-border-radius-bottomleft' : '-webkit-border-bottom-left-radius', width + 'px');
if (opts.BR)
$this.css(radius ? 'border-bottom-right-radius' : moz ? '-moz-border-radius-bottomright' : '-webkit-border-bottom-right-radius', width + 'px');
return;
}
 
var strip = document.createElement('div');
$(strip).css({
overflow: 'hidden',
height: '1px',
minHeight: '1px',
fontSize: '1px',
backgroundColor: sc || 'transparent',
borderStyle: 'solid'
});
 
        var pad = {
            T: parseInt($.css(this,'paddingTop'))||0, R: parseInt($.css(this,'paddingRight'))||0,
            B: parseInt($.css(this,'paddingBottom'))||0, L: parseInt($.css(this,'paddingLeft'))||0
        };
 
        if (typeof this.style.zoom != undefined) this.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) this.style.border = 'none';
        strip.style.borderColor = cc || gpc(this.parentNode);
        var cssHeight = $(this).outerHeight();
 
        for (var j in edges) {
            var bot = edges[j];
            // only add stips if needed
            if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
                strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
                var d = document.createElement('div');
                $(d).addClass('jquery-corner');
                var ds = d.style;
 
                bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);
 
                if (bot && cssHeight != 'auto') {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.bottom = ds.left = ds.padding = ds.margin = '0';
                    if (expr)
                        ds.setExpression('width', 'this.parentNode.offsetWidth');
                    else
                        ds.width = '100%';
                }
                else if (!bot && $.browser.msie) {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';
                    
                    // fix ie6 problem when blocked element has a border width
                    if (expr) {
                        var bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
                        ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"');
                    }
                    else
                        ds.width = '100%';
                }
                else {
                 ds.position = 'relative';
                    ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' :
                                        (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';
                }
 
                for (var i=0; i < width; i++) {
                    var w = Math.max(0,getWidth(fx,i, width));
                    var e = strip.cloneNode(false);
                    e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                    bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
                }
 
if (fold && $.support.boxModel) {
if (bot && noBottomFold) continue;
for (var c in opts) {
if (!opts[c]) continue;
if (bot && (c == 'TL' || c == 'TR')) continue;
if (!bot && (c == 'BL' || c == 'BR')) continue;
 
var common = { position: 'absolute', border: 'none', margin: 0, padding: 0, overflow: 'hidden', backgroundColor: strip.style.borderColor };
var $horz = $('<div/>').css(common).css({ width: width + 'px', height: '1px' });
switch(c) {
case 'TL': $horz.css({ bottom: 0, left: 0 }); break;
case 'TR': $horz.css({ bottom: 0, right: 0 }); break;
case 'BL': $horz.css({ top: 0, left: 0 }); break;
case 'BR': $horz.css({ top: 0, right: 0 }); break;
}
d.appendChild($horz[0]);
 
var $vert = $('<div/>').css(common).css({ top: 0, bottom: 0, width: '1px', height: width + 'px' });
switch(c) {
case 'TL': $vert.css({ left: width }); break;
case 'TR': $vert.css({ right: width }); break;
case 'BL': $vert.css({ left: width }); break;
case 'BR': $vert.css({ right: width }); break;
}
d.appendChild($vert[0]);
}
}
            }
        }
    });
};
 
$.fn.uncorner = function() {
if (radius || moz || webkit)
this.css(radius ? 'border-radius' : moz ? '-moz-border-radius' : '-webkit-border-radius', 0);
$('div.jquery-corner', this).remove();
return this;
};
 
// expose options
$.fn.corner.defaults = {
useNative: true, // true if plugin should attempt to use native browser support for border radius rounding
metaAttr: 'data-corner' // name of meta attribute to use for options
};
    
})(jQuery);

$(document).ready(function() {
	if($.browser.msie){
		$('.rounded').corner("cc:#FFF");
		//$('.rounded').append("<div class=\"tl\"></div><div class=\"tr\"></div><div class=\"bl\"></div><div class=\"br\"></div>");
	}
});

