
$(document).ready(function(){



    var t=0;
var glob=0;
var interval = 4;
var globstep=0;

$('.limenu').each(function(){
	t=t+1;
	$(this).attr('step',glob);
	if(t>1){

		$(this).addClass("menu"+glob);
		$(this).hide();
		////console.log('skjulte' +t);
	}

	if(t>interval){
		t=0;
		glob=glob+1
	}

	}
	);



	pathnames=window.location;
	pathname=pathnames.toString();
	//console.log(pathname);
	a=pathname.split("/" );
	b=a.length;
	$('.limenu').each(function(){
        urlPath= $(this).children().attr('href')    ;
		//for(i=0;i<b;i++){

			if(urlPath.toLowerCase() == "/" +a[3].toLowerCase()+"/" ){
				// expand
				showthese = $(this).attr('step');
				$('.menu'+showthese).show();
				////console.log($(this).text() +" " + a[i]);
				////console.log("show " + '.menu'+showthese);
				$('.menu'+showthese).css('padding-left','20px');

			}else{
                ////console.log(urlPath +"  <--->" + a[3].toLowerCase() +" 3 " +i);
			}
		//}

	});

    

	$('a').each(
		function(){
			if( window.location.pathname == $(this).attr('href') ){
			 	$(this).css('font-weight','800');
			 	$(this).css('text-decoration','underline'); 
			 }
	});

     $('.contentmarkasspam').each(
         function(){
             if($(this).attr('count')> 0){
                 $(this).parent().parent().fadeTo('slow', 0.5);
             }
             if($(this).attr('count')> 4){
                  $(this).parent().parent().animate({
    opacity: 0.25,
    left: '+=50',
    height: 'toggle',
          fontSize:'3px',
  }, 2000, function() {
    // Animation complete.
  });
             }

         }

     );


    $('.contentmarkasspam').click(function(){
  		url ="/ajaxinput.php?action=markasspam&id="+$(this).parent().attr('val');

 		$.ajax({
		  url: url,
		  success: function(data) {
		  	 //alert(data);



 		  }
		});
       $(this).parent().parent().animate({
    opacity: 0.25,
    left: '+=50',
    height: 'toggle',
          fontSize:'3px',
  }, 1000, function() {
    // Animation complete.
  });
    });

    $('.contentvoteforitem').click(function(){
  		url ="/ajaxinput.php?action=markasvote&id="+$(this).parent().attr('val');
        pos= $(this).text().indexOf('+')-1;
        content = $(this).text().substr(0,pos);
        //console.log(content);
        $(this).empty().append(content +" + " + (parseInt($(this).attr('count'))+1));

        $(this).unbind();
 		$.ajax({
		  url: url,
		  success: function(data) {
		  	 //alert(data);



 		  }
		});

    });












if ($('#fun').length > 0) {
	$('#righthandside').hide();
	$('#maincontent').css('width','754px');
}

if ($('#shopframe').length > 0) {
	$('#righthandside').hide();
	$('#maincontent').css('width','754px');
}

$('#emailsignup').focus(
    function(){
    if( $('#emailsignup').attr('clicked')!= 'yes' ){
        $('#emailsignup').attr('clicked',"yes");
        $('#emailsignup').val('');
    }

    });
$('#emailsubscribe').click(function(){

    url ="/ajaxinput.php?action=emailsub&mail=" + $('#emailsignup').val()+"&story=" + document.location;
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var address = $('#emailsignup').val();
    if(reg.test(address) == false) {
        // Validation Failed
        alert('Please enter a valid email address.');
    }else{



 		$.ajax({
		  url: url,
		  success: function(data) {
		  	//alert(data);
		    //$('#kelkooproducts').html(data);
		    //alert('Load was performed.');

 				$('#signupbox').empty().append('<span style=\"font-size:90px\">:-)</span>');
 		  }
		});
    }
});


$('#header').mouseover(function(){
	$('#newtopmenu').show();
	
});
$('#newtopmenu').mouseover(function(){
$('#newtopmenu').mouseleave(function(){
	 $('#newtopmenu').hide();
});
});


    $('.limenu').each(function(){
        if( $(this).text().length > 20 ){
            $('.limenu').each(function(){
                $(this).children().css('font-size','11px');
            }
        );
        }
    });


 if ($('#kelkooproducts').length > 0 && $('#kelkooproductsingle').length==0) {
 		url ="/ajaxinput.php?action=kelkoo&code=" + $('#kelkooproducts').attr('code')+"&a=" + $('#kelkooproducts').attr('keyword')+"&c=" + $('#kelkooproducts').attr('c');
		 if($('#kelkooproducts').attr('code')==1){
		 		if($('#kelkooproducts').attr('c')==1){
					shopLink="<div class=\"visitshop\"><a href=\"/shop/\">Bes&oslash;k v&aring;r nettbutikk</a></div>";
				}
				if($('#kelkooproducts').attr('c')==4){
					shopLink="<div class=\"visitshop\"><a href=\"/shop/\">Visit our shop</a></div>";
				}
				if($('#kelkooproducts').attr('c')==2){
					shopLink="<div class=\"visitshop\"><a href=\"/shop/\">Shop</a></div>";
				}
				if($('#kelkooproducts').attr('c')==3){
					shopLink="<div class=\"visitshop\"><a href=\"/shop/\"> Online-shop</a></div>";
				}
				
			}else{
				shopLink=" ";
			}
			////console.log(url);
 		$.ajax({
		  url: url,
		  success: function(data) {
		  	 ////console.log(data);
		  	//alert(data);
		    //$('#kelkooproducts').html(data);
		    //alert('Load was performed.');
		    splitter = '</splitt>';
		    clearEnd ="<div style=\"clear:both\"></div>"+shopLink;
		     
		    adStart = "<div class=\"inlineproducts\">";
		    adEnd 	= "</div>";
		    productPart = data.split(splitter);
			 
			if(productPart[0].length > 5 ){
			    $('#content1').after(adStart + productPart[0] + splitter + productPart[1]  + '</div>' + adEnd + clearEnd );
				 ////console.log(adStart + productPart[0] + splitter + productPart[1]  + '</div>' + adEnd + clearEnd );
			}
			if(productPart[2].length > 5){
		    	$('#content3').after(adStart + productPart[2] + splitter + productPart[3]  + '</div>' + adEnd + clearEnd);
			}
			if (productPart[4].length > 5) {
				$('#content6').after(adStart + productPart[4] + splitter + productPart[5] + '</div>' + adEnd + clearEnd);
			}
			
		  }
		});
 }

if($('#domainforsale').length >0){
    // denne skal være variabel
   banner ="<div class=\"forsale\"><a href=\"/" + $('#domainforsale').attr('url')+ "\">This domain is for sale. Click to contact us</a></div>";
     $(banner).insertBefore('#main');
     $(banner).insertAfter('#footer');
    ////console.log('domenet er til salgs');
}
	 
 if ($('#kelkooproductsingle').length > 0) {
 		url ="/ajaxinput.php?action=kelkoosingle&code=" + $('#kelkooproducts').attr('code')+"&c=" + $('#kelkooproducts').attr('c')+"&a=" + $('#kelkooproducts').attr('keyword');
     //console.log('later singlepage kelkoo');
 		$.ajax({
		  url: url,
		  success: function(data) {
		  	//alert(data);
		    //$('#kelkooproducts').html(data);
		     //alert('Load was performed.');

 				$('#kelkooproductsingle').append(data);
 		  }
		});
 }else{
     //console.log('kelkooproductsingle var ikke der');
 }
 
 	
if($('#videoplayer').length>0){
	$.ajax({
		   type: "GET",
		   url: "/ajaxinput.php?action=video",
		   dataType: "json",
		    success: function(msg){
		    	   
				 
				  buildVideoPlayer(msg);
		   	}
		});	
	
	
}
	
	if($('#slideshow').length>0){
				$.ajax({
					   type: "GET",
					   url: "/ajaxinput.php?action=gallery",
					   dataType: "json",
					    success: function(msg){
					    	   
							   
							  buildImageRotator(msg);
					   	}
					});	
				
				 
				}
	if($('#slideshow2').length>0){
		$.ajax({
			   type: "GET",
			   url: "/ajaxinput.php?action=gallery2&show="+$('#slideshow2').attr('slidedata'),
			   dataType: "json",
			    success: function(msg){
			    	   
					   
					  buildFunImageRotator(msg);
			   	}
			});	
		
		
	}	
	$('#cntfrmsbmt').click(function(){
		name = $('#contactform_name').val();
		email = $('#contactform_email').val();
		title = $('#contactform_title').val();
		content = $('#contactform_content').val();
		
		$.post("/ajaxinput.php", { action:'contactform' ,name: name, email: email,title:title,content:content } );
		$(this).parent().fadeOut(500);
		$('#tnxfrcntk').fadeIn(500);
	});
	

	$('#showurlform').click(function(){
		 $(this).load('/ajaxinput.php?action=urlform',function(){
		 	$('#newsendurl').click(function(){
				$('#showurlform').empty();
			});
			
		 });
	 	
	});


// motta url
function mycallbackform(v,m,f){
	$.post("/ajaxinput.php", { action:'storenewurl' ,url: f.url, title:f.urlname,comment:comment } );
}

	$('.youtubesingleimageimage').click(function(){
		// alert( $(this).attr("videovalue") );
		var videoString = $(this).attr('videovalue');
		var fullVideoString = youtubehtmlbuild(videoString);
		$(this).parent().empty().append(fullVideoString);
		//alert(fullVideoString);
	})

	$('.contentcomment').click(function(){
		$(this).parent().css('height','400px');
		url = '/ajaxinput.php?action=commentform&url=' + document.location.href;
		$(this).parent().load(url, function() {
	  		// innsending av kommentar
			//alert('Load was performed.');
			
			$('#newsendcomment').click(function(){
				//alert('klikkkk');
				comment_title = $('#comment_title').val();
				comment_comment = $('#comment_comment').val();
				comment_name  = $('#comment_name').val();
				comment_id = $('#comment_id').val();
				 
				$.post("/ajaxinput.php", { 
					action:'postcomment' ,comment_title: comment_title, comment_comment: comment_comment,comment_name:comment_name,comment_id:comment_id 
					},function(data){
    				//alert(data); 
  				} );
				// tegn opp ny kommentar
				// tøm kommentarfeltet helt, og les inn nytt innhold fra serveren. -
				// eller legg til & lat som om alt funka bra. (tar siste)
				new_comment_html = "<div class=\"comment\">" +comment_title+"<div class=\"commentcomment\">"+comment_comment+"</div>" +" <div class=\"commentby\">" +comment_name+"</div></div>";
				
				$('#newcommentitem').empty().append(new_comment_html);
			});
		});
		// fjern click-eventen på denne:
		$('.contentcomment').unbind('click');
		

	}); 

// skaler alle bilder i midt-feltet til maks 150 px bredde/høyde
 if ($(location).attr('pathname').indexOf('twitter') > 1) {
 	$('#maincontent img').each(function(intIndex){
 		if ($(this).width() > 200) {
 			//$(this).hide();
 		}
 		
 	});
 }

 
	// kontakt-siden skal ha litt mer info på seg:
	if( $('.infoom').length > 0){
		 
		sedoUrl ="http://www.sedo.com/search/details.php4?domain="+document.domain;
		var domain_for_sale ="<p style=\" margin-top:130px;padding:20px;background-color:#efefef;text-align:center\">"
		+"Under the right circumstances" + document.domain  
		+ " may be for sale. <br><a href=\""+ sedoUrl + "\"> Click here to bid</a></p>";
		$('#maincontent').append(domain_for_sale);
	}



if($('.shopproduct').length  >0){

	var i=0;
	$('.shopproduct').each(function(){
		ads[i]=$(this).html();
		i++;

	});
	// bygg karusell
	$('#illustration').before('<div id="nyreklame"></div>');
	//$('#illustration').hide();
	$('#nyreklame').css('height','200px');
	switchAd(0);




}




    
});

var ads = new Array();
function switchAd(num){
	$('#nyreklame').fadeOut(200,function(){
	$('#nyreklame').empty().append(ads[num]);
	$('#nyreklame').fadeIn(200);

	});
	num=num+1;
	if(num > ads.length){
		num=0;
	}
	setTimeout("switchAd(" +num+")",3500);
}






// sett inn kommentarskjemaet
 



function youtubehtmlbuild(embedString){
	var out ='<object type="application/x-shockwave-flash" data="' 
	+ embedString + '" width="320" height="267"><param name="movie" value="' 
	+ embedString + '" /><param name="FlashVars" value="playerMode=embedded" /><param name="wmode" value="transparent" /></object>';
	return out;
}

// motta tips via e-post
function mycallbackform(v,m,f){
	var storyId = document.location.href;
	$.post("/ajaxinput.php", { action:'emailtips' ,name: f.name, story: storyId } );

}


function buildImageRotator(data){
	var outHtml="";
	for(i=0;i<data.length;i++){
		outHtml = outHtml +"<img src=\""+data[i]+"\" id=\"rotator" + i + "\" style=\"display:none\">";
	}
	 if(outHtml.length > 30){
	 	$('#slideshow').show();
	 }
	$('#slideshow').append(outHtml);	
	 
	$('#slideshow').click(function(){
		document.location='/flickr/';
	});
	imageRotate(0);
	
}
function buildFunImageRotator(data){
	var outHtml="";
	for(i=0;i<data.length;i++){
		outHtml = outHtml +"<img src=\"http://"+data[i]['image']+"\" id=\"rotator2" + i + "\" style=\"display:none\" targeturl=\"" + data[i]['targeturl']+ "\">";
		 
	}
	if(outHtml.length > 40){
		$('#slideshow2').show();
		$('#slideshow').hide();		
	
	}else{
		$('#slideshow').show();
		$('#slideshow2').hide();		
	} 
	outHtml = outHtml+"<div id=\"imagecounterfun\" count=\"" +data.length + "\"></div>"
	$('#slideshow2').append(outHtml);	
	for (i = 0; i < data.length; i++) {
		$('#rotator2'+i).click(function(){
			document.location = "http://" + $(this).attr('targeturl');
		});
	}
	imageFunRotate(0);
	
}
function imageRotate(i){
	j=i+1;
	if(j>$('#imagecounterfun').attr('count')){
		j=0;
		 
	}
	var width = $('#rotator'+i).attr('width');
	var height = $('#rotator'+i).attr('height');
	if(width<2){
		width=250;
	}
	if(height<2){
		height=250;
	}
	
	var topMargin = parseInt( (300 - height)/2);
	var leftMargin = parseInt( (300 - width)/2);
	$('#rotator'+i).css('margin-left',leftMargin+'px');
	$('#rotator'+i).css('margin-top',topMargin+'px');
	$('#rotator'+i).fadeOut(600,
		function(){
			var width = $('#rotator'+j).attr('width');
			var height = $('#rotator'+j).attr('height');

			if(width<2){
				width=250;
			}
			if(height<2){
				height=250;
			}
		
			var topMargin = parseInt( (300 - height)/2);
			var leftMargin = parseInt( (300 - width)/2);
			$('#rotator'+j).css('margin-left',leftMargin+'px');
			$('#rotator'+j).css('margin-top',topMargin+'px');
			$('#rotator'+j).fadeIn(600);
			//$('#log').empty().append('bilde ' + j +' offset ' + topMargin +' ,' +leftMargin);
		}) ;
	i++;
	if(i>$('#imagecounterfun').attr('count')){i=0;}
	setTimeout("imageRotate(" +i+")",3500);
}
function imageFunRotate(i){
	j=i+1;
	if($('#rotator2'+j).length<1){
		 
		j=0;
	}
	var width = $('#rotator2'+i).attr('width');
	var height = $('#rotator2'+i).attr('height');
		if(width<2){
		width=250;
	}
	if(height<2){
		height=250;
	}

	var topMargin = parseInt( (150 - height)/2);
	var leftMargin = parseInt( (300 - width)/2);
	$('#rotator2'+i).css('margin-left',leftMargin+'px');
	$('#rotator2'+i).css('margin-top',topMargin+'px');
	$('#rotator2'+i).fadeOut(600,
		function(){
			var width = $('#rotator2'+j).attr('width');
			var height = $('#rotator2'+j).attr('height');
				if(width<2){
		width=250;
	}
	if(height<2){
		height=250;
	}

			var topMargin = parseInt( (150 - height)/2);
			var leftMargin = parseInt( (300 - width)/2);
			$('#rotator2'+j).css('margin-left',leftMargin+'px');
			$('#rotator2'+j).css('margin-top',topMargin+'px');
			
			$('#rotator2'+j).fadeIn(600);
			 
		}) ;
	i++;
	if(i>9){i=0;}
	setTimeout("imageFunRotate(" +i+")",4100);
}


function buildVideoPlayer(data){
	 
	 
	var thumbNail = data["thumb"];
	var video 	= data["vid"];
	//console.log(video);
	var outHtml="";
	
	outHtml = outHtml +"<div id=\"videplayerhere\" style=\"display:none;\"></div>";
	for (t = 0; t < 10; t++) {
		var videoId = video[t]["uid"];
		var videoEmbedUrl=  video[t]["video_uri"]; 
		 if (t > 0) {
				var vidvisible = " style=\"display:none\" ";
			}
			else {
				var vidvisible = "";
			}
			
		outHtml = outHtml +"<div class=\"singlevid\" " +vidvisible+" id=\"vidvis" + t + "\" uid=\"" + t +"\"><span class=\"clickvideorewind\"><</span>";
		// sett inn første thumbnail av alle filemen
		for (i = 0; i < 4; i++) {
			
			if (i > 0) {
				var visible = " style=\"display:none\" ";
			}
			else {
				var visible = "";
			}
			 outHtml = outHtml + "<span class=\"vidpreview\" video=\"" + videoEmbedUrl +"\"id=\"vidthum" +videoId +i+ "\" " + visible + " uid=\""+videoId +i+ "\">" + "<img src=\"" + thumbNail[videoId]["thumb_url"][i] + "\" height=\"" + thumbNail[videoId]["thumb_height"][1] + "\" width=\"" + thumbNail[videoId]["thumb_width"][1] + "\"></span>"
			//outHtml = outHtml + "<div id=\"vidthum\" " + visible + "></div>";
			
		}
		outHtml = outHtml +"<span class=\"clickvideoffwd\">></span><div class=\"videotitle\">" + video[t]["video_title"]+"</div></div>";
	}
	 
	$('#videoplayer').empty().append(outHtml);
	$('.vidpreview').mouseover(
		function(){
			videoIdNo=$(this).attr('uid') ;
			playPreview(videoIdNo);
			
		}
	);
	
	$('.vidpreview').click(
		function(){
			videoUrl=$(this).attr('video') ;
			 $('#videplayerhere').empty().fadeIn(900).append(youtubehtmlbuild(videoUrl));
			
		}
	);
	
	
	$('.clickvideorewind').click(function(){
		thisId=$(this).parent().attr('uid');
		$('#vidvis'+ (thisId)).hide();
		if(thisId <1){thisId=10;}
		$('#vidvis'+ (parseInt(thisId)-1)).show();
		 
	});
	$('.clickvideoffwd').click(function(){
		thisId=$(this).parent().attr('uid');
		$('#vidvis'+ (thisId)).hide();
		if(thisId >9){thisId=0;}
		$('#vidvis'+ (parseInt(thisId)+1)).show();
		
	});
	
}



function playPreview(uid){
	//console.log('playPreview'+uid);
	videoImageLoop(uid,0);
	
}
function videoImageLoop(uid,start){
	if (start != 0) {
		$('#vidthum' + (uid + 0)).hide();
	}
	if (start != 1) {
		$('#vidthum' + (uid + 1)).hide();
	}
	if (start != 2) {
		$('#vidthum' + (uid + 2)).hide();
	} 
	if (start != 3) {
		$('#vidthum' + (uid + 3)).hide();
	} 
	$('#vidthum'+(uid +start)).show();
	//console.log('#vidthum'+(uid +start));
	start=start+1;
	if (start > 3) {
		start = 0;
	}
	setTimeout( 'videoImageLoop('+uid+','+start+')'  ,400);
}









searchhi = {
  highlightWord: function(node,word) {
    // Iterate into this nodes childNodes
    if (node.hasChildNodes) {
	    for (var hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
		    searchhi.highlightWord(node.childNodes[hi_cn],word);
	    }
    }

    // And do this node itself
    if (node.nodeType == 3) { // text node
	    tempNodeVal = node.nodeValue.toLowerCase();
	    tempWordVal = word.toLowerCase();
	    if (tempNodeVal.indexOf(tempWordVal) != -1) {
		    var pn = node.parentNode;
		    // check if we're inside a "nosearchhi" zone
		    var checkn = pn;
		    while (checkn.nodeType != 9 && 
		    checkn.nodeName.toLowerCase() != 'body') { 
		    // 9 = top of doc
			    if (checkn.className.match(/\bnosearchhi\b/)) { return; }
			    checkn = checkn.parentNode;
		    }
		    if (pn.className != "searchword") {
			    // word has not already been highlighted!
			    var nv = node.nodeValue;
			    var ni = tempNodeVal.indexOf(tempWordVal);
			    // Create a load of replacement nodes
			    var before = document.createTextNode(nv.substr(0,ni));
			    var docWordVal = nv.substr(ni,word.length);
			    var after = document.createTextNode(nv.substr(ni+word.length));
			    var hiwordtext = document.createTextNode(docWordVal);
			    var hiword = document.createElement("span");
			    hiword.className = "searchword";
			    hiword.appendChild(hiwordtext);
			    pn.insertBefore(before,node);
			    pn.insertBefore(hiword,node);
			    pn.insertBefore(after,node);
			    pn.removeChild(node);
			    searchhi.found += 1;
			    if (searchhi.found == 1) pn.scrollIntoView();
		    }
	    }
    }
  },

  googleSearchHighlight: function() {
    var ref = document.referrer;
    if (ref.indexOf('?') == -1) return;
    var qs = ref.substr(ref.indexOf('?')+1);
    var qsa = qs.split('&');
    for (var i=0;i<qsa.length;i++) {
	    var qsip = qsa[i].split('=');
      if (qsip.length == 1) continue;
      if (qsip[0] == 'q' || qsip[0] == 'p') { // q= for Google, p= for Yahoo
		    var wordstring = unescape(qsip[1].replace(/\+/g,' '));
		    searchhi.process(wordstring);
      }
    }
  },
  
  process: function(wordstring) {
    searchhi.found = 0;
    var words = wordstring.split(/\s+/);
    for (w=0;w<words.length;w++) {
	    searchhi.highlightWord(document.getElementsByTagName("body")[0],words[w]);
    }
    if (searchhi.found === 0) {
      searchhi.nohits();
    }
  },
  
  nohits: function() {
  },
  
  init: function() {
    if (!document.createElement || !document.getElementsByTagName) return;
    // hook up forms of type searchhi
    var frms = document.getElementsByTagName("form");
    for (var i=0; i<frms.length; i++) {
      if (frms[i].className.match(/\bsearchhi\b/)) {
        frms[i].onsubmit = function() {
          var inps = this.getElementsByTagName("input");
          for (var j=0; j<inps.length; j++) {
            if (inps[j].type == "text") {
              searchhi.process(inps[j].value);
              return false;
            }
          }
        };
      }
    }
    // highlight search engine referrer results
    searchhi.googleSearchHighlight();
  }
};



(function(i) {var u =navigator.userAgent;var e=/*@cc_on!@*/false; var st =
setTimeout;if(/webkit/i.test(u)){st(function(){var dr=document.readyState;
if(dr=="loaded"||dr=="complete"){i()}else{st(arguments.callee,10);}},10);}
else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){
document.addEventListener("DOMContentLoaded",i,false); } else if(e){     (
function(){var t=document.createElement('doc:rdy');try{t.doScroll('left');
i();t=null;}catch(e){st(arguments.callee,0);}})();}else{window.onload=i;}})(searchhi.init);
(function($){$.prompt=function(message,options){options=$.extend({},$.prompt.defaults,options);$.prompt.currentPrefix=options.prefix;var ie6=($.browser.msie&&$.browser.version<7);var $body=$(document.body);var $window=$(window);options.classes=$.trim(options.classes);if(options.classes!='')options.classes=' '+options.classes;var msgbox='<div class="'+options.prefix+'box'+options.classes+'" id="'+options.prefix+'box">';if(options.useiframe&&(($('object, applet').length>0)||ie6)){msgbox+='<iframe src="javascript:false;" style="display:block;position:absolute;z-index:-1;" class="'+options.prefix+'fade" id="'+options.prefix+'fade"></iframe>';}else{if(ie6){$('select').css('visibility','hidden');}msgbox+='<div class="'+options.prefix+'fade" id="'+options.prefix+'fade"></div>';}msgbox+='<div class="'+options.prefix+'" id="'+options.prefix+'"><div class="'+options.prefix+'container"><div class="';msgbox+=options.prefix+'close">X</div><div id="'+options.prefix+'states"></div>';msgbox+='</div></div></div>';var $jqib=$(msgbox).appendTo($body);var $jqi=$jqib.children('#'+options.prefix);var $jqif=$jqib.children('#'+options.prefix+'fade');if(message.constructor==String){message={state0:{html:message,buttons:options.buttons,focus:options.focus,submit:options.submit}};}var states="";$.each(message,function(statename,stateobj){stateobj=$.extend({},$.prompt.defaults.state,stateobj);message[statename]=stateobj;states+='<div id="'+options.prefix+'_state_'+statename+'" class="'+options.prefix+'_state" style="display:none;"><div class="'+options.prefix+'message">'+stateobj.html+'</div><div class="'+options.prefix+'buttons">';$.each(stateobj.buttons,function(k,v){if(typeof v=='object')states+='<button name="'+options.prefix+'_'+statename+'_button'+v.title.replace(/[^a-z0-9]+/gi,'')+'" id="'+options.prefix+'_'+statename+'_button'+v.title.replace(/[^a-z0-9]+/gi,'')+'" value="'+v.value+'">'+v.title+'</button>';else states+='<button name="'+options.prefix+'_'+statename+'_button'+k+'" id="'+options.prefix+'_'+statename+'_button'+k+'" value="'+v+'">'+k+'</button>';});states+='</div></div>';});$jqi.find('#'+options.prefix+'states').html(states).children('.'+options.prefix+'_state:first').css('display','block');$jqi.find('.'+options.prefix+'buttons:empty').css('display','none');$.each(message,function(statename,stateobj){var $state=$jqi.find('#'+options.prefix+'_state_'+statename);$state.children('.'+options.prefix+'buttons').children('button').click(function(){var msg=$state.children('.'+options.prefix+'message');var clicked=stateobj.buttons[$(this).text()];if(clicked==undefined){for(var i in stateobj.buttons)if(stateobj.buttons[i].title==$(this).text())clicked=stateobj.buttons[i].value;}if(typeof clicked=='object')clicked=clicked.value;var forminputs={};$.each($jqi.find('#'+options.prefix+'states :input').serializeArray(),function(i,obj){if(forminputs[obj.name]===undefined){forminputs[obj.name]=obj.value;}else if(typeof forminputs[obj.name]==Array||typeof forminputs[obj.name]=='object'){forminputs[obj.name].push(obj.value);}else{forminputs[obj.name]=[forminputs[obj.name],obj.value];}});var close=stateobj.submit(clicked,msg,forminputs);if(close===undefined||close){removePrompt(true,clicked,msg,forminputs);}});$state.find('.'+options.prefix+'buttons button:eq('+stateobj.focus+')').addClass(options.prefix+'defaultbutton');});var ie6scroll=function(){$jqib.css({top:$window.scrollTop()});};var fadeClicked=function(){if(options.persistent){var i=0;$jqib.addClass(options.prefix+'warning');var intervalid=setInterval(function(){$jqib.toggleClass(options.prefix+'warning');if(i++>1){clearInterval(intervalid);$jqib.removeClass(options.prefix+'warning');}},100);}else{removePrompt();}};var keyPressEventHandler=function(e){var key=(window.event)?event.keyCode:e.keyCode;if(key==27){fadeClicked();}if(key==9){var $inputels=$(':input:enabled:visible',$jqib);var fwd=!e.shiftKey&&e.target==$inputels[$inputels.length-1];var back=e.shiftKey&&e.target==$inputels[0];if(fwd||back){setTimeout(function(){if(!$inputels)return;var el=$inputels[back===true?$inputels.length-1:0];if(el)el.focus();},10);return false;}}};var positionPrompt=function(){$jqib.css({position:(ie6)?"absolute":"fixed",height:$window.height(),width:"100%",top:(ie6)?$window.scrollTop():0,left:0,right:0,bottom:0});$jqif.css({position:"absolute",height:$window.height(),width:"100%",top:0,left:0,right:0,bottom:0});$jqi.css({position:"absolute",top:options.top,left:"50%",marginLeft:(($jqi.outerWidth()/2)*-1)});};var stylePrompt=function(){$jqif.css({zIndex:options.zIndex,display:"none",opacity:options.opacity});$jqi.css({zIndex:options.zIndex+1,display:"none"});$jqib.css({zIndex:options.zIndex});};var removePrompt=function(callCallback,clicked,msg,formvals){$jqi.remove();if(ie6){$body.unbind('scroll',ie6scroll);}$window.unbind('resize',positionPrompt);$jqif.fadeOut(options.overlayspeed,function(){$jqif.unbind('click',fadeClicked);$jqif.remove();if(callCallback){options.callback(clicked,msg,formvals);}$jqib.unbind('keypress',keyPressEventHandler);$jqib.remove();if(ie6&&!options.useiframe){$('select').css('visibility','visible');}});};positionPrompt();stylePrompt();if(ie6){$window.scroll(ie6scroll);}$jqif.click(fadeClicked);$window.resize(positionPrompt);$jqib.bind("keydown keypress",keyPressEventHandler);$jqi.find('.'+options.prefix+'close').click(removePrompt);$jqif.fadeIn(options.overlayspeed);$jqi[options.show](options.promptspeed,options.loaded);$jqi.find('#'+options.prefix+'states .'+options.prefix+'_state:first .'+options.prefix+'defaultbutton').focus();if(options.timeout>0)setTimeout($.prompt.close,options.timeout);return $jqib;};$.prompt.defaults={prefix:'jqi',classes:'',buttons:{Ok:true},loaded:function(){},submit:function(){return true;},callback:function(){},opacity:0.6,zIndex:999,overlayspeed:'slow',promptspeed:'fast',show:'fadeIn',focus:0,useiframe:false,top:"15%",persistent:true,timeout:0,state:{html:'',buttons:{Ok:true},focus:0,submit:function(){return true;}}};$.prompt.currentPrefix=$.prompt.defaults.prefix;$.prompt.setDefaults=function(o){$.prompt.defaults=$.extend({},$.prompt.defaults,o);};$.prompt.setStateDefaults=function(o){$.prompt.defaults.state=$.extend({},$.prompt.defaults.state,o);};$.prompt.getStateContent=function(state){return $('#'+$.prompt.currentPrefix+'_state_'+state);};$.prompt.getCurrentState=function(){return $('.'+$.prompt.currentPrefix+'_state:visible');};$.prompt.getCurrentStateName=function(){var stateid=$.prompt.getCurrentState().attr('id');return stateid.replace($.prompt.currentPrefix+'_state_','');};$.prompt.goToState=function(state,callback){$('.'+$.prompt.currentPrefix+'_state').slideUp('slow');$('#'+$.prompt.currentPrefix+'_state_'+state).slideDown('slow',function(){$(this).find('.'+$.prompt.currentPrefix+'defaultbutton').focus();if(typeof callback=='function')callback();});};$.prompt.nextState=function(callback){var $next=$('.'+$.prompt.currentPrefix+'_state:visible').next();$('.'+$.prompt.currentPrefix+'_state').slideUp('slow');$next.slideDown('slow',function(){$next.find('.'+$.prompt.currentPrefix+'defaultbutton').focus();if(typeof callback=='function')callback();});};$.prompt.prevState=function(callback){var $next=$('.'+$.prompt.currentPrefix+'_state:visible').prev();$('.'+$.prompt.currentPrefix+'_state').slideUp('slow');$next.slideDown('slow',function(){$next.find('.'+$.prompt.currentPrefix+'defaultbutton').focus();if(typeof callback=='function')callback();});};$.prompt.close=function(){$('#'+$.prompt.currentPrefix+'box').fadeOut('fast',function(){$(this).remove();});};$.fn.prompt=function(options){if(options==undefined)options={};if(options.withDataAndEvents==undefined)options.withDataAndEvents=false;$.prompt($(this).clone(options.withDataAndEvents).html(),options);}})(jQuery);


eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 j=x y();A.B.q({C:5(a){7 b={r:\'1\',9:\'D\',8:E};7 a=$.q(b,a);7 c="#"+$(0).F("G");7 d=s($(0).k("H"))-I;7 e=s($(0).k("J"))-K;7 f=\'\';$(0).k("L-M","N");$(c).g().h(5(i){$(0).k({"z-O":i,"P":"Q"})});$(c).g().h(5(){$(0).l({m:((2.1()*R)+4)+"3","n":(2.1()*e)+"3","o":(2.1()*d)+"3"},a.8,a.9)});$(0).S(5(){$(0).T();U(j[c])});V(a.r){t\'W\':{f=\'$("\'+c+\'").g().h(5(){$(0).l({m: ((2.1()*p)+6)+"3", "n": (2.1()*\'+e+\')+"3"}, \'+a.8+\', "\'+a.9+\'" );});\';u}t\'X\':{f=\'$("\'+c+\'").g().h(5(){$(0).l({m: ((2.1()*p)+6)+"3", "o":(2.1()*\'+d+\')+"3"}, \'+a.8+\', "\'+a.9+\'" );});\';u}Y:{f=\'$("\'+c+\'").g().h(5(){$(0).l({m: ((2.1()*p)+6)+"3", "n": (2.1()*\'+e+\')+"3", "o":(2.1()*\'+d+\')+"3"}, \'+a.8+\', "\'+a.9+\'" );});\'}}j[c]=v(f,a.8+w);$(0).Z(5(){j[c]=v(f,a.8+w)})}});',62,62,'this|random|Math|px||function||var|speed|easein|||||||children|each||tcTimer|css|animate|fontSize|top|left|34|extend|direction|parseInt|case|break|setInterval|50|new|Array||jQuery|fn|tagCloud|linear|3000|attr|id|width|70|height|30|list|style|none|index|position|absolute|36|mouseover|stop|clearInterval|switch|vertical|horizontal|default|mouseout'.split('|'),0,{}))

