$(document).ready(function () {
    var $panels = $('#slider1 .scrollContainer > div');
    var $panels2 = $('#slider2 .scrollContainer > div');
    var $container = $('#slider1 .scrollContainer');
    var $container2 = $('#slider2 .scrollContainer');
    var horizontal = true;
    if (horizontal) {
        $panels.css({
            'float' : 'left',
            'position' : 'relative' // IE fix to ensure overflow is hidden
        });
        $container.css('width', ($panels[0].offsetWidth * $panels.length) + 20);
        $panels2.css({
            'float' : 'left',
            'position' : 'relative'
        });
        $container2.css('width', ($panels2[0].offsetWidth * $panels2.length) + 20);
    }
    var $scroll = $('#slider1 .scroll').css('overflow', 'hidden');
    var $scroll2 = $('#slider2 .scroll').css('overflow', 'hidden');
    $scroll
        .before('<img class="scrollButtons left" src="/jQuery-scroller/images/scroll_left.png" title="Page back" />')
        .after('<img class="scrollButtons right" src="/jQuery-scroller/images/scroll_right.png" title="Next page" />');
    $scroll2
        .before('<img class="scrollButtons left" src="/jQuery-scroller/images/scroll_left.png" title="Page back" />')
        .after('<img class="scrollButtons right" src="/jQuery-scroller/images/scroll_right.png" title="Next page" />');
    var offset = parseInt((horizontal ? $container.css('paddingTop') : $container.css('paddingLeft')) || 0) * -1;
    var offset2 = parseInt((horizontal ? $container2.css('paddingTop') : $container2.css('paddingLeft')) || 0) * -1;
    var scrollOptions = {
        target: $scroll, // the element that has the overflow
        items: $panels, // can be a selector which will be relative to the target
        // selectors are NOT relative to document, i.e. make sure they're unique
        prev: 'img.left', 
        next: 'img.right',
        axis: 'x',
        offset: offset,
        duration: 300,
        easing: 'swing'};
    var scrollOptions2 = {
        target: $scroll2,
        items: $panels2,
        prev: 'img.left', 
        next: 'img.right',
        axis: 'x',
        offset: offset,
        duration: 300,
        easing: 'swing'};
    // apply serialScroll to the slider
    $('#slider1').serialScroll(scrollOptions);
    $('#slider2').serialScroll(scrollOptions2);
    // now apply localScroll to hook any other arbitrary links to trigger the effect
    $.localScroll(scrollOptions);
    $.localScroll(scrollOptions2);
    // finally, if the URL has a hash, move the slider in to position
    scrollOptions.duration = 1;
    scrollOptions2.duration = 1;
    $.localScroll.hash(scrollOptions);
    $.localScroll.hash(scrollOptions2);
    
	/**
	 * radio button selector
	 */
	$(".panel p label img").click( // title / emblem
		function(event) {
			event.preventDefault();
			$(this).parent().parent().parent().parent().find("input").removeAttr("checked") //-- remove all checked radios in CURRENT panel
			$(this).parent().parent().parent().parent().find("img").removeClass("selected") //-- remove all checked classes in CURRENT panel
			$(this).parent().find(":radio").attr("checked","checked");
			$(this).addClass("selected"); //-- add class to the label
		}
	);
	$("p.ranks label img").click( // rank
		function(event) {
			event.preventDefault();
			$(this).parent().parent().parent().find("input").removeAttr("checked") //-- remove all checked radios in CURRENT panel
			$(this).parent().parent().parent().find("img").removeClass("selected") //-- remove all checked classes in CURRENT panel
			$(this).parent().find(":radio").attr("checked","checked");
			$(this).addClass("selected"); //-- add class to the image
		}
	);
	$("p.titles label img").click(function(){
		var title = $(this).attr("title");
		var titleReturn = [];
			
		var catAssault = ["ACR", "AK-47", "F2000", "FAL", "FAMAS", "M4A1", "M16A4", "SCAR-H", "TAR-21"];
		var catSMG = ["Mini-Uzi", "MP5K", "P90", "UMP45", "VECTOR"];
		var catLMG = ["AUG HBAR", "L86 LSW", "M240","MG4","RPD"];
		var catSniper = ["Barrett .50cal", "Intervention", "M21 EBR","WA2000"];
		var catMPistols = ["Glock 18","M93 Raffica","PP2000","TMP"];
		var catShotguns = ["AA-12", "M1014", "Model 1887","Ranger","SPAS-12","Striker"];
		var catHandguns = [".44 Magnum","Desert Eagle","M9","USP .45"];
		var catLaunchers = ["AT4-HS","Javelin","RPG-7 x2","Stinger","Thumper x2"];
		var catSilver = ["AC130","Attack Helicopter","Blade Veteran","Chopper Gunner","Flash Veteran","Harrier Strike","Pave Low","Precision Airstrike","Predator Missile","Sentry Gun","Silent Veteran","Stand Veteran","Stealth Bomber","Stunner Veteran","The Prestige"];
		var catGold = ["AC130","Attack Helicopter","Blademaster","Chopper Gunner","Harrier Strike","Pave Low","Precision Airstrike","Predator Missile","Prestige 10","Sentry Gun","Stealth Bomber","The Flash","The Silent","The Stand","The Stunner"];
		
	
		// fill arrays with the titles affiliated with the image
		if(title == "Bloody-Sword") { titleReturn = ["Highlander","Excalibur","Impaler"] }
		else if(title == "Bloodsplat") { titleReturn = ["BOOM! Headshot.","Blood Money","BAM!"] }
		else if(title == "Ninja") { titleReturn = ["Ninja","Think Fast!","Full Force"] }
		else if(title == "Cheese") { titleReturn = ["Jack-in-the-Box","Dishes are Done","So Baked"] }
		else if(title == "Chicken") { titleReturn = ["Squawk Box","Skeet Shooter","3xt4 cr1zby"] }
		else if(title == "Dynamite") { titleReturn = ["Plastique","C4 and After","I.C.E. Man"] }
		else if(title == "Hello") { titleReturn = ["It's Personal","My name is...","Fired!"] }
		else if(title == "Apocalypse") { titleReturn = ["Rain of Fire","Reign Down","Global Thermonuclear War"] }
		else if(title == "Spank-Paddle") { titleReturn = ["No.","Crackin' Skulls","owned.","Tag! You're it!","Smash Hit", "OMFG"] }
		else if(title == "Cripple") { titleReturn = ["Accident Prone","a Major Pain","SBD"] }
		else if(title == "Weed") { titleReturn = ["Joint Ops","High Command","Blunt Trauma"] }
		else if(title == "Pushin-Daisies") { titleReturn = ["Pushin' Daisies","Not in the face!","STD"] }
		else if(title == "Make-it-Rain") { titleReturn = ["Money Shot!","Rainmaker","Reversal of Fortune"] }

		else if(title == "Camo-Digital") { titleReturn = ["1st Sgt."] }
		else if(title == "Camo-Artic") { titleReturn = ["Sgt."] }
		else if(title == "Camo-Digital") { titleReturn = ["1st Sgt"] }
		else if(title == "Camo-Bluetiger") { titleReturn = ["Maj."] }
		else if(title == "Cobra") { titleReturn = ["Get To The Choppa!","Cobra Strike","Sky Commander"] }
		else if(title == "Zero") { titleReturn = ["Ghostrider","Re-Zero","Vulture"] }
		else if(title == "Camo-Woodland") { titleReturn = ["S.S.D.D."] }
		else if(title == "Camo-Fall") { titleReturn = ["Commander"] }
		else if(title == "Camo-Urban") { titleReturn = ["1st Lt."] }
		else if(title == "Pavelow") { titleReturn = ["Flying Tank","Transformer","Shot Over"] }
		else if(title == "Satellite") { titleReturn = ["SIGINT","Starfish Prime","Counterintelligence"] }
		else if(title == "Camo-Redtiger") { titleReturn = ["Gen."] }
		else if(title == "Camo-Desert") { titleReturn = ["FNG"] }
		else if(title == "Explosion") { titleReturn = ["Destroyer","It's Sabotage!","Shock and Awe","Pyromaniac","Concussive Barrage","Backfire"] }
		else if(title == "MOAB") { titleReturn = ["Bombshell","Tha Bomb","MOAB"] }
		else if(title == "Bombs") { titleReturn = ["Time on Target","Preemptive Strike","Cluster Bomb"] }

		else if(title == "The-Bomb") { titleReturn = ["Rolling Thunder","Bomb's Away!","EOD","Explosive Ordinance","The Mad Bomber","Boom Boom"] }
		else if(title == "Harrier") { titleReturn = ["Jump Jet","True Liar","Afterburner"] }
		else if(title == "AC130") { titleReturn = ["Angel of Death","Godhand","Death From Above","Ready.Aim.Fire!","The Invincible","Spectre"] }
		else if(title == "Aircraft-Carriers") { titleReturn = ["Fire and Forget","All Your Base","Danger Close"] }
		else if(title == "Drifting") { titleReturn = ["Mach 5","2fast","Speed Demon"] }
		else if(title == "Satellite-2") { titleReturn = ["Intergalactic","The Watchman","Live LongÉ"] }
		else if(title == "Helicopters") { titleReturn = ["Flyswatter","Close Support","Overwatch"] }
		else if(title == "Pavelow-Side") { titleReturn = ["DZ Clear","Eyes Above","Direct Connect"] }
		else if(title == "Tank") { titleReturn = ["Hard Target","Wargasm","Unbreakable"] }
		else if(title == "Buggy") { titleReturn = ["Hijacker","Solid Steel","Decathlete"] }
		else if(title == "Mig-15") { titleReturn = ["Plane Whisperer","Broken Arrow","Carpet Bomber"] }
		else if(title == "Spy") { titleReturn = ["Double Agent","Spy Game","Mad Man"] }
		else if(title == "Rice-Rocket") { titleReturn = ["Drifter","Full Throttle","Trackstar"] }
		else if(title == "Snowmobile") { titleReturn = ["Dish the Rock","Team Player","Sidekick"] }
		
		else if(title == "Bomber-Pinup-Girl") { titleReturn = ["Pin Puller","Nerves of Steel","Airborne"] }
		else if(title == "Tiger") { titleReturn = ["Round 2"] }
		else if(title == "Flower") { titleReturn = ["Perfectionist","30 Something"] }
		else if(title == "Cemetery") { titleReturn = ["...The Harder They Fall.","Parting Gift","Deadline","Dead Man's Switch","Dying Breath","6 Feet Under"] }
		else if(title == "Skateboard") { titleReturn = ["To the Extreme","All Pro","Freerunner"] }
		else if(title == "End-of-Line") { titleReturn = ["End of Line"] }
		
		else if(title == "Shark") { titleReturn = ["Public Enemy","The Feared","Predator"] }
		else if(title == "Spider") { titleReturn = ["Hard Eight"] }
		else if(title == "Butterfly-2") { titleReturn = ["Stuck on You","Share Package"] }
		else if(title == "Bandaid") { titleReturn = ["Juggernaut","Surgical","Survivor"] }
		else if(title == "Samurai-Lv3") { titleReturn = ["Bow Down","Omnipotent","Army of 1","Unbelievable","Cold Steel","Omnicide"] }
		else if(title == "Zombie") { titleReturn = ["Toxic","Living Dead","Last Resort","Mmmmm Brains...","Phoenix Rising","Infected"] }
		else if(title == "Kingsnake") { titleReturn = ["Ambush","Behind Enemy Lines","Pathfinder"] }
		else if(title == "Magic") { titleReturn = ["Cloak and Dagger","Ta-Da!","Quick Change Artist"] }
		else if(title == "Blackcat") { titleReturn = ["9 Lives"] }
		else if(title == "Roll-Hard-Six") { titleReturn = ["Double Down","Pro Gambler","Lucky 7","The Domino Effect","6fears7","Droppin' Crates"] }
		else if(title == "Hazard") { titleReturn = ["Get Real","Dronekiller","Devastator"] }
		else if(title == "Butterfly") { titleReturn = ["Completely Numb","Darkbringer"] }

		else if(title == "Straight-Blast") { titleReturn = ["Lights Out!","One Inch Punch","Five Sided Fistagon"] }
		else if(title == "Lingerie-1") { titleReturn = ["Voyeur","Chick Magnet","The Flasher"] }
		else if(title == "Schooled") { titleReturn = ["Schooled"] }
		else if(title == "General") { titleReturn = ["Sarge","Dictator","Enemy of the State"] }
		else if(title == "Lingerie-2") { titleReturn = ["Silence","Rejected","Kleptomaniac"] }
		else if(title == "Graffiti-2") { titleReturn = ["Straight Up","The Anarchist","New Jack"] }
		else if(title == "Gears") { titleReturn = ["TacDel","Mastermind","Boilermaker"] }
		else if(title == "Operations") { titleReturn = ["ID Thief","Disruptor","Flatliner"] }
		else if(title == "Horsemen") { titleReturn = ["Blood Brothers","The Legend","Epic"] }
		else if(title == "Ghillie") { titleReturn = ["Grassy Knoll","UAV Jammer","4 the Record"] }
		else if(title == "Angry-Dragon") { titleReturn = ["The Mastodon","The Grim Reaper","The Dragon"] }
		else if(title == "Benjamins") { titleReturn = ["Charity Case","Time is Money","I'm Rich!"] }

		else if(title == "Tsunami") { titleReturn = ["Backsmasher","Headrush","Streaker"] }
		else if(title == "St-Patrick's") { titleReturn = ["Third Time Charm"] }
		else if(title == "Cute-Girl-2") { titleReturn = ["Companion Crate","<3","Heartbreaker"] }
		else if(title == "Hotdog-High") { titleReturn = ["Noob Tuber"] }
		else if(title == "Blimp") { titleReturn = ["Philanthropist","Heads Up!","The Bigger They Are"] }
		else if(title == "Fourth-of-July") { titleReturn = ["Bling Bling","Clay Pigeon","Pyrotechnical"] }
		else if(title == "Eyeball") { titleReturn = ["Martyr","Enemy With Benefits","How The?"] }
		else if(title == "Rainbows") { titleReturn = ["Friends with Benefits","UAV Rays","My Li'l Pwny"] }
		else if(title == "Cemetary") { titleReturn = ["...The Harder They Fall.","Parting Gift","Deadline","Dead Man's Switch","Dying Breath","6 Feet Under"] }
		
		else if(title == "United-States") { titleReturn = ["no text","Patriot"] }
		else if(title == "United-Kingdom") { titleReturn = ["no text","The Specialist"] }
		else if(title == "Canada") { titleReturn = ["no text","Great White North"] }
		else if(title == "Australia") { titleReturn = ["no text","Continental"] }
		else if(title == "Spain") { titleReturn = ["no text","The Conqueror"] }
		else if(title == "United-Kingdom") { titleReturn = ["no text","The Specialist"] }
		else if(title == "Austria") { titleReturn = ["no text","The Exterminator"] }
		else if(title == "Japan") { titleReturn = ["no text","Rising Sun"] }
		else if(title == "Brazil") { titleReturn = ["no text","The Redeemer"] }
		else if(title == "Swiss") { titleReturn = ["no text","Neutral"] }

		else if(title == "Sniper-1") { titleReturn = ["NBK","Ghillie in the Mist","Art of Stealth"] }
		else if(title == "Sniper-2") { titleReturn = ["Lone Wolf","Hair Trigger","Sureshot"] }
		else if(title == "Sniper-4") { titleReturn = ["Low Profile","Iron Lungs","Rival"] }
		else if(title == "Swordmaster-1") { titleReturn = ["Take a Stab","Backstabber","The Inciser"] }
		else if(title == "Grenades") { titleReturn = ["Frag Out!","Catch Shrapnel","Pineapple Express"] }
		else if(title == "RPG") { titleReturn = ["Big Bada Boom","Kill for Good","Sonic Boom"] }
		else if(title == "Buckshot") { titleReturn = ["Booyah!","OG","Finishing Touch"] }
		else if(title == "Night-Vision") { titleReturn = ["Remote Viewer","Submit to Authority","X-Ray Vision"] }
		else if(title == "Heartbeat-Sensor") { titleReturn = ["Early Detection","Hi Def","Big Brother","Amplifier","Givin' Static","Techno Killer"] }
		else if(title == "Tomahawk") { titleReturn = ["Bullseye","Stickman","The Ripper"] }
		else if(title == "Bullet") { titleReturn = ["1bullet2kills","K Factor","Bite the Bullet","Hardcore Only","Bandolier","Bulletproof"] }
		else if(title == "Smoke-Em") { titleReturn = ["Tango Down","The Avenger","Protect and Serve"] }
		else if(title == "Snub-Nose") { titleReturn = ["Click Click Boom","Stun Gun","Hard to Kill","Pop Off","Faceoff","Top Gun","Armed and Dangerous","Reloaded","High Caliber"] }
		else if(title == "Silencer") { titleReturn = ["Silent Strike","Invisible","Suppressor"] }
		else if(title == "AT4-Rocket") { titleReturn = ["Full Arsenal","MVP Assassin","Robin Hood"] }
		else if(title == "Cowboy") { titleReturn = ["Shot Down","Hot Shot","The Denier","Quickdraw","Hired Gun","Bounty Hunter"] }
		else if(title == "Machine-Gun") { titleReturn = ["Absentee Killer","Blindfire","Gat Trigger","Hands Free","Look! No Hands!","The Automator"] }
		
		else if(title == "Assault-Marksman") { titleReturn = catAssault.concat(catSMG,catLMG,catSniper) }
		else if(title == "Assault-Expert") { titleReturn = catAssault.concat(catSMG,catLMG,catSniper,catMPistols, catShotguns, catHandguns, catLaunchers) }
		else if(title == "Assault-Sharpshooter") { titleReturn = catAssault.concat(catSMG,catLMG,catSniper,catMPistols, catShotguns, catHandguns, catLaunchers) }
		else if(title == "Assault-Veteran") { titleReturn = catAssault.concat(catSMG,catLMG,catSniper,catMPistols, catShotguns, catHandguns, catLaunchers, catSilver) }
		else if(title == "Assault-Master") { titleReturn = catAssault.concat(catSMG,catLMG,catSniper,catMPistols, catShotguns, catHandguns, catLaunchers, catGold) }

		else{ titleReturn = [""] };
		
		$("div#titleTextChoices").empty();
		$("div#titleTextChoices").slideUp("fast");
		
		if(titleReturn != ""){
			//walk through the array to insert elements with text
			if(titleReturn.length < 7){
				//normal list items
				$.each(titleReturn, function(n, val){
					$("div#titleTextChoices").append('<label><input type="radio" class="hide" name="titleText" id="choice-'+n+'" value="'+val+'" />'+val+'</label>');
				});
			}else{
				//dropdown
				$("div#titleTextChoices").append('<select name="titleText" id="titleTextDropper"> </select>');
				$.each(titleReturn, function(n, val){
					$("select#titleTextDropper").append('<option value="'+val+'">'+val+'</option>');
				});
			
			}
			$("div#titleTextChoices").slideDown("slow");
			
			//set the first item to checked="checked" and set the selected class
			$("input#choice-0").attr("checked","checked");
			$("input#choice-0").parent().addClass("selected");
			
			// make the generated radioboxes clickable
			$("div#titleTextChoices label").click(function(){
				$(this).parent().find("label").removeClass("selected")
				$(this).addClass("selected");
				$(this).find(":radio").attr("checked","checked");
			});
		}
	});
});
$(window).load(function() {
	//wait for images to be loaded, then remove the "please wait" msg
	//$('p#loader').css({'background' : '#cfe1cc url(jQuery-scroller/gradient-green.gif) repeat-x top left'});
	$('p#loader').html('Done!<br/><img src="callsigns/ajax-loader.gif" width="16" height="11" />');
	$('p#loader').slideUp('slow');
	//$('p#loader').fadeOut('slow');
});

