	var player    =  null;
	var playlist  =  null;


      function playerReady(obj)
      {
        player = gid(obj.id);
        addListeners();
      };


      function addListeners()
      {
        playlist = player.getPlaylist();

        if((playlist !== null) && (playlist !== undefined))
        {
          player.addModelListener('STATE', 'stateMonitor');
        }
        else
        {
          setTimeout("addListeners()", 100);
        }
      };


      function stateMonitor(obj)
      {
        if((obj.newstate == 'COMPLETED'))
        {
          gid('placeholder').innerHTML = '<img src="images/splash.jpg">';
		}
      };


      function gid(name)
      {
        return document.getElementById(name);
      };
	  
      var flashvars =
      {
        'file':                         'http://www.qcmodule.net/qcstream/Intro_Final1-Web-new.flv',
        'id':                           'playerId',
        'autostart':                    'true'
      };

      var params =
      {
        'allowscriptaccess':            'always',
        'allowfullscreen':              'true',
        'bgcolor':                      '#FFFFFF'
      };

      var attributes =
      {
        'id':                           'playerId',
        'name':                         'playerId'
      };

	  var dwDefaults = new Class({
  //implements
  Implements: [Options],

  //options
  options: {
    collection: $$('input[type=text]')
  },
  
  //initialization
  initialize: function(options) {
    //set options
    this.setOptions(options);
    this.defaults();
  },
  
  //a method that does whatever you want
  defaults: function() {
    this.options.collection.each(function(el) {
      el.set('value',el.get('rel'));
      el.addEvent('focus', function() { if(el.get('value') == el.get('rel')) { el.set('value',''); } });
      el.addEvent('blur', function() { if(el.get('value') == '') { el.set('value',el.get('rel')); } });
    });
  }
  
});


window.addEvent('domready', function() {
  var defs = new dwDefaults({
    collection: $$('input.textBox')
  });
	
	var agent=navigator.userAgent.toLowerCase();
	var is_iphone = (agent.indexOf('iphone')!=-1);
	if (is_iphone)
	{
		$("placeholder").set('html', '<video src="http://184.73.209.142/html5-elements/Intro_Final1-Web-new_x264.mp4" width="640" height="360" autoplay controls></video>');

		var video = document.getElementsByTagName('video')[0];

		video.onended = function(e) {
		$("placeholder").set('html', '<img src="images/splash.jpg">');
		}

	}
	else
	{
		swfobject.embedSWF('video/player.swf', 'player', '640', '360', '9.0.124', false, flashvars, params, attributes);
	}
});


