
function popWin(url,win,para){
var win=window.open(url,win,para);
win.focus();
}
function setLocation(url){
window.location.href=url;
}
function setPLocation(url,setFocus){
if(setFocus){
window.opener.focus();
}
window.opener.location.href=url;
}
function setLanguageCode(code,fromCode){
var href=window.location.href;
var after='',dash;
if(dash=href.match(/\#(.*)$/)){
href=href.replace(/\#(.*)$/,'');
after=dash[0];
}
if(href.match(/[?]/)){
var re=/([?&]store=)[a-z0-9_]*/;
if(href.match(re)){
href=href.replace(re,'$1'+code);
}else{
href+='&store='+code;
}
var re=/([?&]from_store=)[a-z0-9_]*/;
if(href.match(re)){
href=href.replace(re,'');
}
}else{
href+='?store='+code;
}
if(typeof(fromCode)!='undefined'){
href+='&from_store='+fromCode;
}
href+=after;
setLocation(href);
}
function decorateGeneric(elements,decorateParams)
{
var allSupportedParams=['odd','even','first','last'];
var _decorateParams={};
var total=elements.length;
if(total){
if(typeof(decorateParams)=='undefined'){
decorateParams=allSupportedParams;
}
if(!decorateParams.length){
return;
}
for(var k in allSupportedParams){
_decorateParams[allSupportedParams[k]]=false;
}
for(var k in decorateParams){
_decorateParams[decorateParams[k]]=true;
}
if(_decorateParams.first){
Element.addClassName(elements[0],'first');
}
if(_decorateParams.last){
Element.addClassName(elements[total-1],'last');
}
for(var i=0;i<total;i++){
if((i+1)%2==0){
if(_decorateParams.even){
Element.addClassName(elements[i],'even');
}
}
else{
if(_decorateParams.odd){
Element.addClassName(elements[i],'odd');
}
}
}
}
}
function decorateTable(table,options){
var table=$(table);
if(table){
var _options={
'tbody':false,
'tbody tr':['odd','even','first','last'],
'thead tr':['first','last'],
'tfoot tr':['first','last'],
'tr td':['last']
};
if(typeof(options)!='undefined'){
for(var k in options){
_options[k]=options[k];
}
}
if(_options['tbody']){
decorateGeneric(table.select('tbody'),_options['tbody']);
}
if(_options['tbody tr']){
decorateGeneric(table.select('tbody tr'),_options['tbody tr']);
}
if(_options['thead tr']){
decorateGeneric(table.select('thead tr'),_options['thead tr']);
}
if(_options['tfoot tr']){
decorateGeneric(table.select('tfoot tr'),_options['tfoot tr']);
}
if(_options['tr td']){
var allRows=table.select('tr');
if(allRows.length){
for(var i=0;i<allRows.length;i++){
decorateGeneric(allRows[i].getElementsByTagName('TD'),_options['tr td']);
}
}
}
}
}
function decorateList(list,nonRecursive){
if($(list)){
if(typeof(nonRecursive)=='undefined'){
var items=$(list).select('li')
}
else{
var items=$(list).childElements();
}
decorateGeneric(items,['odd','even','last']);
}
}
function decorateDataList(list){
list=$(list);
if(list){
decorateGeneric(list.select('dt'),['odd','even','last']);
decorateGeneric(list.select('dd'),['odd','even','last']);
}
}
function parseSidUrl(baseUrl,urlExt){
sidPos=baseUrl.indexOf('/?SID=');
sid='';
urlExt=(urlExt!=undefined)?urlExt:'';
if(sidPos>-1){
sid='?'+baseUrl.substring(sidPos+2);
baseUrl=baseUrl.substring(0,sidPos+1);
}
return baseUrl+urlExt+sid;
}
function formatCurrency(price,format,showPlus){
precision=isNaN(format.precision=Math.abs(format.precision))?2:format.precision;
requiredPrecision=isNaN(format.requiredPrecision=Math.abs(format.requiredPrecision))?2:format.requiredPrecision;
precision=requiredPrecision;
integerRequired=isNaN(format.integerRequired=Math.abs(format.integerRequired))?1:format.integerRequired;
decimalSymbol=format.decimalSymbol==undefined?",":format.decimalSymbol;
groupSymbol=format.groupSymbol==undefined?".":format.groupSymbol;
groupLength=format.groupLength==undefined?3:format.groupLength;
if(showPlus==undefined||showPlus==true){
s=price<0?"-":(showPlus?"+":"");
}else if(showPlus==false){
s='';
}
i=parseInt(price=Math.abs(+price||0).toFixed(precision))+"";
pad=(i.length<integerRequired)?(integerRequired-i.length):0;
while(pad){i='0'+i;pad--;}
j=(j=i.length)>groupLength?j%groupLength:0;
re=new RegExp("(\\d{"+groupLength+"})(?=\\d)","g");
r=(j?i.substr(0,j)+groupSymbol:"")+i.substr(j).replace(re,"$1"+groupSymbol)+(precision?decimalSymbol+Math.abs(price-i).toFixed(precision).replace(/-/,0).slice(2):"")
if(format.pattern.indexOf('{sign}')==-1){
pattern=s+format.pattern;
}else{
pattern=format.pattern.replace('{sign}',s);
}
return pattern.replace('%s',r).replace(/^\s\s*/,'').replace(/\s\s*$/,'');
};
function expandDetails(el,childClass){
if(Element.hasClassName(el,'show-details')){
$$(childClass).each(function(item){item.hide()});
Element.removeClassName(el,'show-details');
}
else{
$$(childClass).each(function(item){item.show()});
Element.addClassName(el,'show-details');
}
}
var isIE=navigator.appVersion.match(/MSIE/)=="MSIE";
if(!window.Varien)
var Varien=new Object();
Varien.showLoading=function(){
Element.show('loading-process');
}
Varien.hideLoading=function(){
Element.hide('loading-process');
}
Varien.GlobalHandlers={
onCreate:function(){
Varien.showLoading();
},
onComplete:function(){
if(Ajax.activeRequestCount==0){
Varien.hideLoading();
}
}
};
Ajax.Responders.register(Varien.GlobalHandlers);
Varien.searchForm=Class.create();
Varien.searchForm.prototype={
initialize:function(form,field,emptyText){
this.form=$(form);
this.field=$(field);
this.emptyText=emptyText;
Event.observe(this.form,'submit',this.submit.bind(this));
Event.observe(this.field,'focus',this.focus.bind(this));
Event.observe(this.field,'blur',this.blur.bind(this));
this.blur();
},
submit:function(event){
if(this.field.value==this.emptyText||this.field.value==''){
Event.stop(event);
return false;
}
return true;
},
focus:function(event){
if(this.field.value==this.emptyText){
this.field.value='';
}
},
blur:function(event){
if(this.field.value==''){
this.field.value=this.emptyText;
}
},
initAutocomplete:function(url,destinationElement){
new Ajax.Autocompleter(
this.field,
destinationElement,
url,
{
paramName:this.field.name,
method:'get',
minChars:2,
updateElement:this._selectAutocompleteItem.bind(this),
onShow:function(element,update){
if(!update.style.position||update.style.position=='absolute'){
update.style.position='absolute';
Position.clone(element,update,{
setHeight:false,
offsetTop:element.offsetHeight
});
}
Effect.Appear(update,{duration:0});
}
}
);
},
_selectAutocompleteItem:function(element){
if(element.title){
this.field.value=element.title;
}
this.form.submit();
}
}
Varien.Tabs=Class.create();
Varien.Tabs.prototype={
initialize:function(selector){
var self=this;
$$(selector+' a').each(this.initTab.bind(this));
},
initTab:function(el){
el.href='javascript:void(0)';
if($(el.parentNode).hasClassName('active')){
this.showContent(el);
}
el.observe('click',this.showContent.bind(this,el));
},
showContent:function(a){
var li=$(a.parentNode),ul=$(li.parentNode);
ul.getElementsBySelector('li','ol').each(function(el){
var contents=$(el.id+'_contents');
if(el==li){
el.addClassName('active');
contents.show();
}else{
el.removeClassName('active');
contents.hide();
}
});
}
}
Varien.DateElement=Class.create();
Varien.DateElement.prototype={
initialize:function(type,content,required,format){
if(type=='id'){
this.day=$(content+'day');
this.month=$(content+'month');
this.year=$(content+'year');
this.full=$(content+'full');
this.advice=$(content+'advice');
}else if(type=='container'){
this.day=content.day;
this.month=content.month;
this.year=content.year;
this.full=content.full;
this.advice=content.advice;
}else{
return;
}
this.required=required;
this.format=format;
this.day.addClassName('validate-custom');
this.day.validate=this.validate.bind(this);
this.month.addClassName('validate-custom');
this.month.validate=this.validate.bind(this);
this.year.addClassName('validate-custom');
this.year.validate=this.validate.bind(this);
this.year.setAttribute('autocomplete','off');
this.advice.hide();
},
validate:function(){
var error=false;
if(this.day.value==''&&this.month.value==''&&this.year.value==''){
if(this.required){
error='This date is a required value.';
}else{
this.full.value='';
}
}else if(this.day.value==''||this.month.value==''||this.year.value==''){
error='Please enter a valid full date.';
}else{
var date=new Date();
if(this.day.value<1||this.day.value>31){
error='Please enter a valid day (1-31).';
}else if(this.month.value<1||this.month.value>12){
error='Please enter a valid month (1-12).';
}else if(this.year.value<1900||this.year.value>date.getFullYear()){
error='Please enter a valid year (1900-'+date.getFullYear()+').';
}else{
this.full.value=this.format.replace(/(%m|%b)/i,this.month.value).replace(/(%d|%e)/i,this.day.value).replace(/%y/i,this.year.value);
var testFull=this.month.value+'/'+this.day.value+'/'+this.year.value;
var test=new Date(testFull);
if(isNaN(test)){
error='Please enter a valid date.';
}
}
}
if(error!==false){
try{
this.advice.innerHTML=Translator.translate(error);
}
catch(e){
this.advice.innerHTML=error;
}
this.advice.show();
return false;
}
this.day.removeClassName('validation-failed');
this.month.removeClassName('validation-failed');
this.year.removeClassName('validation-failed');
this.advice.hide();
return true;
}
};
Varien.DOB=Class.create();
Varien.DOB.prototype={
initialize:function(selector,required,format){
var el=$$(selector)[0];
var container={};
container.day=Element.select(el,'.dob-day input')[0];
container.month=Element.select(el,'.dob-month input')[0];
container.year=Element.select(el,'.dob-year input')[0];
container.full=Element.select(el,'.dob-full input')[0];
container.advice=Element.select(el,'.validation-advice')[0];
new Varien.DateElement('container',container,required,format);
}
};
Varien.FileElement=Class.create();
Varien.FileElement.prototype={
initialize:function(id){
this.fileElement=$(id);
this.hiddenElement=$(id+'_value');
this.fileElement.observe('change',this.selectFile.bind(this));
},
selectFile:function(event){
this.hiddenElement.value=this.fileElement.getValue();
}
};
Validation.addAllThese([
['validate-custom',' ',function(v,elm){
return elm.validate();
}]
]);
function truncateOptions(){
$$('.truncated').each(function(element){
Event.observe(element,'mouseover',function(){
if(element.down('div.truncated_full_value')){
element.down('div.truncated_full_value').addClassName('show')
}
});
Event.observe(element,'mouseout',function(){
if(element.down('div.truncated_full_value')){
element.down('div.truncated_full_value').removeClassName('show')
}
});
});
}
Event.observe(window,'load',function(){
truncateOptions();
});
Element.addMethods({
getInnerText:function(element)
{
element=$(element);
if(element.innerText&&!Prototype.Browser.Opera){
return element.innerText
}
return element.innerHTML.stripScripts().unescapeHTML().replace(/[\n\r\s]+/g,' ').strip();
}
});
if(!("console"in window)||!("firebug"in console))
{
var names=["log","debug","info","warn","error","assert","dir","dirxml",
"group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];
window.console={};
for(var i=0;i<names.length;++i)
window.console[names[i]]=function(){}
}
function fireEvent(element,event){
if(document.createEventObject){
var evt=document.createEventObject();
return element.fireEvent('on'+event,evt)
}
else{
var evt=document.createEvent("HTMLEvents");
evt.initEvent(event,true,true);
return!element.dispatchEvent(evt);
}
}

